Exemplo n.º 1
0
 public static function ListUpdatedSendMessages()
 {
     $tweetprivate = new tweet();
     $tweetprivate->sendWatchlistUpdate();
     $updateEmail = new email(email::ADDRESSES_ALL_CHOSEN);
     $updateEmail->sendWatchlistUpdate();
 }
Exemplo n.º 2
0
 public function GetTweets()
 {
     $tweet = new tweet();
     $sql = "\n\t\t\tSELECT tid, nextupdate, date, text\n\t\t\tFROM tweets";
     $stmt = DBConnection::getInstance()->Prepare($sql);
     if ($stmt = DBConnection::getInstance()->Prepare($sql)) {
         $stmt->execute();
         $result = $stmt->fetchAll(PDO::FETCH_OBJ);
     }
     if (is_array($result)) {
         foreach ($result as $object) {
             $m_tweets[] = $tweet->createTweet($object->tid, $object->nextupdate, $object->date, $object->text);
         }
     }
     if ($this->CheckTweets($m_tweets) == true) {
         $this->DeleteTweets();
         $m_tweets = array();
         $consumerkey = 'kSPAW6aM6hBQ1oRrsmCt2g';
         $consumersecret = 'LHA7iAYkM28RWsPgLFmc1IwWMIAzFfEL6oDYffeQow';
         $accesstoken = '70422491-qiEw18c5BezqXrRyjBNA4YwqfefGUOCJ4KjuRDvBJ';
         $accesstokensecret = 'uVyp33clcI6dDCYLAf7dYkbnlVtAGL6KMyXMUpexRK0';
         $twitter = new TwitterOAuth($consumerkey, $consumersecret, $accesstoken, $accesstokensecret);
         $tweets = $twitter->get('https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=joakimkendelt&exclude_replies=true&count=8');
         $numberoftweets = count($tweets);
         for ($i = 0; $i < $numberoftweets; $i++) {
             $timeInterval = time() + 5 * 60;
             //5 mins; 60secs
             $nextUpdate = date('Y-m-d H:i:s', $timeInterval);
             $datetime = $tweets[$i]->created_at;
             $date = date('Y-m-d', strtotime($datetime));
             $time = date('H:i:s', strtotime($datetime));
             $dateoftweet = $date . " " . $time;
             $text = $tweets[$i]->text;
             $this->SaveTweets($nextUpdate, $dateoftweet, $text);
             $m_tweets[] = $tweet->createTweet(null, $nextUpdate, $date, $text);
         }
         return $m_tweets;
     } else {
         return $m_tweets;
     }
     if ($this->CheckTweets($m_tweets) == true) {
         return $m_tweets;
     } else {
         return $m_tweets;
     }
 }
Exemplo n.º 3
0
 public function action_injest()
 {
     try {
         $tweets = Request::factory(sprintf(Controller_Cron::$twitter_endpoint, tweet::last_id()))->execute();
         $i = 0;
         if ($tweets->status === 200) {
             $tweets = json_decode($tweets->body);
             foreach ($tweets->results as $tweet) {
                 tweet::create($tweet);
                 $i++;
             }
         }
         echo 'Completed successfully, inserted ' . $i, ' records';
     } catch (Kohana_Request_Exception $e) {
         // Die gracefully
         'Yo, twitter is so not working!';
     } catch (Exception $e) {
         throw $e;
     }
 }
Exemplo n.º 4
0
 public function action_index()
 {
     $db = mongoconnection::instance();
     $this->request->response->body = (string) View::factory('front/index')->set('tweets', tweet::latest(5));
 }
Exemplo n.º 5
0
    <?php 
echo "Statut : ";
echo $context->data['user']['statut'];
?>
 </br>
  </div>
  <div class="col s12 m4 l6 push-l1"> <ul class="collection with-header z-depth-3">
    <ul>
      <li class="collection-header "><h4>Tweets de <?php 
echo $context->data['user']['prenom'];
?>
 </h4></li>
      <?php 
$datatweet = $context->data['tweet'];
foreach ($datatweet as $key => $tweet) {
    $tweetpost = tweet::getPost($tweet->post);
    $infopost = new post($tweetpost[0]->data);
    ?>
        <li class='collection-item avatar z-depth-2'>
        <img src="././images/<?php 
    echo $context->data['user']['avatar'];
    ?>
" alt='' class='circle'>
        <span class='title'> <?php 
    echo "L'utilisateur n°" . $tweet->emetteur . " a tweeté à " . $infopost->date . ":";
    ?>
</span>
        <p><?php 
    echo $infopost->texte;
    ?>
<br>
Exemplo n.º 6
0
 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);
         }
     }
 }
Exemplo n.º 7
0
 public static function testTweet($request, $context)
 {
     $data = array("emetteur" => $request["emetteur"], "parent" => $request["parent"], "post" => $request["post"], "nbVotes" => $request["nbVotes"]);
     $tweet = new tweet($data);
     $tweet->id = $tweet->save();
     if (is_null($tweet->id)) {
         return NULL;
     } else {
         return $tweet;
     }
 }
Exemplo n.º 8
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;
 }
Exemplo n.º 9
0
 public static function vote($request, $context)
 {
     //print_r($request);
     if (!empty($request['idtweet']) && $context->getSessionAttribute('is_logged') == 1) {
         $voteInfo['message'] = $request['idtweet'];
         $voteInfo['utilisateur'] = $_SESSION['id'];
         $vote = new vote($voteInfo);
         $vote->save();
         $tweetInfo['id'] = $request['idtweet'];
         $nbVotes = vote::getVote($request['idtweet']);
         //print_r($nbVotes);
         $tweetInfo['nbVotes'] = $nbVotes[0]['count'];
         $tweet = new tweet($tweetInfo);
         $tweet->save();
         context::redirect(history . back());
         return context::SUCCESS;
     }
     return context::ERROR;
 }
Exemplo n.º 10
0
<?php

include "twitter.php";
$mytweet = new tweet("screen_name_here");
echo $mytweet->ReturnTweet();
Exemplo n.º 11
0
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();
    	}
    * 
    */
}
Exemplo n.º 12
0
 public static function updateHoldingEvent($hId, $tradeType, $action, $actionPrice, $previousAction, $symbol)
 {
     $today = date('Y-m-d H:i:s');
     holdings::CreateNewTransaction($hId, $tradeType, $abandonPrice, $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);
 }
Exemplo n.º 13
0
 public function afterAdminLogin($verify)
 {
     $db = new dbHandler();
     $db->allUsers();
     echo "Enter the User name to see all tweets\n";
     $twt = new tweet();
     $handle = fopen("php://stdin", "r");
     $user = fgets($handle);
     $twt->gettweetsAdmin(trim($user));
 }