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

PHP getBreakoutStock6函数代码示例

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

本文整理汇总了PHP中getBreakoutStock6函数的典型用法代码示例。如果您正苦于以下问题:PHP getBreakoutStock6函数的具体用法?PHP getBreakoutStock6怎么用?PHP getBreakoutStock6使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了getBreakoutStock6函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: elseif

 } elseif ($_GET['action'] == 'testGetTradeDate') {
     // http://ngureco.hubpages.com/hub/How-to-Buy-Shares-Calculating-Average-Directional-Movement-Using-Excel-ADX-Formula
     $symbol = $_GET['symbol'];
     $date = $_GET['date'];
     $trade_date_id = getTradeDateID($symbol, $date);
     echo json_encode($trade_date_id);
 } elseif ($_GET['action'] == 'testGetBreakoutStock') {
     // http://ngureco.hubpages.com/hub/How-to-Buy-Shares-Calculating-Average-Directional-Movement-Using-Excel-ADX-Formula
     $symbol = $_GET['symbol'];
     $date = $_GET['date'];
     $testArray = array();
     //$testArray["pct_change"] = 0.3;
     //$testArray["relative_avg_vol"] = 0.4;
     $testArray["daily_change"] = 0.3;
     //$testArray[2] = "c";
     $breakOutList = getBreakoutStock6($date, "20_DAY_HIGH", $testArray, 1, "turtle_daily_buy_list");
     //		$breakOutList = getBreakoutStock5 ($date, "55_DAY_HIGH", $testArray, 1, "turtle_daily_buy_list");
     //		$breakOutList = getBreakoutStock4 ($date, "55_DAY_HIGH", $testArray);
     //$breakOutList = getBreakoutStock2 ($date, "55_DAY_HIGH", "relative_avg_vol");
     echo json_encode($breakOutList);
 } elseif ($_GET['action'] == 'testGetBuyList') {
     // http://ngureco.hubpages.com/hub/How-to-Buy-Shares-Calculating-Average-Directional-Movement-Using-Excel-ADX-Formula
     $symbol = $_GET['symbol'];
     $date = $_GET['date'];
     $crsiThreshold = $_GET['crsi'];
     $pctLimitBelow = $_GET['limit'];
     $testArray = array();
     //$testArray["pct_change"] = 0.3;
     //$testArray["relative_avg_vol"] = 0.4;
     $testArray["daily_change"] = 0.3;
     //$testArray[2] = "c";
开发者ID:jimmyc815,项目名称:algo,代码行数:31,代码来源:connorsRSI_strat_5.php


示例2: turtle_portfolio_buy

function turtle_portfolio_buy($date, $breakOutSignal, $ADX_filter, $breakOutOrderBy, $portfolioID, $dailyBuyList)
{
    global $max_num_holdings;
    global $max_risk;
    global $risk_factor;
    global $stop_loss_muptiplier;
    if (!$portfolioID) {
        $portfolioID = 1;
    }
    if (!$dailyBuyList) {
        $dailyBuyList = "turtle_daily_buy_list";
    }
    //$breakOutSignal = "55_DAY_HIGH";
    ### get list of breakout stocks
    //$breakOutStockArray = array();
    //		$breakOutStockArray = getBreakoutStock5 ($date, $breakOutSignal, $breakOutOrderBy, $portfolioID, $dailyBuyList);
    $breakOutStockArray = getBreakoutStock6($date, $breakOutSignal, $breakOutOrderBy, $portfolioID, $dailyBuyList);
    //		echo json_decode($breakOutStockArray);
    // set how many breakout stocks to buy
    //$len_array = count($breakOutStockArray);
    $len_array = count($breakOutStockArray);
    $risk_factor = 1 / $max_num_holdings;
    $portfolio_value = 0;
    $current_pos = 0;
    $next_buy_point = 100000;
    $stop_loss = 0;
    $num_shares = 0;
    $current_N = 0;
    $risk_value = 0;
    $purchase_value = 0;
    $sim_start_day = 55;
    $pyramid_mode = 0;
    #print "-------------------- \n";
    #$time_first = microtime(true);
    $stop_loss = 0;
    //		$ADX_filter = "Off";
    $current_trade_date_id = 0;
    $workingArray = $breakOutStockArray;
    $adxArray = "";
    $adxCount = 1;
    // check if ADX check if turned on
    if ($ADX_filter == "On") {
        for ($x = 1; $x < $len_array; $x++) {
            $current_trade_date_id = getTradeDateID($workingArray[$x]['symbol'], $date);
            $returnADX = calculate_ADX($workingArray[$x]['symbol'], $current_trade_date_id, 14);
            if ($returnADX["plusDI14"] > $returnADX["negDI14"] && $returnADX["ADX"] < 30) {
                //if ($returnADX["plusDI14"] < $returnADX["negDI14"])  {
                //array_delete ($breakOutStockArray[$x]);
                //unset ($breakOutStockArray[$x]);
                if ($returnADX["changeADX"] > 5) {
                    $adxArray[$adxCount] = $workingArray[$x];
                    $adxCount++;
                }
            }
        }
        $breakOutStockArray = $adxArray;
    }
    $len_array = count($breakOutStockArray);
    for ($x = 1; $x < $len_array; $x++) {
        ### get portfolio value
        $portfolio_value = get_historical_turtle_portfolio_value($date, $portfolioID);
        ### get current available cash
        $query = "select shares from turtle_portfolio where symbol = 'CASH' and portfolio_id = " . $portfolioID;
        $result = queryMysql($query);
        while ($data = mysql_fetch_row($result)) {
            $cash = $data[0];
        }
        $risk_value = $portfolio_value * $risk_factor / 100;
        $current_N = $breakOutStockArray[$x]['ATR'];
        if ($current_N > 0) {
            $num_shares = floor($risk_value / ($stop_loss_muptiplier * $current_N));
        }
        /*				$purchase_value = $num_shares * $breakOutStockArray[$x][$breakOutSignal];
        				$stop_loss = $breakOutStockArray[$x][$breakOutSignal] - (2*$current_N);
        				$stop_buy = $breakOutStockArray[$x][$breakOutSignal] + $current_N;
        */
        $purchase_value = $num_shares * $breakOutStockArray[$x]['purchase_price'];
        $stop_loss = $breakOutStockArray[$x]['purchase_price'] - $stop_loss_muptiplier * $current_N;
        $stop_buy = $breakOutStockArray[$x]['purchase_price'] + $current_N;
        $current_risk = get_current_risk($portfolioID);
        if ($cash > $purchase_value && $current_risk < $max_risk) {
            $cash = $cash - $purchase_value;
            $risk_dollar = $num_shares * ($stop_loss_muptiplier * $current_N);
            $risk_pct = $risk_dollar / $portfolio_value * 100;
            // insert into turtle_portfolio
            $my_sql = "insert into turtle_portfolio (portfolio_id, symbol, last_price, shares, cost_basis, stop_loss, stop_buy, risk, risk_pct) ";
            $my_sql .= "values (" . $portfolioID . ", '" . $breakOutStockArray[$x]['symbol'] . "', ";
            $my_sql .= $breakOutStockArray[$x]['close'] . ", ";
            $my_sql .= $num_shares . ", ";
            //					$my_sql .= $breakOutStockArray[$x][$breakOutSignal].", ";
            $my_sql .= $breakOutStockArray[$x]['purchase_price'] . ", ";
            $my_sql .= $stop_loss . ", ";
            $my_sql .= $stop_buy . ", ";
            $my_sql .= $risk_dollar . ", ";
            $my_sql .= $risk_pct . " )";
            $result = queryMysql($my_sql);
            // insert into transaction history table
            $my_sql = "insert into turtle_portfolio_transaction (portfolio_id, symbol, trade_type, trade_date, shares, price, risk, risk_pct, vsSpyRank) ";
            $my_sql .= "values (" . $portfolioID . ", '" . $breakOutStockArray[$x]['symbol'] . "', ";
            $my_sql .= "'BUY', ";
//.........这里部分代码省略.........
开发者ID:jimmyc815,项目名称:algo,代码行数:101,代码来源:portfolio_selection.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP getBrowser函数代码示例发布时间:2022-05-15
下一篇:
PHP getBreakdown函数代码示例发布时间: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