示例#1
0
 public static function main()
 {
     //odczytanie __CLASS__ nie moze byc w funkcji w klasie nadrzędnej
     if (basename($_SERVER["SCRIPT_NAME"]) == __CLASS__ . ".php") {
         transactions::display(__CLASS__);
     }
 }
示例#2
0
<a href="products.php">products.php</a><br>
<a href="customers.php">customers.php</a><br>
<a href="transactions.php">transactions.php</a><br>
<a href="login.php">login.php</a><br>

<?php 
/* http://pl.php.net/manual/en/function.mysqli-connect.php
http://www.devshed.com/c/a/MySQL/Implementing-Additional-Methods-with-mysqli-and-PHP-5/1/
(013147149X_book.pdf) Andi Gutmans, Stig S??her Bakken
and Derick Rethans - PHP 5 Power Programming -> 6.2.6 Queries
*/
require_once 'functions.php';
products::display();
customers::display();
transactions::display();
login::display();
database::getConn()->close();
示例#3
0
 public function ZoneSymbol($list, $symbol, $target)
 {
     $ticker = new ticker();
     $ticker->set_variable('ticker_symbol', $symbol);
     if ($ticker->loadNext()) {
         $tId = $ticker->get_variable('ticker_id');
         $last = floatval($ticker->get_variable('last'));
         $holdings = new holdings();
         $holdings->set_variable('holdings_ticker_id', $tId);
         if ($holdings->loadNext()) {
             $t1 = floatval($holdings->get_variable('holdings_t1'));
             $t2 = floatval($holdings->get_variable('holdings_t2'));
             $t3 = floatval($holdings->get_variable('holdings_t3'));
             $origPrice = $holdings->get_variable('holdings_orig_price');
             $hId = $holdings->get_variable('holdings_id');
             $tradeType = $holdings->get_variable('holdings_tradetype');
             $newHolding = new holdings();
             if ($list == "L") {
                 $action = "";
                 if ($target == "T1") {
                     $action = SELL1;
                     $newHolding->set_variable('holdings_t1_marked', 1);
                     $newHolding->set_variable('holdings_stop_price', $origPrice);
                     watchlist::removeTickerHitT1($tId);
                     holdings::updateTickerSellPrices($tId, $origPrice);
                     highlights::holdingsHighlight($hId, H_T1, 0, highlights::EVENT_START_DAY);
                 } else {
                     if ($target == "T2") {
                         $action = SELL2;
                         $newHolding->set_variable('holdings_t2_marked', 1);
                         holdings::updateTickerSellPrices($tId, $t1);
                         highlights::holdingsHighlight($hId, H_T2, 0, highlights::EVENT_START_DAY);
                     } else {
                         if ($target == "T3") {
                             $action = SELL3;
                             $newHolding->set_variable('holdings_t3_marked', 1);
                             holdings::updateTickerSellPrices($tId, $t2);
                             highlights::holdingsHighlight($hId, H_T3, 0, highlights::EVENT_START_DAY);
                         }
                     }
                 }
                 if ($action != "") {
                     $newHolding->set_variable('holdings_id', $hId);
                     $newHolding->set_variable('holdings_last_action', $action);
                     $newHolding->update();
                     // Add a transaction to the transaction table
                     $transactions = new transactions();
                     $transactions->set_variable('transaction_holdings_id', $hId);
                     $transactions->set_variable('transaction_price', $last);
                     $transactions->set_variable('transaction_date', date('Y-m-d H:i:s'));
                     $transactions->set_variable('transaction_action', $action);
                     $transactions->set_variable('transaction_tradetype', $tradeType);
                     $transactions->createNew();
                 }
             }
         }
     }
 }
