當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Stock::getTicker方法代碼示例

本文整理匯總了PHP中Stock::getTicker方法的典型用法代碼示例。如果您正苦於以下問題:PHP Stock::getTicker方法的具體用法?PHP Stock::getTicker怎麽用?PHP Stock::getTicker使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Stock的用法示例。


在下文中一共展示了Stock::getTicker方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: update_all_daily_data

function update_all_daily_data()
{
    $status = '';
    $query = mysql_query("SELECT * FROM stocks");
    while ($array = mysql_fetch_array($query)) {
        $stock = new Stock($array);
        if (update_stock_daily($stock->getTicker())) {
            $status .= 'Successfully Updated all stock info for ' . $stock->getTicker() . '<br />';
        } else {
            $status .= 'Failed to update stock ' . $stock->getTicker() . '<br />';
        }
    }
    return $status;
}
開發者ID:WealthCity,項目名稱:ktrader,代碼行數:14,代碼來源:init_functions.php

示例2: deactivateStock

/**
 * Will only deactivate if latest trade was 0 and last 5 days was also 0.
 */
function deactivateStock($stock_id)
{
    $stock = new Stock($stock_id, false);
    //Make sure stock exists.
    if ($stock->getId() < 0) {
        return "";
    }
    //Don't do anything if already inactive
    if ($stock->getStatus() == STATUS_INACTIVE) {
        return $stock->getTicker() . "(" . $stock->getId() . ") was already inactive.";
    }
    if (update_stock_info($stock->getTicker())) {
        //Only need to get new data if was updated.
        $stock = new Stock($stock_id, false);
    }
    if ($stock->getLastTrade() > 0.05) {
        return "";
    }
    update_stock_daily($stock->getTicker());
    $stock = new Stock($stock_id, true);
    $arr = $stock->getDailyData();
    if (sizeof($arr) < 5) {
        //If in here, we don't have enough data which means stock is probably a weird derivative.
        $stock->setStatus(STATUS_INACTIVE);
        $stock->persist();
        return "Removed Stock " . $stock->getTicker() . " (" . $stock->getId() . ") due to not enough daily data.";
    }
    //Make sure has been less than 0.05 for quite some time.
    if ($arr[0]->getClose() < 0.05 && $arr[1]->getClose() < 0.05 && $arr[2]->getClose() < 0.05 && $arr[3]->getClose() < 0.05) {
        $stock->setStatus(STATUS_INACTIVE);
        $stock->persist();
        return "Removed Stock " . $stock->getTicker() . " (" . $stock->getId() . ") due to a last closing price of \$" . $stock->getLastTrade();
    }
    return "";
}
開發者ID:WealthCity,項目名稱:ktrader,代碼行數:38,代碼來源:model.php


注:本文中的Stock::getTicker方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。