• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP historical_stock_price函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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";
开发者ID:jimmyc815,项目名称:algo,代码行数:31,代码来源:portfolio_selection.php


示例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);
开发者ID:jimmyc815,项目名称:algo,代码行数:31,代码来源:connorsRSI_strat_5.php


示例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;
//.........这里部分代码省略.........
开发者ID:jimmyc815,项目名称:algo,代码行数:101,代码来源:trend_setup.php



注:本文中的historical_stock_price函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP history函数代码示例发布时间:2022-05-15
下一篇:
PHP hikashop_table函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap