本文整理汇总了PHP中historical_stock_price函数的典型用法代码示例。如果您正苦于以下问题:PHP historical_stock_price函数的具体用法?PHP historical_stock_price怎么用?PHP historical_stock_price使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了historical_stock_price函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: strtotime
*/
$newDateStr = strtotime($stockRetArray[$x]['trade_date']);
$newDateStr = $newDateStr * 1000 - 14400000;
$pclose = $stockRetArray[$x]['close'] * 1 / 1;
//print "return: $preturn";
//array_push($retArray, array($newDateStr, $preturn));
array_push($retArray, array($newDateStr, $pclose));
//array_push($retArray, {$newDateStr, $preturn});
}
echo json_encode($retArray);
} elseif ($_GET['action'] == 'get_stock_price_history_ohlc') {
$symbol = $_GET['symbol'];
$start_date = $_GET['start_date'];
$retArray = array();
$stockRetArray = array();
$stockRetArray = historical_stock_price($symbol, $start_date);
$arrayLen = count($stockRetArray);
for ($x = 0; $x < $arrayLen; $x++) {
/*print "<BR>date: $stockRetArray[$x] close: $stockRetArray[$x]['trade_date'] " ;
print $stockRetArray[$x]['trade_date'];
print $stockRetArray[$x]['close'];
print $stockRetArray[$x]['return'];
print "<BR>";
*/
$newDateStr = strtotime($stockRetArray[$x]['trade_date']);
$newDateStr = $newDateStr * 1000 - 14400000;
$pclose = $stockRetArray[$x]['close'] * 1 / 1;
$popen = $stockRetArray[$x]['open'] * 1 / 1;
$phigh = $stockRetArray[$x]['high'] * 1 / 1;
$plow = $stockRetArray[$x]['low'] * 1 / 1;
//print "return: $preturn";
示例2: chart_trends
$swingArray = chart_trends($symbol, $start_date, $end_date, $pid);
$arrayLen = count($swingArray);
echo json_encode($swingArray);
} elseif ($_GET['action'] == 'test_historical_stock_price') {
$symbol = $_GET['symbol'];
$start_date = $_GET['start_date'];
$e_date = $_GET['end_date'];
$pid = $_GET['portfolio_id'];
if (!$e_date) {
$e_date = date("Y-m-d");
}
if (!$pid) {
$pid = 1;
}
$swingArray = array();
$swingArray = historical_stock_price($symbol, $start_date, $e_date, $pid);
echo json_encode($swingArray);
}
}
function historical_stock_return($symbol, $start_date, $end_date)
{
$perfArray = array();
$count = 0;
// if end date is not supplied, default to today
if (!$end_date) {
$end_date = date("Y-m-d");
}
// get close price for symbol on starting date
$query = "select close from quotes where symbol = '" . $symbol . "' and trade_date = ";
$query .= "(select min(trade_date) from quotes where symbol = '" . $symbol . "' and trade_date >= '" . $start_date . "' and trade_date <= '" . $end_date . "')";
$result = queryMysql($query);
示例3: generate_trends
function generate_trends($symbol, $start_date, $end_date, $time_frame)
{
$stockRetArray = array();
$retArray = array();
$eachRow = array();
$spArray = array();
$sphArray = array();
$splArray = array();
$trend_strength = 0;
$spArray = generate_swing_points($symbol, $start_date, $end_date, $time_frame);
$spArrayLen = count($spArray);
for ($x = 0; $x < $spArrayLen; $x++) {
if ($spArray[$x]['type'] == "SPH") {
array_push($sphArray, $spArray[$x]);
} else {
if ($spArray[$x]['type'] == "SPL") {
array_push($splArray, $spArray[$x]);
}
}
}
$sphLen = count($sphArray);
$splLen = count($splArray);
$sphPos = 0;
$splPos = 0;
$stockRetArray = historical_stock_price($symbol, $start_date, $end_date);
$arrayLen = count($stockRetArray);
// use previous sph/spl data to determine trend transistion
$previous_sph = 0;
$previous_sph_volume = 1;
$previous_spl = 10000;
$previous_spl_volume = 1;
// there are 7 possible current
// CB = confirmed bullish
// SB = suspect bullish
// CR = confirmed bearish
// SR = suspect bearish
// CS = confirmed sideway
// SS = suspect sideway
$current_trend = "SS";
$trend_array = array();
$each_trend_row = array();
for ($x = 0; $x < $arrayLen; $x++) {
$newDateStr = strtotime($stockRetArray[$x]['trade_date']);
$newDateStr = $newDateStr * 1000 - 14400000;
$pclose = $stockRetArray[$x]['close'] * 1 / 1;
$popen = $stockRetArray[$x]['open'] * 1 / 1;
$phigh = $stockRetArray[$x]['high'] * 1 / 1;
$plow = $stockRetArray[$x]['low'] * 1 / 1;
$pvolume = $stockRetArray[$x]['volume'] * 1 / 1;
$pavg_volume = $stockRetArray[$x]['avg_volume'] * 1 / 1;
$prelative_avg_vol = $stockRetArray[$x]['relative_avg_vol'] * 1 / 1;
$pATR = $stockRetArray[$x]['ATR'] * 1 / 1;
// update SPH and SPL position
if ($sphArray[$sphPos + 1]['date'] >= $newDateStr && $newDateStr > $sphArray[$sphPos]['date']) {
$sphPos++;
}
if ($splArray[$splPos + 1]['date'] >= $newDateStr && $newDateStr > $splArray[$splPos]['date']) {
$splPos++;
}
// find new trend
if ($phigh > $sphArray[$sphPos - 1]['price']) {
$new_trend = get_new_bullish_trend($current_trend, $phigh, $pvolume, $newDateStr, $previous_sph, $sphArray[$sphPos - 1]['volume'], $sphArray[$sphPos - 1]['date']);
// each SPH point will only be used to change trend once
if ($sphPos < $sphLen) {
$sphPos++;
}
//determine trend strength
/* if (($previous_trend == "CR" || $previous_trend == "SR") && ($current_trend == "SS")) {
$trend_strength = -1;
} else if ($current_trend == "CB") {
$trend_strength = 3;
} else if ($current_trend == "SB") {
$trend_strength = 2;
} else if ($current_trend == "SS") {
$trend_strength = 0;
} else if ($current_trend == "CS") {
$trend_strength = 0;
} else if ($current_trend == "SR") {
$trend_strength = -2;
} else if ($current_trend == "CR") {
$trend_strength = -3;
}
*/
if (($current_trend == "CR" || $current_trend == "SR") && $new_trend == "SS") {
$trend_strength = -1;
} else {
if ($new_trend == "CB") {
$trend_strength = 3;
} else {
if ($new_trend == "SB") {
$trend_strength = 2;
} else {
if ($new_trend == "SS") {
$trend_strength = 0;
} else {
if ($new_trend == "CS") {
$trend_strength = 0;
} else {
if ($new_trend == "SR") {
$trend_strength = -2;
//.........这里部分代码省略.........