本文整理匯總了PHP中stock_transaction_record函數的典型用法代碼示例。如果您正苦於以下問題:PHP stock_transaction_record函數的具體用法?PHP stock_transaction_record怎麽用?PHP stock_transaction_record使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了stock_transaction_record函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: json_encode
echo json_encode($retArray);
} elseif ($_GET['action'] == 'get_stock_transaction_record') {
$symbol = $_GET['symbol'];
$start_date = $_GET['start_date'];
$end_date = $_GET['end_date'];
$pid = $_GET['portfolio_id'];
// if end date is not supplied, default to today
if (!$end_date) {
$end_date = date("Y-m-d");
}
if (!$pid) {
$pid = 1;
}
$retArray = array();
$stockRetArray = array();
$stockRetArray = stock_transaction_record($symbol, $start_date, $end_date, $pid);
$arrayLen = count($stockRetArray);
for ($x = 0; $x < $arrayLen; $x++) {
$newDateStr = strtotime($stockRetArray[$x]['trade_date']);
$newDateStr = $newDateStr * 1000 - 14400000;
$price = $stockRetArray[$x]['price'] * 1 / 1;
$title = $stockRetArray[$x]['trade_type'];
$text = $stockRetArray[$x]['trade_type'] . " " . $stockRetArray[$x]['shares'] . " shares at " . $price;
$eachRow = array();
$eachRow['x'] = $newDateStr;
$eachRow['y'] = $price;
$eachRow['title'] = $title;
$eachRow['text'] = $text;
array_push($retArray, $eachRow);
}
echo json_encode($retArray);
示例2: array
$stockRetArray = array();
$stockRetArray = historical_stock_return($symbol, $start_date);
$arrayLen = count($stockRetArray);
for ($x = 0; $x < $arrayLen; $x++) {
$newDateStr = strtotime($stockRetArray[$x]['trade_date']);
$newDateStr = $newDateStr * 1000 - 14400000;
$ma_200 = $stockRetArray[$x]['200_MA'] * 1 / 1;
array_push($retArray, array($newDateStr, $ma_200));
}
echo json_encode($retArray);
} elseif ($_GET['action'] == 'get_stock_transaction_record') {
$symbol = $_GET['symbol'];
$start_date = $_GET['start_date'];
$retArray = array();
$stockRetArray = array();
$stockRetArray = stock_transaction_record($symbol, $start_date);
$arrayLen = count($stockRetArray);
for ($x = 0; $x < $arrayLen; $x++) {
$newDateStr = strtotime($stockRetArray[$x]['trade_date']);
$newDateStr = $newDateStr * 1000 - 14400000;
$price = $stockRetArray[$x]['price'] * 1 / 1;
$title = $stockRetArray[$x]['trade_type'];
$text = $stockRetArray[$x]['trade_type'] . " " . $stockRetArray[$x]['shares'] . " shares at " . $price;
$eachRow = array();
$eachRow['x'] = $newDateStr;
$eachRow['y'] = $price;
$eachRow['title'] = $title;
$eachRow['text'] = $text;
array_push($retArray, $eachRow);
}
echo json_encode($retArray);