Пример #1
0
            $holdingId = intval($_POST['holding_id']);
        } else {
            if (isset($_GET['history_id'])) {
                $holdingId = intval($_GET['history_id']);
                holdings::ADMIN_MarkAbandoned($holdingId);
                header('Location: admin.editallholdings.php');
            } else {
                header('Location: admin.editallholdings.php');
            }
        }
    }
}
// load holding data
$holdingItem = new holdings();
$holdingItem->set_variable('holdings_id', $holdingId);
if ($holdingItem->load()) {
    $abandonDate = strtotime($holdingItem->get_variable('holdings_abandon_date'));
    $tickerId = $holdingItem->get_variable('holdings_ticker_id');
    $ticker = new ticker();
    $ticker->set_variable('ticker_id', $tickerId);
    if ($ticker->load()) {
        $tickerSymbol = $ticker->get_variable('ticker_symbol');
        $last = $ticker->get_variable('last');
    } else {
        $tickerSymbol = "ERROR";
    }
    // Mark Targets
    if (isset($_GET['markTarget'])) {
        $holdingItem->markTarget($_GET['markTarget'], $tickerSymbol, $last);
        $holdingItem->load();
    }
Пример #2
0
            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>";
            }
        }
    }
    echo "\ncomplete HOLDINGS abandon update";
}
Пример #3
0
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);
/// REMOVE SOMETHING
if (isset($_GET['delete_hid'])) {
    $holdings = new holdings();
    $holdings->set_variable('holdings_id', $_GET['delete_hid']);
    if ($holdings->load()) {
        $holdings->delete();
    }
}
// Load the information from the database
$tradeTypesToUse = array(LONG_TRADE, PULLBACK_TRADE, SHORT_TRADE, BACKDRAFT_TRADE, BREAKOUT_TRADE, BREAKDOWN_TRADE);
$holdings = array();
foreach ($tradeTypesToUse as $tradeType) {
    $holdings[$tradeType] = ticker_group_info::retrieveHoldingsArray($tradeType);
}
?>


<!DOCTYPE html>
<html>
<head>
<title>BioBounce.com</title>

<meta name = "keywords" content = "biotech, stock, market, swing trading, stock trading" />
<meta name = "description" content = "" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, minimum-scale=1 user-scalable=no">
Пример #5
0
function endOfDayEmail()
{
    $email = new email(email::ADDRESSES_ALL_ACTIVE);
    $allText = array(BREAKOUT_TRADE => '', LONG_TRADE => '', PULLBACK_TRADE => '', SHORT_TRADE => '', BACKDRAFT_TRADE => '', BREAKDOWN_TRADE => '');
    $transHistory = new transactions();
    while ($transHistory->loadNext(' DATE(`transaction_date`) = DATE(NOW()) ')) {
        $hId = $transHistory->get_variable('transaction_holdings_id');
        $holdings = new holdings();
        $holdings->set_variable("holdings_id", $hId);
        if (!$holdings->load()) {
            continue;
        }
        $tId = $holdings->get_variable("holdings_ticker_id");
        $ticker = new ticker();
        $ticker->set_variable('ticker_id', $tId);
        if ($ticker->load()) {
            $symbol = $ticker->get_variable('ticker_symbol');
            //echo "Adding to EOD EMAIL " . $symbol . "\n\n";
            $tranDate = $transHistory->get_variable('transaction_date');
            $tz = new DateTimeZone('America/New_York');
            $date = new DateTime($tranDate);
            $date->setTimeZone($tz);
            $dateStr = $date->format("h:i A");
            $tradeType = $transHistory->get_variable('transaction_tradetype');
            $action = intval($transHistory->get_variable('transaction_action'));
            $actionPrice = floatval($transHistory->get_variable('transaction_price'));
            $actionInfo = email::GetEmailText($tradeType, $action, $symbol, $actionPrice, "", false);
            if (strlen($actionInfo["body"]) > 0) {
                $allText[$tradeType] .= "<div style=\"\" >" . $dateStr . " - " . $actionInfo["body"] . "</div>";
            }
        }
    }
    $bodyText = '';
    foreach ($allText as $key => $value) {
        if (strlen($value) > 0) {
            $bodyText .= "<div style=\"font-size:13pt;font-family:Helvetica;text-decoration:underline;text-align:center;padding-bottom:7px;padding-top:20px;font-weight:bold\">" . GetTradeTypeConstantName($key) . "</div>" . $value;
        }
    }
    if (strlen($bodyText) == 0) {
        echo "NO TRANSACTIONS TODAY " . $transHistory->debug();
        $email->endOfDay("There were no BioBounce events today.");
    } else {
        echo "SENDING EOD EMAIL\n\n";
        $email->endOfDay($bodyText);
    }
}
require_once 'php/db_interface/autoload.php';
$login = new login(true);
if (isset($_GET['tt'])) {
    $tradeType = intval($_GET['tt']);
} else {
    $tradeType = BREAKOUT_TRADE;
}
$counter = 1;
while (true) {
    if (!isset($_POST[$counter])) {
        break;
    }
    $holdId = $_POST[$counter];
    $holding = new holdings();
    $holding->set_variable('holdings_id', $holdId);
    if ($holding->load()) {
        $oldAbandon = floatval($holding->get_variable('holdings_stop_price'));
        $oldHard = floatval($holding->get_variable('holdings_top_price'));
        $isEdited = false;
        if (isset($_POST['abandon_' . $holdId])) {
            $abandon = floatval($_POST['abandon_' . $holdId]);
            if ($abandon != $oldAbandon) {
                $holding->set_variable('holdings_stop_price', $abandon);
                highlights::holdingsHighlight($holdId, H_ABANDON, 0, highlights::EVENT_START_DAY);
                $isEdited = true;
            }
        }
        if (isset($_POST['hardstop_' . $holdId])) {
            $hardstop = floatval($_POST['hardstop_' . $holdId]);
            if ($hardstop != $oldHard) {
                $holding->set_variable('holdings_top_price', $hardstop);
Пример #7
0
 public static function abandonPriceMet($holding_id, $abandonPrice)
 {
     if ($holding_id == 0 || $abandonPrice == 0) {
         echo " ERROR: HID = " . $holding_id . " AbandonPrice = " . $abandonPrice;
         return;
     }
     $holding = new holdings();
     $holding->set_variable('holdings_id', $holding_id);
     if ($holding->load()) {
         $symbol = $holding->get_variable('holdings_ticker_symbol');
         if (strlen($symbol) <= 0) {
             $tId = $holding->get_variable('holdings_ticker_id');
             $ticker = new ticker();
             $ticker->set_variable("ticker_id", $tId);
             if ($ticker->load()) {
                 $symbol = $ticker->get_variable("ticker_symbol");
                 $last = $ticker->get_variable('last');
             }
         }
         $tradeType = $holding->get_variable("holdings_tradetype");
         $action = $holding->get_variable("holdings_last_action");
         if ($action == WARNING || IsAbandoned($action)) {
             return;
         }
         $holding->set_variable('holdings_last_action', WARNING);
         $holding->update();
         holdings::updateHoldingEvent($holding_id, $tradeType, WARNING, $abandonPrice, $action, $symbol);
     }
 }