本文整理汇总了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);