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

PHP getBuyList函数代码示例

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

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



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

示例1: crsi_buy

function crsi_buy($date, $breakOutSignal, $ADX_filter, $breakOutOrderBy, $portfolioID, $dailyBuyList, $enterCRSI, $enterRange, $enterLimit, $tranHistory, $orderBy, $next_date, $skipFactor, $stop_loss_multiplier, $max_risk, $risk_factor)
{
    global $max_num_holdings;
    #global $max_risk;
    #global $risk_factor;
    #global $stop_loss_multiplier;
    global $portfolio_tbl;
    global $showOutput;
    global $commission;
    global $tranHistArray;
    global $portfolio_table;
    if (!$portfolioID) {
        $portfolioID = 1;
    }
    if (!$dailyBuyList) {
        $dailyBuyList = "crsi_daily_buy_list";
    }
    $breakOutStockArray = getBuyList($date, $enterCRSI, $enterRange, $portfolioID, $dailyBuyList, $enterLimit, $orderBy);
    $sizeBuyList = sizeof($breakOutStockArray);
    if (!$skipFactor) {
        $skipFactor = 0.05;
    }
    /*
    echo "date: $date ", PHP_EOL;
    $count = sizeof($breakOutStockArray);
    echo "len array: $count ", PHP_EOL;
    
    for ($y=0; $y<sizeof($breakOutStockArray); $y++) {
    	echo "symbol: ", $breakOutStockArray[$y]['symbol'], PHP_EOL;	
    }
    		echo " end end ", PHP_EOL;
    */
    $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;
    $stop_loss = 0;
    $current_trade_date_id = 0;
    $workingArray = $breakOutStockArray;
    $adxArray = "";
    $adxCount = 1;
    $len_array = count($breakOutStockArray);
    $portfolio_value = get_historical_turtle_portfolio_value($date, $portfolioID);
    $query = "select shares from {$portfolio_table} where symbol = 'CASH' and portfolio_id = " . $portfolioID;
    $result = queryMysql($query);
    while ($data = mysql_fetch_row($result)) {
        $cash = $data[0];
    }
    #echo "date: $date symbol: ", $breakOutStockArray[$x]['symbol'], "cash: $cash purchase value: $purchase_value current risk: $current_risk max risk: $max_risk ", PHP_EOL;
    $current_risk = get_portfolio_risk($date, $portfolioID);
    #echo "date: $date symbol: ", $breakOutStockArray[$x]['symbol'], "cash: $cash purchase value: $purchase_value current risk: $current_risk max risk: $max_risk ", PHP_EOL;
    #print "current risk in the beginning: $current_risk \n";
    $buy_array = array();
    $skipNum = ceil($skipFactor * $sizeBuyList);
    #echo "date: ", $date, " size: ", $sizeBuyList, " skipping: ", $skipNum, PHP_EOL;
    #for ($x=1; $x < $len_array; $x++) {
    for ($x = $skipNum; $x < $sizeBuyList; $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_multiplier * $current_N));
        }
        /*				$purchase_value = $num_shares * $breakOutStockArray[$x][$breakOutSignal];
        				$stop_loss = $breakOutStockArray[$x][$breakOutSignal] - (2*$current_N);
        				$stop_buy = $breakOutStockArray[$x][$breakOutSignal] + $current_N;
        */
        #echo "x: $x date: $date	portfolio value: $portfolio_value	cash: $cash	risk value: $risk_value	current N: $current_N	symbol: ".$breakOutStockArray[$x]['symbol'], PHP_EOL;
        ## set purchase price to next day open price
        $breakOutStockArray[$x]['purchase_price'] = getStockPrice($next_date, $breakOutStockArray[$x]['symbol'], 'open');
        if (!$breakOutStockArray[$x]['purchase_price']) {
            break;
        }
        $h = $breakOutStockArray[$x]['high'];
        $l = $breakOutStockArray[$x]['low'];
        $o = $breakOutStockArray[$x]['open'];
        $c = $breakOutStockArray[$x]['close'];
        $p = $breakOutStockArray[$x]['purchase_price'];
        #print "trade date: $date symbol $s close: $c open: $o purchase price = $p <br /> \n";
        #$breakOutStockArray[$x]['purchase_price'] = $breakOutStockArray[$x]['buy_price'];
        $purchase_value = $num_shares * $breakOutStockArray[$x]['purchase_price'] + $commission;
        $stop_loss = $breakOutStockArray[$x]['purchase_price'] - $stop_loss_multiplier * $current_N;
        $stop_buy = $breakOutStockArray[$x]['purchase_price'] + $current_N;
        #$current_risk = get_current_risk($portfolioID);
        #$current_risk = get_portfolio_risk($date, $portfolioID);
//.........这里部分代码省略.........
开发者ID:jimmyc815,项目名称:algo,代码行数:101,代码来源:connorsRSI_strat_17.php


示例2: crsi_buy

function crsi_buy($date, $breakOutSignal, $ADX_filter, $breakOutOrderBy, $portfolioID, $dailyBuyList, $enterCRSI, $enterRange, $enterLimit, $tranHistory, $orderBy, $next_date)
{
    global $max_num_holdings;
    global $max_risk;
    global $risk_factor;
    global $stop_loss_muptiplier;
    global $portfolio_tbl;
    global $showOutput;
    if (!$portfolioID) {
        $portfolioID = 1;
    }
    if (!$dailyBuyList) {
        $dailyBuyList = "crsi_daily_buy_list";
    }
    //$breakOutSignal = "55_DAY_HIGH";
    ### get list of breakout stocks
    //$breakOutStockArray = array();
    #$crsiThreshold = 20;
    #$pctLimitBelow = 2;
    #$enterCRSI = 20;
    #$enterRange = 100;
    #$enterLimit = 2;
    //		$breakOutStockArray = getBreakoutStock5 ($date, $breakOutSignal, $breakOutOrderBy, $portfolioID, $dailyBuyList);
    //		$breakOutStockArray = getBreakoutStock6 ($date, $breakOutSignal, $breakOutOrderBy, $portfolioID, $dailyBuyList);
    $breakOutStockArray = getBuyList($date, $enterCRSI, $enterRange, $portfolioID, $dailyBuyList, $enterLimit, $orderBy);
    //		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;
    $stop_loss = 0;
    $current_trade_date_id = 0;
    $workingArray = $breakOutStockArray;
    $adxArray = "";
    $adxCount = 1;
    $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;
        */
        ## find purchase price
        ## if target buy price > open (gap down at open, past buy price)
        ##	set purchase price = (open + low ) / 2
        ## if open > target buy price > close (regular price action
        ##  set purchase price = target buy price
        if ($breakOutStockArray[$x]['buy_price'] > $breakOutStockArray[$x]['open']) {
            $breakOutStockArray[$x]['purchase_price'] = getStockPrice($date, $breakOutStockArray[$x]['symbol'], 'close');
            $s = $breakOutStockArray[$x]['symbol'];
            $p = $breakOutStockArray[$x]['purchase_price'];
            $b = $breakOutStockArray[$x]['buy_price'];
            #print "buy price > open: $s buy price = $b purchase price = $p <br />";
        } else {
            $breakOutStockArray[$x]['purchase_price'] = getStockPrice($next_date, $breakOutStockArray[$x]['symbol'], 'close');
            $s = $breakOutStockArray[$x]['symbol'];
            $p = $breakOutStockArray[$x]['purchase_price'];
            $b = $breakOutStockArray[$x]['buy_price'];
            $h = $breakOutStockArray[$x]['high'];
            $l = $breakOutStockArray[$x]['low'];
            $o = $breakOutStockArray[$x]['open'];
            $c = $breakOutStockArray[$x]['close'];
            #print "regular price: $o high $h low $l  close $c : $s buy price = $b purchase price = $p <br />";
        }
        ## set purchase price to next day open price
        ##$breakOutStockArray[$x]['purchase_price'] = getStockPrice($next_date, $breakOutStockArray[$x]['symbol'], 'open');
        $h = $breakOutStockArray[$x]['high'];
        $l = $breakOutStockArray[$x]['low'];
        $o = $breakOutStockArray[$x]['open'];
        $c = $breakOutStockArray[$x]['close'];
        $p = $breakOutStockArray[$x]['purchase_price'];
        #print "trade date: $date symbol $s close: $c open: $o purchase price = $p <br /> \n";
        #$breakOutStockArray[$x]['purchase_price'] = $breakOutStockArray[$x]['buy_price'];
        $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);
        $current_risk = get_portfolio_risk($date, $portfolioID);
//.........这里部分代码省略.........
开发者ID:jimmyc815,项目名称:algo,代码行数:101,代码来源:connorsRSI_strat_5.php


示例3: json_encode

     //		$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";
     $breakOutList = getBuyList($date, $crsiThreshold, $testArray, 2, "crsi_daily_buy_list", $pctLimitBelow);
     //		$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'] == 'test_turtle_portfolio_buy') {
     // http://ngureco.hubpages.com/hub/How-to-Buy-Shares-Calculating-Average-Directional-Movement-Using-Excel-ADX-Formula
     reset_portfolio(1);
     $symbol = $_GET['symbol'];
     $date = $_GET['date'];
     // update cash position
     $my_sql = "delete from turtle_portfolio where symbol != 'CASH'";
     $result = queryMysql($my_sql);
     turtle_portfolio_buy($date);
     //echo json_encode($returnADX);
 } elseif ($_GET['action'] == 'test_crsi_buy') {
开发者ID:jimmyc815,项目名称:algo,代码行数:31,代码来源:connorsRSI_strat_validate.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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