本文整理汇总了PHP中getBreakoutStock6函数的典型用法代码示例。如果您正苦于以下问题:PHP getBreakoutStock6函数的具体用法?PHP getBreakoutStock6怎么用?PHP getBreakoutStock6使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getBreakoutStock6函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: elseif
} elseif ($_GET['action'] == 'testGetTradeDate') {
// http://ngureco.hubpages.com/hub/How-to-Buy-Shares-Calculating-Average-Directional-Movement-Using-Excel-ADX-Formula
$symbol = $_GET['symbol'];
$date = $_GET['date'];
$trade_date_id = getTradeDateID($symbol, $date);
echo json_encode($trade_date_id);
} elseif ($_GET['action'] == 'testGetBreakoutStock') {
// http://ngureco.hubpages.com/hub/How-to-Buy-Shares-Calculating-Average-Directional-Movement-Using-Excel-ADX-Formula
$symbol = $_GET['symbol'];
$date = $_GET['date'];
$testArray = array();
//$testArray["pct_change"] = 0.3;
//$testArray["relative_avg_vol"] = 0.4;
$testArray["daily_change"] = 0.3;
//$testArray[2] = "c";
$breakOutList = getBreakoutStock6($date, "20_DAY_HIGH", $testArray, 1, "turtle_daily_buy_list");
// $breakOutList = getBreakoutStock5 ($date, "55_DAY_HIGH", $testArray, 1, "turtle_daily_buy_list");
// $breakOutList = getBreakoutStock4 ($date, "55_DAY_HIGH", $testArray);
//$breakOutList = getBreakoutStock2 ($date, "55_DAY_HIGH", "relative_avg_vol");
echo json_encode($breakOutList);
} elseif ($_GET['action'] == 'testGetBuyList') {
// http://ngureco.hubpages.com/hub/How-to-Buy-Shares-Calculating-Average-Directional-Movement-Using-Excel-ADX-Formula
$symbol = $_GET['symbol'];
$date = $_GET['date'];
$crsiThreshold = $_GET['crsi'];
$pctLimitBelow = $_GET['limit'];
$testArray = array();
//$testArray["pct_change"] = 0.3;
//$testArray["relative_avg_vol"] = 0.4;
$testArray["daily_change"] = 0.3;
//$testArray[2] = "c";
示例2: turtle_portfolio_buy
function turtle_portfolio_buy($date, $breakOutSignal, $ADX_filter, $breakOutOrderBy, $portfolioID, $dailyBuyList)
{
global $max_num_holdings;
global $max_risk;
global $risk_factor;
global $stop_loss_muptiplier;
if (!$portfolioID) {
$portfolioID = 1;
}
if (!$dailyBuyList) {
$dailyBuyList = "turtle_daily_buy_list";
}
//$breakOutSignal = "55_DAY_HIGH";
### get list of breakout stocks
//$breakOutStockArray = array();
// $breakOutStockArray = getBreakoutStock5 ($date, $breakOutSignal, $breakOutOrderBy, $portfolioID, $dailyBuyList);
$breakOutStockArray = getBreakoutStock6($date, $breakOutSignal, $breakOutOrderBy, $portfolioID, $dailyBuyList);
// echo json_decode($breakOutStockArray);
// set how many breakout stocks to buy
//$len_array = count($breakOutStockArray);
$len_array = count($breakOutStockArray);
$risk_factor = 1 / $max_num_holdings;
$portfolio_value = 0;
$current_pos = 0;
$next_buy_point = 100000;
$stop_loss = 0;
$num_shares = 0;
$current_N = 0;
$risk_value = 0;
$purchase_value = 0;
$sim_start_day = 55;
$pyramid_mode = 0;
#print "-------------------- \n";
#$time_first = microtime(true);
$stop_loss = 0;
// $ADX_filter = "Off";
$current_trade_date_id = 0;
$workingArray = $breakOutStockArray;
$adxArray = "";
$adxCount = 1;
// check if ADX check if turned on
if ($ADX_filter == "On") {
for ($x = 1; $x < $len_array; $x++) {
$current_trade_date_id = getTradeDateID($workingArray[$x]['symbol'], $date);
$returnADX = calculate_ADX($workingArray[$x]['symbol'], $current_trade_date_id, 14);
if ($returnADX["plusDI14"] > $returnADX["negDI14"] && $returnADX["ADX"] < 30) {
//if ($returnADX["plusDI14"] < $returnADX["negDI14"]) {
//array_delete ($breakOutStockArray[$x]);
//unset ($breakOutStockArray[$x]);
if ($returnADX["changeADX"] > 5) {
$adxArray[$adxCount] = $workingArray[$x];
$adxCount++;
}
}
}
$breakOutStockArray = $adxArray;
}
$len_array = count($breakOutStockArray);
for ($x = 1; $x < $len_array; $x++) {
### get portfolio value
$portfolio_value = get_historical_turtle_portfolio_value($date, $portfolioID);
### get current available cash
$query = "select shares from turtle_portfolio where symbol = 'CASH' and portfolio_id = " . $portfolioID;
$result = queryMysql($query);
while ($data = mysql_fetch_row($result)) {
$cash = $data[0];
}
$risk_value = $portfolio_value * $risk_factor / 100;
$current_N = $breakOutStockArray[$x]['ATR'];
if ($current_N > 0) {
$num_shares = floor($risk_value / ($stop_loss_muptiplier * $current_N));
}
/* $purchase_value = $num_shares * $breakOutStockArray[$x][$breakOutSignal];
$stop_loss = $breakOutStockArray[$x][$breakOutSignal] - (2*$current_N);
$stop_buy = $breakOutStockArray[$x][$breakOutSignal] + $current_N;
*/
$purchase_value = $num_shares * $breakOutStockArray[$x]['purchase_price'];
$stop_loss = $breakOutStockArray[$x]['purchase_price'] - $stop_loss_muptiplier * $current_N;
$stop_buy = $breakOutStockArray[$x]['purchase_price'] + $current_N;
$current_risk = get_current_risk($portfolioID);
if ($cash > $purchase_value && $current_risk < $max_risk) {
$cash = $cash - $purchase_value;
$risk_dollar = $num_shares * ($stop_loss_muptiplier * $current_N);
$risk_pct = $risk_dollar / $portfolio_value * 100;
// insert into turtle_portfolio
$my_sql = "insert into turtle_portfolio (portfolio_id, symbol, last_price, shares, cost_basis, stop_loss, stop_buy, risk, risk_pct) ";
$my_sql .= "values (" . $portfolioID . ", '" . $breakOutStockArray[$x]['symbol'] . "', ";
$my_sql .= $breakOutStockArray[$x]['close'] . ", ";
$my_sql .= $num_shares . ", ";
// $my_sql .= $breakOutStockArray[$x][$breakOutSignal].", ";
$my_sql .= $breakOutStockArray[$x]['purchase_price'] . ", ";
$my_sql .= $stop_loss . ", ";
$my_sql .= $stop_buy . ", ";
$my_sql .= $risk_dollar . ", ";
$my_sql .= $risk_pct . " )";
$result = queryMysql($my_sql);
// insert into transaction history table
$my_sql = "insert into turtle_portfolio_transaction (portfolio_id, symbol, trade_type, trade_date, shares, price, risk, risk_pct, vsSpyRank) ";
$my_sql .= "values (" . $portfolioID . ", '" . $breakOutStockArray[$x]['symbol'] . "', ";
$my_sql .= "'BUY', ";
//.........这里部分代码省略.........