public static function eventTrigger($event) { $highlights = new highlights(); $highlights->set_variable('highlights_tilleventid', $event); echo "Deleting all highlights because of event id = " . $event; $highlights->delete(); }
public function UpdateWatch($watchlistRecord, $lowOrEntry, $highOrRange) { // call pure virtual to get fields based on trade type $this->CalculateTargets($lowOrEntry, $highOrRange); $watchlistRecord->set_variable('watchlist_low', $lowOrEntry); $watchlistRecord->set_variable('watchlist_high', $highOrRange); $watchlistRecord->set_variable('watchlist_top', $this->topPrice); $watchlistRecord->set_variable('watchlist_bottom', $this->bottomPrice); $watchlistRecord->set_variable('watchlist_target0', $this->t0); $watchlistRecord->set_variable('watchlist_target1', $this->t1); $watchlistRecord->set_variable('watchlist_target2', $this->t2); $watchlistRecord->set_variable('watchlist_target3', $this->t3); $watchlistRecord->update(); $watchId = $watchlistRecord->get_variable('watchlist_id'); highlights::watchlistHighlight($watchId, W_ENTRY_ZONE, 0, highlights::EVENT_START_DAY); }
<th class="bottom lowpriority"> <span class="hastooltip" title="Entry Price">Entry Price</span><div class="none"><?php echo $typeStrings->entryHoldingDesc; ?> </div> </th> <th class="bottom "> <span class="hastooltip" title="BioBounce Return">Return</span><div class="none">The current return percent of this stock based on the original price.</div> </th> <th class="bottom"> <span class="hastooltip" title="Last Action Taken">Last Action</span><div class="none">The last BioBounce action that was taken.</div> </th> </tr> </thead> <tbody> <?php if ($login->showData) { $tablestate = "row_odd"; $someHoldingHidden = false; foreach ($holdings as $holding) { $hid = $holding['holdings_id']; $highlights = highlights::getHoldingsHighlights($hid); $last = $holding['last']; $action = $holding['holdings_last_action']; $tradeType = $holding['holdings_tradetype']; $lastAction = GetLastActionString($tradeType, $action); $abandonClass = IsAbandoned($action) ? " abandonRow " : ""; $hasToolTipString = ""; if (strlen($holding['holdings_tooltip']) > 0) { $hasToolTipString = "hastooltip"; } $iAmHolding = personal_holdings::iAmHolding($login->userId, $hid); if (!$iAmHolding) { $someHoldingHidden = true; } $checkedString = $iAmHolding ? "checked" : ""; $noneString = $iAmHolding ? "" : " none ";
} $holdingItem->set_variable('holdings_tooltip', $_POST['tip']); $holdingItem->set_variable('holdings_orig_price', floatval($_POST['origPrice'])); // Check if we have to update the abandon price and add highlight $origAbandon = $holdingItem->get_variable('holdings_stop_price'); $newAbandon = floatval($_POST['abandonPrice']); if ($origAbandon != $newAbandon) { $holdingItem->set_variable('holdings_stop_price', $newAbandon); highlights::holdingsHighlight($holdingId, H_ABANDON, 0, highlights::EVENT_START_DAY); } // Check if we have to update the abandon price and add highlight $origHardStop = $holdingItem->get_variable('holdings_top_price'); $newHardStop = floatval($_POST['hardStopPrice']); if ($origHardStop != $newHardStop) { $holdingItem->set_variable('holdings_top_price', $newHardStop); highlights::holdingsHighlight($holdingId, H_HARDSTOP, 0, highlights::EVENT_START_DAY); } $holdingItem->set_variable('holdings_orig_date', $_POST['origdate']); if ($abandonDate != null) { $holdingItem->set_variable('holdings_abandon_date', $_POST['abandondate']); } $holdingItem->update(); } $origDate = strtotime($holdingItem->get_variable('holdings_orig_date')); $action = $holdingItem->get_variable('holdings_last_action'); $t0 = $holdingItem->get_variable('holdings_t0'); $t1 = $holdingItem->get_variable('holdings_t1'); $t2 = $holdingItem->get_variable('holdings_t2'); $t3 = $holdingItem->get_variable('holdings_t3'); $hitT0 = $holdingItem->get_variable('holdings_t0_marked'); $hitT1 = $holdingItem->get_variable('holdings_t1_marked');
private function updateHoldings() { $holdings = new holdings(); $now = date('Y-m-d H:i:s'); while ($holdings->loadNextAll()) { $last_action = $holdings->get_variable('holdings_last_action'); $action = $last_action; $last = floatval($holdings->get_variable('last')); $high = floatval($holdings->get_variable('last_high')); $low = floatval($holdings->get_variable('last_low')); // check to make sure we didn't just zone for testing the ticker information $origDate = $holdings->get_variable('holdings_orig_date'); $diff = (strtotime($now) - (strtotime($origDate) + 60 * updater::HIGH_MINUTE_WINDOW)) / 60; if ($diff < 0) { $high = $last; } if ($high <= 0) { $high = $last; } if ($low <= 0) { $low = $last; } $symbol = $holdings->get_variable('ticker_symbol'); $tId = $holdings->get_variable('ticker_id'); //$t0 = floatval($holdings->get_variable('holdings_t0')); $t1 = floatval($holdings->get_variable('holdings_t1')); $t2 = floatval($holdings->get_variable('holdings_t2')); $t3 = floatval($holdings->get_variable('holdings_t3')); $t1Marked = $holdings->get_variable('holdings_t1_marked'); $t2Marked = $holdings->get_variable('holdings_t2_marked'); $t3Marked = $holdings->get_variable('holdings_t3_marked'); $stopType = $holdings->get_variable('holdings_stop_type'); $stopPrice = $holdings->get_variable('holdings_stop_price'); $topPrice = $holdings->get_variable('holdings_top_price'); $origPrice = $holdings->get_variable('holdings_orig_price'); $hId = $holdings->get_variable('holdings_id'); $tradeType = $holdings->get_variable('holdings_tradetype'); $newHolding = new holdings(); if ($tradeType == SHORT_TRADE) { if (!$t1Marked && ($last <= $t1 || $low <= $t1)) { //"SELL #1"; echo "\n\n\nSHORT BUY 1 and send tweet!"; $action = SELL1; $actionPrice = $t1; $newHolding->set_variable('holdings_t1_marked', 1); // update sell price of all holdings with this ticker_id watchlist::removeTickerHitT1($tId); //holdings::updateTickerSellPrices($tId, $origPrice); highlights::holdingsHighlight($hId, H_T1, 0, highlights::EVENT_START_DAY); } else { if (!$t2Marked && ($last <= $t2 || $low <= $t2)) { //"SELL #2"; echo "\n\n\nSHORT BUY2 and send tweet!"; $action = SELL2; $actionPrice = $t2; $newHolding->set_variable('holdings_t2_marked', 1); holdings::updateTickerSellPrices($tId, $t1); highlights::holdingsHighlight($hId, H_T2, 0, highlights::EVENT_START_DAY); } else { if (!$t3Marked && ($last <= $t3 || $low <= $t3)) { //"SELL #3"; echo "\n\n\nSELL 3 and send tweet!"; $actionPrice = $t3; $action = SELL3; $newHolding->set_variable('holdings_t3_marked', 1); holdings::updateTickerSellPrices($tId, $t3); highlights::holdingsHighlight($hId, H_T3, 0, highlights::EVENT_START_DAY); } else { if (!$t3Marked && $last >= $stopPrice) { if ($last_action != WARNING && !IsAbandoned($last_action)) { //"WARNING"; echo "\n\n\nWARNING and send tweet!"; $action = WARNING; $actionPrice = $stopPrice; } } } } } if ($action != $last_action) { $newHolding->set_variable('holdings_id', $hId); $newHolding->set_variable('holdings_last_action', $action); $newHolding->update(); // Add a transaction to the transaction table holdings::CreateNewTransaction($hId, $tradeType, $actionPrice, $action); } } else { if ($tradeType == LONG_TRADE) { if (!$t1Marked && ($last >= $t1 || $high >= $t1)) { //"SELL #1"; echo "\n\n\nSELL 1 and send tweet!"; $action = SELL1; $actionPrice = $t1; $newHolding->set_variable('holdings_t1_marked', 1); $newHolding->set_variable('holdings_stop_price', $origPrice); // update sell price of all holdings with this ticker_id watchlist::removeTickerHitT1($tId); //holdings::updateTickerSellPrices($tId, $origPrice); highlights::holdingsHighlight($hId, H_T1, 0, highlights::EVENT_START_DAY); } else { if (!$t2Marked && ($last >= $t2 || $high >= $t2)) { //"SELL #2"; echo "\n\n\nSELL 2 and send tweet!"; $action = SELL2; $actionPrice = $t2; $newHolding->set_variable('holdings_t2_marked', 1); holdings::updateTickerSellPrices($tId, $t1); highlights::holdingsHighlight($hId, H_T2, 0, highlights::EVENT_START_DAY); } else { if (!$t3Marked && ($last >= $t3 || $high >= $t3)) { //"SELL #3"; echo "\n\n\nSELL 3 and send tweet!"; $action = SELL3; $actionPrice = $t3; $newHolding->set_variable('holdings_t3_marked', 1); holdings::updateTickerSellPrices($tId, $t2); highlights::holdingsHighlight($hId, H_T3, 0, highlights::EVENT_START_DAY); } else { if ($last <= $stopPrice) { if ($last_action != WARNING && !IsAbandoned($last_action)) { //"WARNING"; echo "\n\n\nWARNING and send tweet!"; $action = WARNING; $actionPrice = $stopPrice; } } } } } if ($action != $last_action) { $newHolding->set_variable('holdings_id', $hId); $newHolding->set_variable('holdings_last_action', $action); $newHolding->update(); // Add a transaction to the transaction table holdings::CreateNewTransaction($hId, $tradeType, $actionPrice, $action); } } else { if ($tradeType == REVERSAL_TRADE) { } else { $abandonPrice = $stopPrice; $hardStopPrice = $topPrice; switch ($tradeType) { case BREAKOUT_TRADE: if (!$t3Marked && ($last >= $t3 || $high >= $t3)) { $holdings->markTarget(3, $symbol, $last, true, $t3); } else { if ($last <= $hardStopPrice) { holdings::abandonHardStop($hId, ""); } else { if ($last <= $abandonPrice) { holdings::abandonPriceMet($hId, $abandonPrice); // if ($last_action != WARNING && !IsAbandoned($last_action)) { // //"WARNING"; // echo "\n\n\nWARNING and send tweet!"; // $action = WARNING; // $actionPrice = $abandonPrice; // $newHolding -> set_variable('holdings_id', $hId); // $newHolding -> set_variable('holdings_last_action', $action); // $newHolding -> update(); // // holdings::CreateNewTransaction($hId, $tradeType, $abandonPrice, $action); // } } } } break; case PULLBACK_TRADE: if (!$t1Marked && ($last >= $t1 || $high >= $t1)) { $holdings->markTarget(1, $symbol, $last, true, $t1); } else { if (!$t1Marked && $last <= $abandonPrice) { holdings::abandonPriceMet($hId, $abandonPrice); // if ($last_action != WARNING && !IsAbandoned($last_action)) { // //"WARNING"; // echo "\n\n\nWARNING and send tweet!"; // $action = WARNING; // $actionPrice = $abandonPrice; // $newHolding -> set_variable('holdings_id', $hId); // $newHolding -> set_variable('holdings_last_action', $action); // $newHolding -> update(); // // holdings::CreateNewTransaction($hId, $tradeType, $abandonPrice, $action); // } } } break; case BACKDRAFT_TRADE: if (!$t1Marked && ($last <= $t1 || $low <= $t1)) { $holdings->markTarget(1, $symbol, $last, true, $t1); } else { if (!$t1Marked && $last >= $abandonPrice) { holdings::abandonPriceMet($hId, $abandonPrice); // if ($last_action != WARNING && !IsAbandoned($last_action)) { // //"WARNING"; // echo "\n\n\nWARNING and send tweet!"; // $action = WARNING; // $actionPrice = $abandonPrice; // $newHolding -> set_variable('holdings_id', $hId); // $newHolding -> set_variable('holdings_last_action', $action); // $newHolding -> update(); // // holdings::CreateNewTransaction($hId, $tradeType, $abandonPrice, $action); // } } } break; case BREAKDOWN_TRADE: if (!$t3Marked && ($last <= $t3 || $high <= $t3)) { $holdings->markTarget(3, $symbol, $last, true, $t3); } else { if ($last >= $hardStopPrice) { holdings::abandonHardStop($hId, ""); } else { if ($last >= $abandonPrice) { holdings::abandonPriceMet($hId, $abandonPrice); // if ($last_action != WARNING && !IsAbandoned($last_action)) { // //"WARNING"; // echo "\n\n\nWARNING and send tweet!"; // $action = WARNING; // $actionPrice = $abandonPrice; // $newHolding -> set_variable('holdings_id', $hId); // $newHolding -> set_variable('holdings_last_action', $action); // $newHolding -> update(); // // holdings::CreateNewTransaction($hId, $tradeType, $abandonPrice, $action); // } } } } break; } } } } // OBSOLETE WITH THE NEW METHODS if ($action != $last_action) { $tweet = new tweet(); $updateEmail = new email(email::ADDRESSES_ALL_CHOSEN, $tradeType, $hId); $tweet->newTweet($tradeType, $action, $symbol, $actionPrice); $updateEmail->newEmail($tradeType, $action, $symbol, $actionPrice); } } }
function startOfDayUpdate() { // Update the highlights with start of day trigger highlights::eventTrigger(highlights::EVENT_START_DAY); // Make sure no expired users get emails. user::resetAllExpiredEmailUpdates(); // Delete previously deleted watchlists watchlist::pruneDeletedWatchlistIds(); watchlist::deleteZonedTickers(BREAKOUT_TRADE); watchlist::deleteZonedTickers(BREAKDOWN_TRADE); watchlist::deleteZonedTickers(LONG_TRADE); watchlist::deleteZonedTickers(SHORT_TRADE); watchlist::deleteZonedTickers(PULLBACK_TRADE); watchlist::deleteZonedTickers(BACKDRAFT_TRADE); $deleteIds = array(); $deleteHoldingsIds = array(); $holdings = new holdings(); while ($holdings->loadNext()) { $hid = $holdings->get_variable("holdings_id"); $tid = $holdings->get_variable("holdings_ticker_id"); $action = $holdings->get_variable("holdings_last_action"); $hidden = $holdings->get_variable("holdings_abandon_hide"); $tradeType = $holdings->get_variable("holdings_tradetype"); if (IsAbandoned($action) && $hidden == 0) { $deleteHoldingsIds[] = $hid; echo "\nDELETING Holdings ID " . $hid . " because it was abandoned"; $watchlist = new watchlist(); $watchlist->set_variable("watchlist_ticker_id", $tid); $watchlist->set_variable("watchlist_tradetype", $tradeType); while ($watchlist->loadNext()) { $deleteIds[] = $watchlist->get_variable("watchlist_id"); } } else { if (($tradeType == REVERSAL_TRADE || $tradeType == SHORT_TRADE) && $hidden == 0) { $hitT3 = $holdings->get_variable("holdings_t3_marked"); if ($hitT3 == 1) { $deleteHoldingsIds[] = $hid; echo "\nDELETING Holdings ID " . $hid . " because topped reversal/shorts"; $watchlist = new watchlist(); $watchlist->set_variable("watchlist_ticker_id", $tid); $watchlist->set_variable("watchlist_tradetype", $tradeType); while ($watchlist->loadNext()) { $deleteIds[] = $watchlist->get_variable("watchlist_id"); } } } else { if (($tradeType == BACKDRAFT_TRADE || $tradeType == PULLBACK_TRADE) && $hidden == 0) { $hitT1 = $holdings->get_variable("holdings_t1_marked"); if ($hitT1 == 1) { $deleteHoldingsIds[] = $hid; echo "\nDELETING Holdings ID " . $hid . " because topped pullback/backdraft"; $watchlist = new watchlist(); $watchlist->set_variable("watchlist_ticker_id", $tid); $watchlist->set_variable("watchlist_tradetype", $tradeType); while ($watchlist->loadNext()) { $deleteIds[] = $watchlist->get_variable("watchlist_id"); } } } } } } foreach ($deleteIds as $wid) { echo "\n\n\nDELETING Watchlist ID " . $wid . " because it is abandoned or topped out reversal/shorts"; $watchlist = new watchlist(); $watchlist->set_variable('watchlist_id', $wid); $watchlist->delete(); } foreach ($deleteHoldingsIds as $hid) { echo "\n\n\nDELETING Holdings ID " . $hid . " because it is abandoned or topped out reversal/shorts"; $holdings = new holdings(); $holdings->set_variable('holdings_id', $hid); // instead of deleting, mark it as hidden if ($holdings->load()) { $tickerInfo = new ticker(); $tickerInfo->set_variable('ticker_id', $holdings->get_variable('holdings_ticker_id')); if ($tickerInfo->load()) { $holdings->set_variable('holdings_ticker_symbol', $tickerInfo->get_variable('ticker_symbol')); } $holdings->set_variable('holdings_abandon_hide', 1); $holdings->set_variable('holdings_abandon_date', date('Y-m-d H:i:s')); $holdings->update(); } // replace this //$holdings->delete(); } // delete the tickers that are no longer used. $ticker = new ticker(); $deleteIds = array(); while ($ticker->loadNext()) { $tid = $ticker->get_variable("ticker_id"); // reset the high and low $last = $ticker->get_variable("last"); $ticker->set_variable("today_high", $last); $ticker->set_variable("today_low", $last); $ticker->set_variable("last_high", $last); $ticker->set_variable("last_low", $last); $ticker->update(); $watchlist = new watchlist(); $watchlist->set_variable("watchlist_ticker_id", $tid); if (!$watchlist->load()) { $holding = new holdings(); $holding->set_variable("holdings_ticker_id", $tid); $holding->set_variable("holdings_abandon_hide", 0); if (!$holding->load()) { $deleteIds[] = $tid; } } } foreach ($deleteIds as $tid) { echo "\n\n\nDELETING TICKER ID " . $tid . " because it is no longer used"; $ticker = new ticker(); $ticker->set_variable('ticker_id', $tid); $ticker->delete(); } $tickerHist = new ticker_history(); while ($tickerHist->loadNextDistinctTicker()) { $ticker = new ticker(); $tid = $tickerHist->get_variable('history_ticker_id'); $ticker->set_variable('ticker_id', $tid); if (!$ticker->load()) { echo "\nTicker History Cleanup:: Removing " . $tid . "\n"; ticker_history::removeTickerHistory($tid); } } // try to reconcile any payments that are not currently known. // now doing this whenever a payment is received. //payment_info::reconcileAllPaymentUids(); }
<?php //Include the PS_Pagination class require_once 'php/db_interface/autoload.php'; $login = new login(true); if (isset($_POST['sendTweet'])) { comms::ListUpdatedSendMessages(); } /// REMOVE SOMETHING if (isset($_GET['delete_id'])) { $adminList = new adminControlWatchlist($_GET['delete_id']); $adminList->Remove(); highlights::watchlistHighlight($_GET['delete_id'], W_ROW_DELETE, 0, highlights::EVENT_START_DAY); } // Create all new tickers $counter = 1; while (true) { if (!isset($_POST["ticker" . $counter]) || strlen(trim($_POST["ticker" . $counter])) <= 0) { break; } $tradeType = $_POST["type" . $counter]; $tickerName = $_POST["ticker" . $counter]; $tickerLow = floatval($_POST["low" . $counter]); $tickerHigh = floatval($_POST["high" . $counter]); $className = adminControlWatchlist::GetWatchClassName($tradeType); $newTicker = new $className(); $newTicker->AddNewTickerAndWatch($tickerName, $tickerLow, $tickerHigh); $counter++; } // Load the information from the database $tradeTypesToUseInDropdown = array(PULLBACK_TRADE, BACKDRAFT_TRADE, BREAKOUT_TRADE, BREAKDOWN_TRADE);
function endOfDayUpdate() { // Update the highlights with end of day trigger highlights::eventTrigger(highlights::EVENT_END_DAY); // Abandon the stocks that were marked abandon during the day abandonNowStocks(); // update the close price of the ticker $ticker = new ticker(); while ($ticker->loadNext()) { $last = $ticker->get_variable('last'); $ticker->set_variable('last_close', $last); $ticker->update(); } /// update the holdings $holdings = new holdings(); while ($holdings->loadNextAll()) { $last_action = $holdings->get_variable('holdings_last_action'); if (IsAbandoned($last_action)) { continue; } $last = floatval($holdings->get_variable('last')); $low = floatval($holdings->get_variable('today_low')); $t3 = floatval($holdings->get_variable('holdings_t3')); $tId = $holdings->get_variable('ticker_id'); $symbol = $holdings->get_variable('ticker_symbol'); $stopType = $holdings->get_variable('holdings_stop_type'); $stopPrice = floatval($holdings->get_variable('holdings_stop_price')); $hId = $holdings->get_variable('holdings_id'); $initSellPriceSet = $holdings->get_variable('holdings_init_sell_price_set'); $isT1Marked = $holdings->get_variable('holdings_t1_marked'); $tradeType = $holdings->get_variable("holdings_tradetype"); echo "\n\n\nChecking " . $hId . " ticker " . $tId . " against \$" . $last; $action = NONE; switch ($tradeType) { case BREAKDOWN_TRADE: case SHORT_TRADE: $doAbandon = $last > $stopPrice; break; case BACKDRAFT_TRADE: $doAbandon = $last > $stopPrice && !$isT1Marked; break; case LONG_TRADE: case REVERSAL_TRADE: case BREAKOUT_TRADE: $doAbandon = $last < $stopPrice; break; case PULLBACK_TRADE: $doAbandon = $last < $stopPrice && !$isT1Marked; break; } if ($doAbandon) { $tweet = new tweet(); $abandonEmail = new email(email::ADDRESSES_SMS_ONLY, $tradeType, $hId); $action = ABANDON; $tweet->newTweet($tradeType, $action, $symbol, $stopPrice); $abandonEmail->newEmail($tradeType, $action, $symbol, $stopPrice); $newHolding = new holdings(); $newHolding->set_variable('holdings_id', $hId); $newHolding->set_variable('holdings_last_action', $action); $newHolding->set_variable('holdings_abandon_marked', 1); $newHolding->update(); // Add a transaction to the transaction table holdings::CreateNewTransaction($hId, $tradeType, $stopPrice, $action); } if ($action != ABANDON && $last_action == WARNING) { // reset WARNING list $t1Marked = $holdings->get_variable('holdings_t1_marked'); $t2Marked = $holdings->get_variable('holdings_t2_marked'); $t3Marked = $holdings->get_variable('holdings_t3_marked'); if ($t3Marked) { $next_action = SELL3; } else { if ($t2Marked) { $next_action = SELL2; } else { if ($t1Marked) { $next_action = SELL1; } else { $next_action = BUY; } } } $newHoldings = new holdings(); $newHoldings->set_variable('holdings_id', $hId); $newHoldings->set_variable('holdings_last_action', $next_action); echo "\nREPLACE WARNING WITH LAST ACTION\n"; echo $newHoldings->debug(); $newHoldings->update(); } } // end of day, check to see if we are out of zone /* $watchlist = new watchlist(); $watchlist->set_variable('watchlist_is_zoned', 1); $deleteIds = array(); while ($watchlist->loadNext()){ $tradeType = $watchlist->get_variable("watchlist_tradetype"); $ticker = new ticker(); $ticker->set_variable('ticker_id', $watchlist->get_variable('watchlist_ticker_id')); if ($ticker->load()){ if ($tradeType==SHORT_TRADE){ $high = floatval($ticker->get_variable('today_high')); $bottom = floatval($watchlist->get_variable('watchlist_bottom')); if ($high < $bottom){ $watchlistId = floatval($watchlist->get_variable('watchlist_id')); $deleteIds[] = $watchlistId; } }else if ($tradeType==LONG_TRADE){ $low = floatval($ticker->get_variable('today_low')); $top = floatval($watchlist->get_variable('watchlist_top')); if ($low > $top){ $watchlistId = floatval($watchlist->get_variable('watchlist_id')); $deleteIds[] = $watchlistId; } }else if ($tradeType==REVERSAL_TRADE){ $low = floatval($ticker->get_variable('today_low')); $top = floatval($watchlist->get_variable('watchlist_top')); if ($low > $top){ $watchlistId = floatval($watchlist->get_variable('watchlist_id')); $deleteIds[] = $watchlistId; } } } } foreach ($deleteIds as $wId){ echo "\n\n\nDELETING WATCHLIST ID ". $wId. " because it was higher than top all day"; $watchlist = new watchlist(); $watchlist->set_variable('watchlist_id', $wId); $watchlist->delete(); } * */ }
public static function abandonHardStop($holding_id, $message = "") { $holding = new holdings(); $holding->set_variable('holdings_id', $holding_id); if ($holding->load()) { $symbol = $holding->get_variable('holdings_ticker_symbol'); $tId = $holding->get_variable('holdings_ticker_id'); $tradeType = $holding->get_variable("holdings_tradetype"); $stopPrice = floatval($holding->get_variable('holdings_top_price')); $action = $holding->get_variable("holdings_last_action"); if (IsAbandoned($action)) { return; } $tweet = new tweet(); $abandonEmail = new email(email::ADDRESSES_ALL_CHOSEN, $tradeType, $hId); if (strlen($symbol) <= 0) { $ticker = new ticker(); $ticker->set_variable("ticker_id", $tId); if ($ticker->load()) { $symbol = $ticker->get_variable("ticker_symbol"); $last = $ticker->get_variable('last'); } } //"ABANDON"; $action = ABANDON_HARD_STOP; $tweet->newTweet($tradeType, $action, $symbol, $stopPrice, $message); $abandonEmail->newEmail($tradeType, $action, $symbol, $stopPrice, $message); $holding->set_variable('holdings_last_action', $action); $holding->set_variable('holdings_stop_price', $stopPrice); $holding->update(); highlights::holdingsHighlight($hId, H_LAST_ACTION, 0, highlights::EVENT_END_DAY); // Add a transaction to the transaction table $transactions = new transactions(); $transactions->set_variable('transaction_holdings_id', $holding_id); $transactions->set_variable('transaction_price', $stopPrice); $transactions->set_variable('transaction_date', date('Y-m-d H:i:s')); $transactions->set_variable('transaction_action', ABANDON_HARD_STOP); $transactions->set_variable('transaction_tradetype', $tradeType); $transactions->createNew(); } }
function processPullbacks() { $watches = new watchlist(); $watches->set_variable("watchlist_tradetype", PULLBACK_TRADE); while ($watches->loadNext()) { $tId = $watches->get_variable("watchlist_ticker_id"); $wId = $watches->get_variable("watchlist_id"); $calcHigh = $watches->get_variable("watchlist_high"); $calcLow = $watches->get_variable("watchlist_low"); $ticker = new ticker(); $ticker->set_variable("ticker_id", $tId); if ($ticker->load()) { $dayHigh = $ticker->get_variable("today_high"); $symbol = strtoupper($ticker->get_variable("ticker_symbol")); echo "Testing " . $symbol . " PrevHigh=" . $calcHigh . " DayHigh=" . $dayHigh . "<br>\n"; if ($dayHigh > $calcHigh) { echo " RECALC AND HIGHLIGHTING\n<br>"; $className = adminControlWatchlist::GetWatchClassName(PULLBACK_TRADE); $watchlistAdmin = new $className($wId); $watchlistAdmin->Edit($calcLow, $dayHigh); // highlight the abandon price highlights::watchlistHighlight($wId, W_ENTRY_ZONE, 0, highlights::EVENT_START_DAY); } } } }