本文整理汇总了PHP中crsi_buy函数的典型用法代码示例。如果您正苦于以下问题:PHP crsi_buy函数的具体用法?PHP crsi_buy怎么用?PHP crsi_buy使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了crsi_buy函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mysql_fetch_row
$dateCount++;
#print "trade date in array: $data[0] <br />";
}
$count = 0;
$minReturn = 100;
$maxReturn = -100;
for ($x = 0; $x < $dateCount - 1; $x++) {
#while ($data = mysql_fetch_row($result)) {
# $trade_date = $data[0];
$trade_date = $dateArray[$x]['trade_date'];
$next_trade_date = $dateArray[$x + 1]['trade_date'];
if ($showOutput) {
print "trade date: {$trade_date} <br />";
}
crsi_sell($trade_date, $portfolioID, $tranHistory, $exitCRSI, $stopLoss, $next_trade_date);
crsi_buy($trade_date, $breakOutSignal, $ADX_filter, $breakOutOrderBy, $portfolioID, $dailyBuyList, $enterCRSI, $enterRange, $enterLimit, $tranHistory, $orderBy, $next_trade_date);
$value = get_historical_turtle_portfolio_value($trade_date, $portfolioID);
$preturn = ($value - $original_investment) / $original_investment * 100;
$dollar_return = $value - $original_investment;
if ($preturn > $maxReturn) {
$maxReturn = $preturn;
}
if ($preturn < $minReturn) {
$minReturn = $preturn;
}
$portfolioReturn[$count]['trade_date'] = $trade_date;
$portfolioReturn[$count]['return'] = $preturn;
$portfolioReturn[$count]['value'] = $value;
$portfolioReturn[$count]['maxReturn'] = $maxReturn;
$portfolioReturn[$count]['minReturn'] = $minReturn;
$portfolioReturn[$count]['dollar_return'] = $dollar_return;
示例2: queryMysql
$symbol = $_GET['symbol'];
$date = $_GET['date'];
// update cash position
$my_sql = "delete from turtle_portfolio where symbol != 'CASH'";
$result = queryMysql($my_sql);
turtle_portfolio_buy($date);
//echo json_encode($returnADX);
} elseif ($_GET['action'] == 'test_crsi_buy') {
// http://ngureco.hubpages.com/hub/How-to-Buy-Shares-Calculating-Average-Directional-Movement-Using-Excel-ADX-Formula
reset_portfolio(1);
$symbol = $_GET['symbol'];
$date = $_GET['date'];
// update cash position
//$my_sql = "delete from turtle_portfolio where symbol != 'CASH'";
//$result = queryMysql($my_sql);
crsi_buy($date);
//echo json_encode($returnADX);
} elseif ($_GET['action'] == 'getPortfolioHolding') {
$query = $_GET['txtInputQuery'];
//$query = "select * from turtle_portfolio";
$query = stripslashes($query);
$result = queryMysql($query);
$ret = array();
$i = 0;
while ($row = mysql_fetch_assoc($result)) {
$rowRet = array();
foreach ($row as $key => $value) {
//$rowRet[] = $value;
$ret[$i][$key] = $value;
}
//$ret[i] = $rowRet;
示例3: simulate_range_trade
function simulate_range_trade($portfolioID, $start_date, $end_date, $enterCRSI, $enterRange, $enterLimit, $exitCRSI, $commission, $max_risk, $risk_factor, $stop_loss_multiplier, $orderBy)
{
global $original_investment;
global $breakOutSignal;
global $ADX_filter;
global $breakOutSignal;
global $breakOutOrderBy;
global $simplePriceHistory;
global $showOutput;
global $risk_factor;
global $max_risk;
global $stop_loss_multiplier;
global $tranHistArray;
global $portfolio_table;
$dailyBuyList = "crsi_daily_buy_list" . $portfolioID;
### drop recreate daily buy list table
$query = "drop table if exists " . $dailyBuyList;
$result = queryMysql($query);
$create_sql = "CREATE TABLE {$dailyBuyList} ( ";
$create_sql .= "portfolio_id int(11) DEFAULT NULL, ";
$create_sql .= "rank int(11) NOT NULL DEFAULT '0', ";
$create_sql .= "trade_date date DEFAULT NULL, ";
$create_sql .= "symbol varchar(6) COLLATE latin1_german2_ci DEFAULT NULL, ";
$create_sql .= "buy_price double DEFAULT NULL, ";
$create_sql .= "UNIQUE KEY uniq_idx (portfolio_id,symbol), ";
$create_sql .= "KEY pid_idex (portfolio_id) ";
$create_sql .= ") ENGINE=MEMORY ";
$result = queryMysql($create_sql);
$tranHistory = "turtle_portfolio_transaction" . $portfolioID;
reset_portfolio($portfolioID);
prepare_transactions_table($portfolioID, $tranHistory, $portfolio_table);
$query = "select trade_date from quotes_memory where symbol = 'AAPL' and trade_date >= '" . $start_date . "' and trade_date <= '" . $end_date . "' order by trade_date";
$result = queryMysql($query);
$dateArray = array();
$dateCount = 0;
while ($data = mysql_fetch_row($result)) {
$dateArray[$dateCount]['trade_date'] = $data[0];
$dateCount++;
}
$count = 0;
$minReturn = 100;
$maxReturn = -100;
$retArray = array();
for ($x = 0; $x < $dateCount - 1; $x++) {
#while ($data = mysql_fetch_row($result)) {
# $trade_date = $data[0];
$trade_date = $dateArray[$x]['trade_date'];
$next_trade_date = $dateArray[$x + 1]['trade_date'];
if ($showOutput) {
print "trade date: {$trade_date} <br />";
}
crsi_sell($trade_date, $portfolioID, $tranHistory, $exitCRSI, $stopLoss, $next_trade_date);
crsi_buy($trade_date, $breakOutSignal, $ADX_filter, $breakOutOrderBy, $portfolioID, $dailyBuyList, $enterCRSI, $enterRange, $enterLimit, $tranHistory, $orderBy, $next_trade_date);
$value = get_historical_turtle_portfolio_value($trade_date, $portfolioID);
$preturn = ($value - $original_investment) / $original_investment * 100;
$dollar_return = $value - $original_investment;
if ($preturn > $maxReturn) {
$maxReturn = $preturn;
}
if ($preturn < $minReturn) {
$minReturn = $preturn;
}
$portfolioReturn[$count]['trade_date'] = $trade_date;
$portfolioReturn[$count]['return'] = $preturn;
$portfolioReturn[$count]['value'] = $value;
$portfolioReturn[$count]['maxReturn'] = $maxReturn;
$portfolioReturn[$count]['minReturn'] = $minReturn;
$portfolioReturn[$count]['dollar_return'] = $dollar_return;
$newDateStr = strtotime($trade_date);
$newDateStr = $newDateStr * 1000 - 14400000;
array_push($retArray, array($newDateStr, $preturn));
$count++;
}
## batch insert into crsi_portfolio_performance afterward
$sql = array();
foreach ($portfolioReturn as $row) {
$sql[] = '(' . $portfolioID . ", '" . mysql_real_escape_string($row['trade_date']) . "', " . $row['dollar_return'] . ", " . $row['return'] . ", " . $row['value'] . ")";
}
try {
mysql_query('INSERT INTO crsi_portfolio_performance (portfolio_id, trade_date, return_dollar, return_pct, portfolio_value) VALUES ' . implode(',', $sql));
} catch (Exception $e) {
echo "Query: {$query} \n";
echo 'Caught exception: ', $e->getMessage(), "\n";
}
foreach ($tranHistArray as $th) {
try {
queryMysql($th);
} catch (Exception $e) {
echo "Query: {$th} \n";
echo 'Caught exception: ', $e->getMessage(), "\n";
}
}
mysql_close();
return json_encode($retArray);
}
示例4: mysql_fetch_row
$dateArray[$dateCount]['trade_date'] = $data[0];
$dateCount++;
#print "trade date in array: $data[0] <br />";
}
$count = 0;
$minReturn = 100;
$maxReturn = -100;
for ($x = 0; $x < $dateCount; $x++) {
#while ($data = mysql_fetch_row($result)) {
# $trade_date = $data[0];
$trade_date = $dateArray[$x]['trade_date'];
if ($showOutput) {
print "trade date: {$trade_date} <br />";
}
crsi_sell($trade_date, $portfolioID);
crsi_buy($trade_date, $breakOutSignal, $ADX_filter, $breakOutOrderBy, $portfolioID, $dailyBuyList);
$value = get_historical_turtle_portfolio_value($trade_date, $portfolioID);
$preturn = ($value - $original_investment) / $original_investment * 100;
$dollar_return = $value - $original_investment;
if ($preturn > $maxReturn) {
$maxReturn = $preturn;
}
if ($preturn < $minReturn) {
$minReturn = $preturn;
}
$portfolioReturn[$count]['trade_date'] = $trade_date;
$portfolioReturn[$count]['return'] = $preturn;
$portfolioReturn[$count]['value'] = $value;
$portfolioReturn[$count]['maxReturn'] = $maxReturn;
$portfolioReturn[$count]['minReturn'] = $minReturn;
$portfolioReturn[$count]['dollar_return'] = $dollar_return;