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


PHP Stock::getCurPrice方法代码示例

本文整理汇总了PHP中Stock::getCurPrice方法的典型用法代码示例。如果您正苦于以下问题:PHP Stock::getCurPrice方法的具体用法?PHP Stock::getCurPrice怎么用?PHP Stock::getCurPrice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Stock的用法示例。


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

示例1: closeDay

 public function closeDay()
 {
     if ($cur_price = Stock::getCurPrice($this->sc_id)) {
         $this->day_close = $cur_price;
         $this->status = $this->day_open > $this->day_close ? ((double) $this->day_close / (double) $this->day_open - 1.0) * 100.0 : ((double) $this->day_close / (double) $this->day_open - 1.0) * 100.0;
         $database = new Database();
         $query = "UPDATE " . self::$table;
         $query .= " SET day_close =" . $this->day_close . ", status=" . $this->status;
         $query .= " WHERE id=" . $this->id;
         echo $query;
         $run = $database->query($query);
         if ($run) {
             unset($database);
             return true;
         } else {
             Log("Couldnt execute StockHistory::closeday close manually for {$this->sc_id}", LOG_MANUAL);
             return false;
         }
     } else {
         Log("Couldnt execute StockHistory::closeday close manually for {$this->sc_id}", LOG_MANUAL);
         return false;
     }
 }
开发者ID:ciplpj,项目名称:vsm,代码行数:23,代码来源:StockHistory.class.php

