Example #1
0
function daily_loop_all_portfolios()
{
    $accounts = get_all_active_portfolio_id();
    foreach ($accounts as $pid) {
        echo "pid: {$pid}", PHP_EOL;
        daily_buy_sell_cron($pid);
        sleep(2);
    }
}
                                                 $portRetArray = portfolio_return_history($pid, $start_date, $end_date);
                                                 $arrayLen = count($portRetArray);
                                                 #$retArray['name'] = $pid;
                                                 $retArray['name'] = $portRetArray[0]['description'] . ":" . $portRetArray[0]['risk_category'];
                                                 for ($x = 0; $x < $arrayLen; $x++) {
                                                     $newDateStr = strtotime($portRetArray[$x]['trade_date']);
                                                     $newDateStr = $newDateStr * 1000 - 14400000;
                                                     $preturn = $portRetArray[$x]['return_pct'] * 1 / 1;
                                                     array_push($dataArray, array($newDateStr, $preturn));
                                                 }
                                                 $retArray['data'] = $dataArray;
                                                 echo json_encode($retArray);
                                             } else {
                                                 if ($_GET['action'] == 'get_all_active_portfolio_id') {
                                                     $all_pids = array();
                                                     $all_pids = get_all_active_portfolio_id();
                                                     #			json_encode(get_all_active_portfolio_id());
                                                     echo json_encode($all_pids);
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }