当前位置: 首页>>代码示例>>PHP>>正文


PHP crsi_sell函数代码示例

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


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

示例1: mysql_fetch_row

     $dateArray[$dateCount]['trade_date'] = $data[0];
     $dateCount++;
     #print "trade date in array: $data[0] <br />";
 }
 $count = 0;
 $minReturn = 100;
 $maxReturn = -100;
 for ($x = 0; $x < $dateCount - 1; $x++) {
     #while ($data = mysql_fetch_row($result)) {
     #	$trade_date = $data[0];
     $trade_date = $dateArray[$x]['trade_date'];
     $next_trade_date = $dateArray[$x + 1]['trade_date'];
     if ($showOutput) {
         print "trade date: {$trade_date} <br />";
     }
     crsi_sell($trade_date, $portfolioID, $tranHistory, $exitCRSI, $stopLoss, $next_trade_date);
     crsi_buy($trade_date, $breakOutSignal, $ADX_filter, $breakOutOrderBy, $portfolioID, $dailyBuyList, $enterCRSI, $enterRange, $enterLimit, $tranHistory, $orderBy, $next_trade_date);
     $value = get_historical_turtle_portfolio_value($trade_date, $portfolioID);
     $preturn = ($value - $original_investment) / $original_investment * 100;
     $dollar_return = $value - $original_investment;
     if ($preturn > $maxReturn) {
         $maxReturn = $preturn;
     }
     if ($preturn < $minReturn) {
         $minReturn = $preturn;
     }
     $portfolioReturn[$count]['trade_date'] = $trade_date;
     $portfolioReturn[$count]['return'] = $preturn;
     $portfolioReturn[$count]['value'] = $value;
     $portfolioReturn[$count]['maxReturn'] = $maxReturn;
     $portfolioReturn[$count]['minReturn'] = $minReturn;
开发者ID:jimmyc815,项目名称:algo,代码行数:31,代码来源:connorsRSI_strat_5.php

示例2: simulate_range_trade

function simulate_range_trade($portfolioID, $start_date, $end_date, $enterCRSI, $enterRange, $enterLimit, $exitCRSI, $commission, $max_risk, $risk_factor, $stop_loss_multiplier, $orderBy)
{
    global $original_investment;
    global $breakOutSignal;
    global $ADX_filter;
    global $breakOutSignal;
    global $breakOutOrderBy;
    global $simplePriceHistory;
    global $showOutput;
    global $risk_factor;
    global $max_risk;
    global $stop_loss_multiplier;
    global $tranHistArray;
    global $portfolio_table;
    $dailyBuyList = "crsi_daily_buy_list" . $portfolioID;
    ### drop recreate daily buy list table
    $query = "drop table if exists " . $dailyBuyList;
    $result = queryMysql($query);
    $create_sql = "CREATE TABLE {$dailyBuyList} ( ";
    $create_sql .= "portfolio_id int(11) DEFAULT NULL, ";
    $create_sql .= "rank int(11) NOT NULL DEFAULT '0', ";
    $create_sql .= "trade_date date DEFAULT NULL, ";
    $create_sql .= "symbol varchar(6) COLLATE latin1_german2_ci DEFAULT NULL, ";
    $create_sql .= "buy_price double DEFAULT NULL, ";
    $create_sql .= "UNIQUE KEY uniq_idx (portfolio_id,symbol), ";
    $create_sql .= "KEY pid_idex (portfolio_id)  ";
    $create_sql .= ") ENGINE=MEMORY ";
    $result = queryMysql($create_sql);
    $tranHistory = "turtle_portfolio_transaction" . $portfolioID;
    reset_portfolio($portfolioID);
    prepare_transactions_table($portfolioID, $tranHistory, $portfolio_table);
    $query = "select trade_date from quotes_memory where symbol = 'AAPL' and trade_date >= '" . $start_date . "' and trade_date <= '" . $end_date . "' order by trade_date";
    $result = queryMysql($query);
    $dateArray = array();
    $dateCount = 0;
    while ($data = mysql_fetch_row($result)) {
        $dateArray[$dateCount]['trade_date'] = $data[0];
        $dateCount++;
    }
    $count = 0;
    $minReturn = 100;
    $maxReturn = -100;
    $retArray = array();
    for ($x = 0; $x < $dateCount - 1; $x++) {
        #while ($data = mysql_fetch_row($result)) {
        #	$trade_date = $data[0];
        $trade_date = $dateArray[$x]['trade_date'];
        $next_trade_date = $dateArray[$x + 1]['trade_date'];
        if ($showOutput) {
            print "trade date: {$trade_date} <br />";
        }
        crsi_sell($trade_date, $portfolioID, $tranHistory, $exitCRSI, $stopLoss, $next_trade_date);
        crsi_buy($trade_date, $breakOutSignal, $ADX_filter, $breakOutOrderBy, $portfolioID, $dailyBuyList, $enterCRSI, $enterRange, $enterLimit, $tranHistory, $orderBy, $next_trade_date);
        $value = get_historical_turtle_portfolio_value($trade_date, $portfolioID);
        $preturn = ($value - $original_investment) / $original_investment * 100;
        $dollar_return = $value - $original_investment;
        if ($preturn > $maxReturn) {
            $maxReturn = $preturn;
        }
        if ($preturn < $minReturn) {
            $minReturn = $preturn;
        }
        $portfolioReturn[$count]['trade_date'] = $trade_date;
        $portfolioReturn[$count]['return'] = $preturn;
        $portfolioReturn[$count]['value'] = $value;
        $portfolioReturn[$count]['maxReturn'] = $maxReturn;
        $portfolioReturn[$count]['minReturn'] = $minReturn;
        $portfolioReturn[$count]['dollar_return'] = $dollar_return;
        $newDateStr = strtotime($trade_date);
        $newDateStr = $newDateStr * 1000 - 14400000;
        array_push($retArray, array($newDateStr, $preturn));
        $count++;
    }
    ## batch insert into crsi_portfolio_performance afterward
    $sql = array();
    foreach ($portfolioReturn as $row) {
        $sql[] = '(' . $portfolioID . ", '" . mysql_real_escape_string($row['trade_date']) . "', " . $row['dollar_return'] . ", " . $row['return'] . ", " . $row['value'] . ")";
    }
    try {
        mysql_query('INSERT INTO crsi_portfolio_performance (portfolio_id, trade_date, return_dollar, return_pct, portfolio_value) VALUES ' . implode(',', $sql));
    } catch (Exception $e) {
        echo "Query: {$query} \n";
        echo 'Caught exception: ', $e->getMessage(), "\n";
    }
    foreach ($tranHistArray as $th) {
        try {
            queryMysql($th);
        } catch (Exception $e) {
            echo "Query: {$th} \n";
            echo 'Caught exception: ', $e->getMessage(), "\n";
        }
    }
    mysql_close();
    return json_encode($retArray);
}
开发者ID:jimmyc815,项目名称:algo,代码行数:95,代码来源:backup_connorsRSI_strat_14.20150525.php

示例3: while

 while ($data = mysql_fetch_row($result)) {
     $dateArray[$dateCount]['trade_date'] = $data[0];
     $dateCount++;
     #print "trade date in array: $data[0] <br />";
 }
 $count = 0;
 $minReturn = 100;
 $maxReturn = -100;
 for ($x = 0; $x < $dateCount; $x++) {
     #while ($data = mysql_fetch_row($result)) {
     #	$trade_date = $data[0];
     $trade_date = $dateArray[$x]['trade_date'];
     if ($showOutput) {
         print "trade date: {$trade_date} <br />";
     }
     crsi_sell($trade_date, $portfolioID);
     crsi_buy($trade_date, $breakOutSignal, $ADX_filter, $breakOutOrderBy, $portfolioID, $dailyBuyList);
     $value = get_historical_turtle_portfolio_value($trade_date, $portfolioID);
     $preturn = ($value - $original_investment) / $original_investment * 100;
     $dollar_return = $value - $original_investment;
     if ($preturn > $maxReturn) {
         $maxReturn = $preturn;
     }
     if ($preturn < $minReturn) {
         $minReturn = $preturn;
     }
     $portfolioReturn[$count]['trade_date'] = $trade_date;
     $portfolioReturn[$count]['return'] = $preturn;
     $portfolioReturn[$count]['value'] = $value;
     $portfolioReturn[$count]['maxReturn'] = $maxReturn;
     $portfolioReturn[$count]['minReturn'] = $minReturn;
开发者ID:jimmyc815,项目名称:algo,代码行数:31,代码来源:connorsRSI_strat.php

示例4: round

     $keyStatsArray[0]['neg_tran_probability'] = round($keyStatsArray[0]['total_neg_tran'] / $keyStatsArray[0]['tran_count'] * 100, 2);
     echo json_encode($keyStatsArray);
 } elseif ($_GET['action'] == 'getRealTimeQuote') {
     $symbol = $_GET['symbol'];
     $quote = get_yahoo_rt_quote($symbol);
     echo json_encode($quote);
 } elseif ($_GET['action'] == 'test_turtle_portfolio_sell') {
     $today_date = $_GET['today_date'];
     $date = $_GET['date'];
     $portfolioID = 1;
     turtle_portfolio_sell($date, $portfolioID);
 } elseif ($_GET['action'] == 'test_crsi_sell') {
     $today_date = $_GET['today_date'];
     $date = $_GET['date'];
     $portfolioID = 1;
     crsi_sell($date, $portfolioID);
 } elseif ($_GET['action'] == 'test_turtle_portfolio_update_stop_loss') {
     $today_date = $_GET['today_date'];
     $date = $_GET['date'];
     turtle_portfolio_update_stop_loss($date);
 } elseif ($_GET['action'] == 'test_turtle_portfolio_buy') {
     $today_date = $_GET['today_date'];
     $date = $_GET['date'];
     turtle_portfolio_buy($date);
 } elseif ($_GET['action'] == 'test_turtle_portfolio_pyramid_buy') {
     $today_date = $_GET['today_date'];
     $date = $_GET['date'];
     turtle_portfolio_pyramid_buy($date);
 } elseif ($_GET['action'] == 'get_current_portfolio_value') {
     $today_date = $_GET['today_date'];
     $date = $_GET['date'];
开发者ID:jimmyc815,项目名称:algo,代码行数:31,代码来源:connorsRSI_strat_19.php

示例5: while

 while ($data = mysql_fetch_row($result)) {
     $dateArray[$dateCount]['trade_date'] = $data[0];
     $dateCount++;
     #print "trade date in array: $data[0] <br />";
 }
 $count = 0;
 $minReturn = 100;
 $maxReturn = -100;
 for ($x = 0; $x < $dateCount; $x++) {
     #while ($data = mysql_fetch_row($result)) {
     #	$trade_date = $data[0];
     $trade_date = $dateArray[$x]['trade_date'];
     if ($showOutput) {
         print "trade date: {$trade_date} <br />";
     }
     crsi_sell($trade_date, $portfolioID, $tranHistory);
     crsi_buy($trade_date, $breakOutSignal, $ADX_filter, $breakOutOrderBy, $portfolioID, $dailyBuyList, $enterCRSI, $enterRange, $enterLimit, $tranHistory);
     $value = get_historical_turtle_portfolio_value($trade_date, $portfolioID);
     $preturn = ($value - $original_investment) / $original_investment * 100;
     $dollar_return = $value - $original_investment;
     if ($preturn > $maxReturn) {
         $maxReturn = $preturn;
     }
     if ($preturn < $minReturn) {
         $minReturn = $preturn;
     }
     $portfolioReturn[$count]['trade_date'] = $trade_date;
     $portfolioReturn[$count]['return'] = $preturn;
     $portfolioReturn[$count]['value'] = $value;
     $portfolioReturn[$count]['maxReturn'] = $maxReturn;
     $portfolioReturn[$count]['minReturn'] = $minReturn;
开发者ID:jimmyc815,项目名称:algo,代码行数:31,代码来源:connorsRSI_strat.php


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