示例2: stockUpdate

 public function stockUpdate()
 {
     $stock_control = new StockControl($this->sc_id);
     $cur_price = Stock::getCurPrice($this->sc_id);
     if ($stock_control->getOverride() == -1) {
         $val = mt_rand(-abs($stock_control->low), -abs($stock_control->high));
         $new_val = $cur_price + $val;
         /*
          * Check if over_value as been reached or not! if it has
          * then terminate the control function
          */
         if ($stock_control->over_value >= $new_val) {
             $stock_control->setOverride(0);
             $stock_control->writeControl();
             Stock::addToMarket($this->sc_id, $new_val);
             return true;
         }
         if ($this->threshold < $new_val) {
             Stock::addToMarket($this->sc_id, $new_val);
             return true;
         } else {
             /*
              * Reached ground value so turn overide off now!
              */
             $stock_control->setOverride(0);
             $stock_control->writeControl();
             $val = mt_rand(0, abs(2 * $stock_control->high));
             $new_val = $cur_price + $val;
             Stock::addToMarket($this->sc_id, $new_val);
             return true;
         }
     } elseif ($stock_control->getOverride() == 1) {
         $val = mt_rand(abs($stock_control->low), abs($stock_control->high));
         $new_val = $cur_price + $val;
         /*
          * Check if over_value as been reached or not! if it has
          * then terminate the control function
          */
         if ($stock_control->over_value <= $new_val) {
             $stock_control->setOverride(0);
             $stock_control->writeControl();
             Stock::addToMarket($this->sc_id, $new_val);
             return true;
         }
         Stock::addToMarket($this->sc_id, $new_val);
         return true;
     } else {
         $news = News::getNewsForStock($this->sc_id);
         if (is_array($news) && !empty($news)) {
             $new = array_shift($news);
             if ($new['p_change'] > 0) {
                 if ($new['price_value'] > $cur_price) {
                     $val_diff = $new['price_value'] - $cur_price;
                     if ($val_diff > 400) {
                         $reduce = (int) $val_diff / mt_rand(40, 80);
                         $new_val = $cur_price + $reduce;
                         Stock::addToMarket($this->sc_id, $new_val);
                         return true;
                     } elseif ($val_diff > 200) {
                         $reduce = (int) $val_diff / mt_rand(20, 40);
                         $new_val = $cur_price + $reduce;
                         Stock::addToMarket($this->sc_id, $new_val);
                         return true;
                     } elseif ($val_diff > 100) {
                         $reduce = (int) $val_diff / mt_rand(10, 20);
                         $new_val = $cur_price + $reduce;
                         Stock::addToMarket($this->sc_id, $new_val);
                         return true;
                     } else {
                         $reduce = mt_rand(0, 3);
                         $new_val = $cur_price + $reduce;
                         Stock::addToMarket($this->sc_id, $new_val);
                         return true;
                     }
                 } else {
                     News::newsDone($new['id']);
                 }
             } else {
                 //Negative price changee in news
                 if ($new['price_value'] < $cur_price) {
                     $val_diff = $cur_price - $new['price_value'];
                     if ($val_diff > 400) {
                         $reduce = (int) $val_diff / mt_rand(40, 80);
                         $new_val = $cur_price - $reduce;
                         Stock::addToMarket($this->sc_id, $new_val);
                         return true;
                     } elseif ($val_diff > 200) {
                         $reduce = (int) $val_diff / mt_rand(20, 40);
                         $new_val = $cur_price - $reduce;
                         Stock::addToMarket($this->sc_id, $new_val);
                         return true;
                     } elseif ($val_diff > 100) {
                         $reduce = (int) $val_diff / mt_rand(10, 20);
                         $new_val = $cur_price - $reduce;
                         Stock::addToMarket($this->sc_id, $new_val);
                         return true;
                     } else {
                         $reduce = mt_rand(0, 3);
                         $new_val = $cur_price - $reduce;
                         /*
//.........这里部分代码省略.........
开发者ID:ciplpj,项目名称:vsm,代码行数:101,代码来源:Stock.class.php

示例3: add

 public static function add($sc_id, $data, $p_change, $live_date)
 {
     global $database;
     $sc_id = (int) $sc_id;
     $data = $database->escape_value($data);
     $p_change = (int) $p_change;
     $date = Database::date();
     $price_value = (double) (Stock::getCurPrice($sc_id) * (1.0 + (double) ((double) $p_change / (double) 100.0)));
     $query = "INSERT INTO " . self::$table . " (sc_id,data,date_uploaded,p_change,live_date,status,price_value,done)";
     $query .= "\tVALUES({$sc_id},'" . $data . "'" . ",'{$date}',{$p_change},'{$live_date}',0,{$price_value},0);";
     $run = $database->query($query);
     if ($run) {
         return true;
     } else {
         //TODO:When news update fails!
         return false;
     }
 }
开发者ID:ciplpj,项目名称:vsm,代码行数:18,代码来源:News.class.php

示例4: foreach

						<tr>
							<th>S.No</th>
							<th>Stock Name</th>
							<th>Average Price <i class="icon-money"></i></th>
							<th>Present Stock Price <i class="icon-money"></i></th>
							<th>Profit / Loss</th>
							<th>No. of Stocks</th>
							<th>Last Transaction</th>
							<th>Sell Stocks</th>
						</tr>
					</thead>
					<tbody>
					<?php 
//for($y = 0;$y< sizeof($stock_arr); $y++ ){
foreach ($holder_stocks->holder_stocks as $stock) {
    if ($stock['pur_price'] > Stock::getCurPrice($stock['sc_id'])) {
        $stat = "Loss";
        $col = "green";
    } else {
        $stat = "Profit";
        $col = "blue";
    }
    $s_no++;
    $company = new StockCompany($stock['sc_id']);
    $stock_obj = new Stock($stock['sc_id']);
    ?>
						<tr>
							<td><?php 
    echo $s_no;
    ?>
</td>
开发者ID:ciplpj,项目名称:vsm,代码行数:31,代码来源:portfolio.php

示例5: StockHolder

<?php 
include 'includes/header.inc.php';
?>
	<!-- Content
	================================================== -->
	<section id="content" class="container">

</section><!-- end .container -->
<?php 
if ($session->is_logged_in()) {
    $sh_id = $session->sh_id;
    $holder = new StockHolder($sh_id);
    $holder_stocks = new HolderStocks($sh_id);
    $cur_amt = 0;
    foreach ($holder_stocks->holder_stocks as $stock) {
        $cur_amt += $stock['s_qty'] * Stock::getCurPrice($stock['sc_id']);
    }
} else {
    header('Location: index.php');
    exit;
}
?>

<section class="container">
<h1>Marketplace</h1>  <div class="loader_market">
                                    <center>
                                        <img class="loading-image" src="img/loader.gif" alt="loading.." height="70" width="70">
                                    </center>
                                </div>
	<div class="row">
		<div class="span12">
开发者ID:ciplpj,项目名称:vsm,代码行数:31,代码来源:marketplace.php

示例6: array

     * close all day_closings!! direct function in stockhistory
     * also update StockCompany - dayclose = cur price and dayopen = cur price as well!
     */
    $histories = array();
    $companies = array();
    $controls = array();
    $stocks = Stock::getAllStocks();
    foreach ($stocks as $stock) {
        $histories[] = new StockHistory($stock->sc_id);
        $companies[] = new StockCompany($stock->sc_id);
        $controls[] = new StockControl($stock->sc_id);
    }
    foreach ($histories as $history) {
        $history->closeDay();
    }
    foreach ($companies as $company) {
        $cur_val = Stock::getCurPrice($company->id);
        $company->updateDayClose($cur_val);
        $company->updateDayOpen($cur_val);
    }
    foreach ($controls as $control) {
        $control->setOverride(0);
        $control->writeControl();
    }
    StockHolder::updateLeaderBoard();
    /*
     * Make the settings reset once the script has ended 
     * for next execution of the script so that stocks can be initialised first
     */
    reset_setting();
}
开发者ID:ciplpj,项目名称:vsm,代码行数:31,代码来源:automate.php

示例7: getAllStockPrices

 public static function getAllStockPrices($sh_id = null)
 {
     $database = new Database();
     $total_amount = 0;
     if ($sh_id) {
         $query = "SELECT sc_id,s_qty FROM " . self::$table;
         $query .= " WHERE sh_id = " . $sh_id;
         $holder_stocks_wrapper = $database->query($query);
         if ($holder_stocks_wrapper) {
             while ($holder_stock = $database->fetch_array($holder_stocks_wrapper)) {
                 $total_amount = $holder_stock['s_qty'] * Stock::getCurPrice($holder_stock['sc_id']);
             }
             unset($database);
             return $total_amount;
         } else {
             unset($database);
             return 0;
         }
     } else {
         unset($database);
         return false;
     }
 }
开发者ID:ciplpj,项目名称:vsm,代码行数:23,代码来源:HolderStocks.class.php

示例8: nStatus

 public function nStatus()
 {
     $database = new Database();
     $n_status = 0;
     $holder_stocks = new HolderStocks($this->sh_id);
     $cur_price = 0;
     $base_price = 0;
     $holder_stocks->holder_stocks;
     foreach ($holder_stocks->holder_stocks as $stock) {
         $cur_price = $cur_price + $stock['s_qty'] * Stock::getCurPrice($stock['sc_id']);
         $base_price += $stock['s_qty'] * $stock['pur_price'];
     }
     if ($cur_price > $base_price) {
         $n_status = (double) (double) $cur_price / (double) $base_price;
         $n_status = $n_status - 1.0;
     } elseif ($cur_price < $base_price) {
         $n_status = (double) (double) $cur_price / (double) $base_price;
         $n_status = 1.0 - $n_status;
     } else {
         $n_status = 0.0;
     }
     $n_status *= 100.0;
     if (isset($this->sh_id)) {
         $query = "UPDATE " . self::$table;
         $query .= " SET n_status = " . $n_status;
         $query .= " WHERE id=" . $this->sh_id;
         $run = $database->query($query);
         if ($run) {
             $this->n_status = $n_status;
             return $n_status;
         } else {
             return $n_status;
         }
     }
 }
开发者ID:ciplpj,项目名称:vsm,代码行数:35,代码来源:StockHolder.class.php


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