示例#1
0
function abandonNowStocks()
{
    $holding = new holdings();
    $holding->set_variable("holdings_last_action", ABANDON_AT_CLOSE);
    $holding->set_variable("holdings_abandon_marked", 0);
    $symbols = array();
    $hids = array();
    $hasAbandon = false;
    while ($holding->loadNext()) {
        $symbol = $holding->get_variable('holdings_ticker_symbol');
        $tid = $holding->get_variable('holdings_ticker_id');
        $hid = $holding->get_variable('holdings_id');
        if (strlen($symbol) <= 0) {
            $ticker = new ticker();
            $ticker->set_variable("ticker_id", $tid);
            if ($ticker->load()) {
                $symbol = $ticker->get_variable("ticker_symbol");
            }
        }
        array_push($symbols, strtoupper($symbol));
        array_push($hids, $hid);
        $hasAbandon = true;
    }
    if ($hasAbandon) {
        print_r($symbols);
        print_r($hids);
        $results = finance_google::retrieveCurrentPrice($symbols);
        $updateHolding = new holdings();
        foreach ($results as $key => $value) {
            if ($key == "filesize") {
                continue;
            }
            $updateHolding->reset_query();
            $ticker = $key;
            $price = floatval($value);
            if ($price > 0) {
                echo "\nTICKER:" . $ticker . " PRICE=" . $price . "\n";
                $index = array_search($ticker, $symbols);
                $hid = $hids[$index];
                $updateHolding->set_variable("holdings_id", $hid);
                if (!$updateHolding->load()) {
                    echo "WRONG::" . $ticker . " NOT RECOGNIZED IN DB\n\n";
                    continue;
                }
                $updateHolding->set_variable("holdings_stop_price", $price);
                echo "\nChanging Stop Price for " . $ticker . " to " . $price . ". Opening Price at end of day.\n";
                $updateHolding->set_variable("holdings_abandon_marked", 1);
                $updateHolding->set_variable("holdings_abandon_hide", 1);
                $updateHolding->set_variable('holdings_abandon_date', date('Y-m-d H:i:s'));
                $updateHolding->set_variable("holdings_ticker_symbol", $ticker);
                $updateHolding->update();
            }
        }
    }
}
示例#2
0
     }
     if ($action == ABANDON_HARD_STOP) {
         continue;
     }
     if ($action == ABANDON_AT_CLOSE) {
         continue;
     }
     echo "\nAdding Ticker Symbol for " . $symbol . " to price update list.\n";
     array_push($symbols, strtoupper($symbol));
     array_push($hids, $hid);
 }
 //$results = finance_google::retrieveCurrentPrice($symbols);
 $results = finance::retrieveCurrentPrice($symbols, "o");
 $updateHolding = new holdings();
 foreach ($hids as $updateHid) {
     $updateHolding->reset_query();
     $updateHolding->set_variable("holdings_id", $updateHid);
     if ($updateHolding->load()) {
         $symbol = strtoupper($updateHolding->get_variable('holdings_ticker_symbol'));
         $tid = $holding->get_variable('holdings_ticker_id');
         $price = floatval($results[$symbol]);
         if ($price > 0) {
             $updateHolding->set_variable("holdings_stop_price", $price);
             echo "\n<br>Changing Stop Price for " . $symbol . " to " . $price . ". Opening Price after Abandon.\n<br>";
             $updateHolding->update();
         } else {
             $str = "holdings_abandon_date LIKE '" . date("Y-m-d") . "%'";
             echo "\nNOT Changing Stop Price for " . $symbol . " to " . $price . ". Opening Price after Abandon. SOMETHiNG WRONG!! " . $str . "\n<br>";
         }
     }
 }