示例#4
0
 public function markZoned($tradeType = LONG_TRADE, $sendUpdate = true, $logTransaction = true)
 {
     $notesStr = "";
     $zoned = $this->get_variable('watchlist_is_zoned');
     if ($zoned == 0) {
         $tid = $this->get_variable('watchlist_ticker_id');
         $ticker = new ticker();
         $ticker->set_variable('ticker_id', $tid);
         if ($ticker->load()) {
             $tickerSymbol = $ticker->get_variable('ticker_symbol');
             $last = $ticker->get_variable('last');
             $today_low = $ticker->get_variable('today_low');
             $today_high = $ticker->get_variable('today_high');
             $date = date('Y-m-d H:i:s');
             $bottom = $this->get_variable('watchlist_bottom');
             $top = $this->get_variable('watchlist_top');
             $today_low = max($bottom, min($last, $today_low));
             $today_high = min($top, max($last, $today_high));
             if ($today_low == 0 || $today_high == 0) {
                 return "ERROR IN DATA PROVIDED::HIGH=" . $today_high . "::LOW=" . $today_low;
             }
             $holdings = new holdings();
             $holdings->set_variable('holdings_ticker_id', $tid);
             $holdings->set_variable('holdings_orig_date', $date);
             $lowOrEntry = round(floatval($this->get_variable('watchlist_low')), 2);
             $t0 = round(floatval($this->get_variable('watchlist_target0')), 2);
             $t1 = round(floatval($this->get_variable('watchlist_target1')), 2);
             $t2 = round(floatval($this->get_variable('watchlist_target2')), 2);
             $t3 = round(floatval($this->get_variable('watchlist_target3')), 2);
             $holdings->set_variable('holdings_t0', $t0);
             $holdings->set_variable('holdings_t1', $t1);
             $holdings->set_variable('holdings_t2', $t2);
             $holdings->set_variable('holdings_t3', $t3);
             $holdings->set_variable('holdings_tradetype', $tradeType);
             $holdings->set_variable('holdings_stop_type', 'EOD');
             $holdings->set_variable('holdings_last_action', BUY);
             switch ($tradeType) {
                 case SHORT_TRADE:
                 case BACKDRAFT_TRADE:
                     $actionPrice = $bottom;
                     $holdings->set_variable('holdings_orig_price', $bottom);
                     $holdings->set_variable('holdings_stop_price', $top);
                     $holdings->set_variable('holdings_top_price', $bottom);
                     $notesStr .= "\n<br/>\nIN ZONE ticker:" . $tickerSymbol . " \$" . $last . " (ORIG_PRICE = " . $today_high . ")";
                     break;
                 case LONG_TRADE:
                 case PULLBACK_TRADE:
                     $actionPrice = $top;
                     $holdings->set_variable('holdings_orig_price', $top);
                     $holdings->set_variable('holdings_stop_price', $bottom);
                     $holdings->set_variable('holdings_top_price', $top);
                     $notesStr .= "\n<br/>\nIN ZONE ticker:" . $tickerSymbol . " \$" . $last . " (ORIG_PRICE = " . $today_low . ")";
                     break;
                 case REVERSAL_TRADE:
                     $actionPrice = $top;
                     $holdings->set_variable('holdings_orig_price', $top);
                     $holdings->set_variable('holdings_stop_price', $top);
                     $holdings->set_variable('holdings_top_price', $top);
                     $notesStr .= "\n<br/>\nIN ZONE ticker:" . $tickerSymbol . " \$" . $last . " (ORIG_PRICE = " . $today_low . ")";
                     break;
                 case BREAKOUT_TRADE:
                     $actionPrice = $lowOrEntry;
                     $holdings->set_variable('holdings_orig_price', $lowOrEntry);
                     $holdings->set_variable('holdings_stop_price', $top);
                     $holdings->set_variable('holdings_top_price', $top);
                     // Hard Stop Price
                     $notesStr .= "\n<br/>\nIN ZONE ticker:" . $tickerSymbol . " \$" . $last . " (ORIG_PRICE = " . $today_low . ")";
                     break;
                 case BREAKDOWN_TRADE:
                     $actionPrice = $lowOrEntry;
                     $holdings->set_variable('holdings_orig_price', $lowOrEntry);
                     $holdings->set_variable('holdings_stop_price', $top);
                     $holdings->set_variable('holdings_top_price', $top);
                     $notesStr .= "\n<br/>\nIN ZONE ticker:" . $tickerSymbol . " \$" . $last . " (ORIG_PRICE = " . $today_low . ")";
                     break;
             }
             $tweet = new tweet();
             $updateEmail = new email(email::ADDRESSES_ALL_CHOSEN, $tradeType);
             $action = BUY;
             $tweet->newTweet($tradeType, $action, $tickerSymbol, $actionPrice);
             $updateEmail->newEmail($tradeType, $action, $tickerSymbol, $actionPrice);
             $tooltip = $this->get_variable("watchlist_tooltip");
             $holdings->set_variable("holdings_tooltip", $tooltip);
             $holdingsId = $holdings->createNew();
             if ($logTransaction) {
                 // Add a transaction to the transaction table
                 $transactions = new transactions();
                 $transactions->set_variable('transaction_holdings_id', $holdingsId);
                 $transactions->set_variable('transaction_price', $actionPrice);
                 $transactions->set_variable('transaction_date', date('Y-m-d H:i:s'));
                 $transactions->set_variable('transaction_action', BUY);
                 $transactions->set_variable('transaction_tradetype', $tradeType);
                 $transactions->createNew();
             }
             // add to the holdings table with the current information
             $this->set_variable('watchlist_is_zoned', 1);
             $this->update();
         }
     }
     return $notesStr;
 }
示例#5
0
 function checkDiscount()
 {
     include_once "transactions.php";
     $transact = new transactions();
     $phone = $_REQUEST['phone'];
     $transact->checkForDiscount($phone);
     if ($row = $transact->fetchArray()) {
         echo '{"result":1,"transactions":[';
         while ($row) {
             echo json_encode($row);
             if ($row = $transact->fetchArray()) {
                 echo ',';
             }
         }
         echo ']}';
     } else {
         echo '{"result":0,"message":"No transactions found"}';
     }
 }
示例#6
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);
    }
}
示例#7
0
 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();
     }
 }