function getMarketStatus() { if (getCurrentTimeIntVal() >= 100000 && getCurrentTimeIntVal() <= 160000) { if (isTradingDay()) { if (date("Y-m-d") == "2016-12-23" || date("Y-m-d") == "2016-12-30" || date("Y-m-d") == "2015-12-31") { if (getCurrentTimeIntVal() <= 141000) { return "Market Open"; } else { return "Market Closed"; } } else { return "Market Open"; } } } return "Market Closed"; }
/** * Define the application's command schedule. * * @param \Illuminate\Console\Scheduling\Schedule $schedule * @return void */ protected function schedule(Schedule $schedule) { if (isTradingDay()) { $schedule->command('stocks:calculateStockChange')->weekdays()->dailyAt('03:35'); $schedule->command('stocks:resetDayChange')->dailyAt('04:00'); //Full sector metric update once before and once after each trading day $schedule->command('stocks:updateSectorMetrics', ['--mode' => 'full'])->weekdays()->dailyAt('10:28'); $schedule->command('stocks:updateSectorMetrics', ['--mode' => 'full'])->weekdays()->dailyAt('16:25'); $schedule->command('stocks:getDailyFinancials')->weekdays()->dailyAt('16:30'); } //Only run these between 10:30 and 17:00 Sydney Time if (getCurrentTimeIntVal() >= 103000 && getCurrentTimeIntVal() <= 170000 && isTradingDay()) { $schedule->command('stocks:updateStockMetrics')->cron("*/2 * * * *"); $schedule->command('stocks:updateSectorMetrics', ['--mode' => 'partial'])->cron("*/2 * * * *"); } $schedule->command('stocks:updateStockList')->dailyAt('02:00'); $schedule->command('stocks:getCompanySummaries')->dailyAt('02:01'); }
public static function getGraphData($stockCode, $timeFrame = 'last_month', $dataType) { $historicals = Historicals::where(['stock_code' => $stockCode])->dateCondition($timeFrame)->orderBy('date')->get(); $graphData = array(); foreach ($historicals as $record) { if ($dataType == 'Price') { $price = $record->close; $fiftyDayMovingAverage = $record->fifty_day_moving_average; $twoHundredDayMovingAverage = $record->two_hundred_day_moving_average; } array_push($graphData, array(getCarbonDateFromDate($record->date)->toFormattedDateString(), $price, $fiftyDayMovingAverage, $twoHundredDayMovingAverage)); } //Add Current day's trade value to graph data //10:32am allows time for the metrics to be populated if (isTradingDay() && getCurrentTimeIntVal() >= 103200 && !Historicals::where(['stock_code' => $stockCode, 'date' => date('Y-m-d')])->first()) { $stockMetric = StockMetrics::where('stock_code', $stockCode)->first(); $metricDate = explode(" ", $stockMetric->updated_at)[0]; array_push($graphData, array(getCarbonDateFromDate($metricDate)->toFormattedDateString(), $stockMetric->last_trade)); } return $graphData; }