function daily_buy_sell_cron($pid) { $today = date("Y-m-d"); #$today = "2015-05-15"; $account = live_get_account_setting($pid); ## delete order_queue echo "delete order queue for {$pid} ", PHP_EOL; delete_queue($pid); ## sell echo "before sell", PHP_EOL; live_crsi_sell($today, $pid, $account['exit_crsi'], ""); ## make sure the orders are inserted into table at separate time sleep(1); echo "before buy", PHP_EOL; ## buy live_crsi_buy($today, $pid, $account['enter_crsi'], $account['enter_range'], $account['pct_limit_below'], $account['order_by'], $account['risk_factor'], $account['risk_sd'], $account['max_risk']); echo "before record performance", PHP_EOL; ## record portfolio value and performance record_daily_performance($pid); ## populate daily buy list live_populateDailyBuyList($today, $account['enter_crsi'], $account['enter_range'], $pid, $account['pct_limit_below']); }
$buy_list = live_getBuyList($today, $portfolioID, $orderBy); } else { if ($_GET['action'] == 'live_get_portfolio_risk') { $portfolioID = $_GET['portfolio_id']; $today = "2015-03-26"; $orderBy = "crsi desc"; live_get_portfolio_risk($today, $portfolioID); } else { if ($_GET['action'] == 'live_crsi_buy') { $portfolioID = $_GET['portfolio_id']; $today = $_GET['today']; if (empty($today)) { $today = date("Y-m-d"); } $account = live_get_account_setting($portfolioID); live_crsi_buy($today, $portfolioID, $account['enter_crsi'], $account['enter_range'], $account['pct_limit_below'], $account['order_by']); } else { if ($_GET['action'] == 'test_live_get_account_setting') { $portfolioID = $_GET['portfolio_id']; live_get_account_setting($portfolioID); } } } } } } } } #function live_populateDailyBuyList ($today_date, $crsiThreshold, $enterRange, $portfolioID, $dailyBuyList, $pctLimitBelow) { #function live_getBuyList ($today_date, $crsiThreshold, $enterRange, $portfolioID, $dailyBuyList, $pctLimitBelow, $orderBy) { }