本文整理汇总了PHP中getTradeDateID函数的典型用法代码示例。如果您正苦于以下问题:PHP getTradeDateID函数的具体用法?PHP getTradeDateID怎么用?PHP getTradeDateID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getTradeDateID函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getTradeDateID
$purchase_value = 0;
$sim_start_day = 55;
$pyramid_mode = 0;
$stop_loss = 0;
$ADX_filter = "On";
$current_trade_date_id = 0;
$workingArray = $breakOutStockArray;
$tmpArray = "";
$breakOutCount = 1;
print "original leng: ";
print $len_array;
// check if ADX check if turned on
if ($ADX_filter == "On") {
for ($x = 1; $x < $len_array; $x++) {
$symbol = $workingArray[$x]['symbol'];
$current_trade_date_id = getTradeDateID($workingArray[$x]['symbol'], $date);
print "symbol: ";
print $workingArray[$x]['symbol'];
print " ";
$returnADX = calculate_ADX($workingArray[$x]['symbol'], $current_trade_date_id, 14);
print " plus DI 14: ";
print $returnADX["plusDI14"];
print " neg DI 14: ";
print $returnADX["negDI14"];
print " ADX: ";
print $returnADX["ADX"];
if ($returnADX["plusDI14"] > $returnADX["negDI14"] && $returnADX["ADX"] > 25) {
// array_delete ($breakOutStockArray[$x]);
print "Meet Requirement :";
print $x;
print " ";
开发者ID:jimmyc815,项目名称:algo,代码行数:31,代码来源:connorsRSI_strat_5.php
示例2: turtle_portfolio_buy
function turtle_portfolio_buy($date, $breakOutSignal, $ADX_filter, $breakOutOrderBy)
{
global $max_num_holdings;
global $max_risk;
global $risk_factor;
//$breakOutSignal = "55_DAY_HIGH";
### get list of breakout stocks
//$breakOutStockArray = array();
$breakOutStockArray = getBreakoutStock5($date, $breakOutSignal, $breakOutOrderBy);
// 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;
$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);
### get current available cash
$query = "select shares from turtle_portfolio where portfolio_id = 1 and symbol = 'CASH'";
$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 / (2 * $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'] - 2 * $current_N;
$stop_buy = $breakOutStockArray[$x]['purchase_price'] + $current_N;
$current_risk = get_current_risk();
if ($cash > $purchase_value && $current_risk < $max_risk) {
$cash = $cash - $purchase_value;
$risk_dollar = $num_shares * (2 * $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 (1, '" . $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 . " )";
//print $my_sql;
//print "\n";
$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) ";
$my_sql .= "values (1, '" . $breakOutStockArray[$x]['symbol'] . "', ";
$my_sql .= "'BUY', ";
$my_sql .= "'" . $date . "', ";
$my_sql .= $num_shares . ", ";
// $my_sql .= $breakOutStockArray[$x][$breakOutSignal].", ";
$my_sql .= $breakOutStockArray[$x]['purchase_price'] . ", ";
$my_sql .= $risk_dollar . ", ";
$my_sql .= $risk_pct . " )";
//print "tranx: $my_sql";
$result = queryMysql($my_sql);
//.........这里部分代码省略.........
开发者ID:jimmyc815,项目名称:algo,代码行数:101,代码来源:portfolio_selection.php
示例3: json_encode
//$rowRet[] = $value;
$ret[$i][$key] = $value;
}
//$ret[i] = $rowRet;
$i++;
}
echo json_encode($ret);
} elseif ($_GET['action'] == 'testPopulateDailyBuyList') {
// 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'];
$portfolioID = 1;
$dailyBuyList = "crsi_daily_buy_list";
$trade_date_id = getTradeDateID($symbol, $date);
populateDailyBuyList($date, $crsiLimit, $symbol, $portfolioID, $dailyBuyList, $pctLimitBelow);
//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");
开发者ID:jimmyc815,项目名称:algo,代码行数:31,代码来源:connorsRSI_strat_20150309.php
示例4: live_turtle_portfolio_buy
function live_turtle_portfolio_buy($date, $breakOutSignal, $ADX_filter, $breakOutOrderBy, $portfolioID, $dailyBuyList)
{
global $max_num_holdings;
global $max_risk;
global $risk_factor;
if (!$portfolioID) {
$portfolioID = 2;
}
if (!$dailyBuyList) {
$dailyBuyList = "turtle_daily_buy_list_live";
}
//$breakOutSignal = "55_DAY_HIGH";
### get list of breakout stocks
//$breakOutStockArray = array();
$breakOutStockArray = live_get_breakout_stock($breakOutSignal, $breakOutOrderBy, $portfolioID, $dailyBuyList);
// 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;
$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_realtime_turtle_portfolio_value($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;
### get yesterday's ATR
$query = "select ATR from price_history where symbol = '" . $breakOutStockArray[$x]['symbol'] . "' and trade_date_id = (select max(trade_date_id) from price_history where symbol = '" . $breakOutStockArray[$x]['symbol'] . "')";
$result3 = queryMysql($query);
while ($data3 = mysql_fetch_row($result3)) {
$this_ATR = $data3[0];
}
$current_N = $this_ATR;
if ($current_N > 0) {
$num_shares = floor($risk_value / (2 * $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'] - 2 * $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 * (2 * $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]['last_price'] . ", ";
$my_sql .= $num_shares . ", ";
$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) ";
$my_sql .= "values (" . $portfolioID . ", '" . $breakOutStockArray[$x]['symbol'] . "', ";
$my_sql .= "'BUY', ";
//.........这里部分代码省略.........
开发者ID:jimmyc815,项目名称:algo,代码行数:101,代码来源:turtle_live_monitor.php
注:本文中的getTradeDateID函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论