[ "US" => -12, //美国 "CA" => -12, //加拿大 "UK" => -7, //英国 "DE" => -6, //德国 "FR" => -6, //法国 "IT" => -6, //意大利 "PT" => -7, //葡萄牙 "ES" => -6, //西班牙 "CH" => -6, //瑞士 "AU" => 2, //澳大利亚 "NZ" => 5, //新西兰 "CN" => 0, //北京时间 "JP" => 1, //东京时间 ], **/ 'RankUpdatedEvery' => 600, //分钟计算 'MarketLocationMap' =>[ 'sh' => 'china', 'sz' => 'china', 'ny' => 'us', 'nas' => 'us', 'us' => 'us', 'hk' => 'hk', ], 'GlobalTimezone' => [ "US" => 'America/New_York', //美国 "CA" => 'America/Toronto', //加拿大 "UK" => 'Europe/London', //英国 "DE" => 'Europe/Berlin', //德国 "FR" => 'Europe/Paris', //法国 "IT" => 'Europe/Rome', //意大利 "PT" => 'Europe/Lisbon', //葡萄牙 "ES" => 'Europe/Madrid', //西班牙 "CH" => 'Europe/Zurich', //瑞士 "AU" => 'Australia/Sydney', //澳大利亚 "NZ" => 'Pacific/Auckland', //新西兰 "CN" => 'Asia/Shanghai', //北京时间 "JP" => 'Asia/Tokyo', //东京时间 ], 'MarketTimezone' => [ 'sh' => 'CN', 'sz' => 'CN', 'ny' => 'US', 'nas' => 'US', 'us' => 'US', 'hk' => 'CN', ], 'MarketOpenTime' => [ 'sh' => '9:30-11:30,13:00-15:00', 'sz' => '9:30-11:30,13:00-15:00', 'ny' => '9:30-16:30', 'nas' => '9:30-16:30', 'us' => '9:30-16:30', 'hk' => '10:00-12:30,14:30-16:00', ], 'fullcode_prefix' => [ 'sh' => 'sh', 'sz' => 'sz', 'ny' => 'gb_', 'nas' => 'gb_', 'us' => 'gb_', 'hk' => 'hk', ], 'market_platform' => [ 'sina' => ['sh', 'sz', 'ny', 'nas', 'us', 'hk'], ], 'market_platform_price_query' =>[ 'sina' => 'http://hq.sinajs.cn/list=', ], 'unit_in_word' => [ 'sh' => '手', 'sz' => '手', ], 'volume_unit' => [ 'sh' => 100, 'sz' => 100, ], 'show_share_chart' => [ 'sh', 'sz', 'hk', 'us', 'nas', 'ny' ], 'share_chart_platform' =>[ 'sina' => ['sh', 'sz', 'hk', 'us', 'nas', 'ny'], ], 'has_bar_chart' => [ 'sh', 'sz', 'hk' ], 'share_chart_url_head' => [ 'sh' => 'http://image.sinajs.cn/newchart/', 'sz' => 'http://image.sinajs.cn/newchart/', 'hk' => 'http://image.sinajs.cn/newchart/hk_stock/', 'us' => 'http://image.sinajs.cn/newchart/usstock/', 'nas' => 'http://image.sinajs.cn/newchart/usstock/', 'ny' => 'http://image.sinajs.cn/newchart/usstock/', ], //T+D延迟:单位小时 'trading_with_delay' => [ 'sh' => 24, 'sz' => 24, ], ]; $mval){ $timezone = $timezones[$mval]; $new_date_time = $this->make_date_time_now($timezone, 'Y-m-d H:i:s'); //dd($new_date_time); /* $date_time = new DateTime('NOW'); $date_time->setTimezone(new DateTimeZone($timezone)); $new_date_time = new DateTime($date_time->format('Y-m-d H:i:s')); */ $ret[$mid] = $new_date_time->getTimestamp(); } //dd($ret); return $ret; } public function make_date_time_now($timezone, $format){ $date_time = new DateTime('NOW'); $date_time->setTimezone(new DateTimeZone($timezone)); $new_date_time = new DateTime($date_time->format($format)); return $new_date_time; } public function opened_markets($open_times, $local_times){ $ret = array(); foreach($open_times as $mid => $mdata){ $times = array(); $now = date('Hi', $local_times[$mid]); $nowweekday = date('D', $local_times[$mid]); if($nowweekday != 'Sat' && $nowweekday != 'Sun'){ $temp = explode(',', $mdata); foreach($temp as $t){ $temp2 = explode('-', $t); $temp3 = explode(':', $temp2[0]); $times[] = $temp3[0] . $temp3[1]; $temp3 = explode(':', $temp2[1]); $times[] = $temp3[0] . $temp3[1]; } if(count($times) == 2 && $now >= $times[0] && $now <= $times[1]) $ret[] = $mid; elseif(count($times) == 4 && ( ($now >= $times[0] && $now <= $times[1]) || ($now >= $times[2] && $now <= $times[3]) )) $ret[] = $mid; } } return $ret; } public function countdown($market, $open_markets, $open_times){ $ret = 0; if(in_array($market, $open_markets)) return $ret; else{ //dd('i am here'); $timezones = config('share.GlobalTimezone'); $market_time_zones = config('share.MarketTimezone'); $timezone = $timezones[$market_time_zones[$market]]; $now_date = $this->make_date_time_now($timezone, 'Y-m-d H:i:s'); $times = array(); $open_str = $open_times[$market]; $now = date('Hi', $now_date->getTimestamp()); $nowweekday = date('D', $now_date->getTimestamp()); if($nowweekday != 'Sat' && $nowweekday != 'Sun'){ $temp = explode(',', $open_str); $times_comp = array(); foreach($temp as $t){ $temp2 = explode('-', $t); $times_comp[] = $temp2[0]; $times_comp[] = $temp2[1]; $temp3 = explode(':', $temp2[0]); $times[] = $temp3[0] . $temp3[1]; $temp4 = explode(':', $temp2[1]); $times[] = $temp4[0] . $temp4[1]; } if(count($times) == 2){ if($now < $times[0]) { $open = date('Y-m-d', $now_date->getTimestamp()) . ' ' . $times_comp[0]; $open_date = new DateTime($open); } elseif($now > $times[1]){ $open = date('Y-m-d', $now_date->getTimestamp()) . ' ' . $times_comp[0]; $open_date = new DateTime($open); $open_date->modify('+1 day'); } //$diff = $now_date->diff($open_date) ; //$ret = $diff->s; $ret = $open_date->getTimestamp() - $now_date->getTimestamp(); } elseif (count($times) == 4){ //dd($times); if($now < $times[0]){ $open = date('Y-m-d', $now_date->getTimestamp()) . ' ' . $times_comp[0]; $open_date = new DateTime($open); //dd($open); //dd($open_date->format('Y-m-d H:i:s')); } elseif ($now > $times[1] && $now < $times[2]){ $open = date('Y-m-d') . ' ' . $times_comp[2]; $open_date = new DateTime($open); } elseif ($now > $times[3]){ $open = date('Y-m-d', $now_date->getTimestamp()) . ' ' . $times_comp[0]; $open_date = new DateTime($open); $open_date->modify('+1 day'); //dd($open_date->format('Y-m-d H:i:s')); } //$diff = $now_date->diff($open_date); $ret = $open_date->getTimestamp() - $now_date->getTimestamp(); //dd($ret); } } } return $ret; } protected function ntp_time($host) { // Create a socket and connect to NTP server $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); socket_connect($sock, $host, 123); // Send request $msg = "\010" . str_repeat("\0", 47); socket_send($sock, $msg, strlen($msg), 0); // Receive response and close socket socket_recv($sock, $recv, 48, MSG_WAITALL); socket_close($sock); // Interpret response $data = unpack('N12', $recv); $timestamp = sprintf('%u', $data[9]); // NTP is number of seconds since 0000 UT on 1 January 1900 // Unix time is seconds since 0000 UT on 1 January 1970 $timestamp -= 2208988800; return $timestamp; } }

Whoops, looks like something went wrong.

(1/1) UnexpectedValueException

The stream or file "/var/www/html/StockMarketSimulator/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied

in StreamHandler.php (line 107)
at StreamHandler->write(array('message' => 'Symfony\\Component\\Debug\\Exception\\FatalErrorException: Trait \'App\\Tools\\MarketTimeZone\' not found in /var/www/html/StockMarketSimulator/app/Http/Controllers/PagesController.php:16Stack trace:#0 {main}', 'context' => array(), 'level' => 400, 'level_name' => 'ERROR', 'channel' => 'local', 'datetime' => object(DateTime), 'extra' => array(), 'formatted' => '[2024-09-30 21:25:36] local.ERROR: Symfony\\Component\\Debug\\Exception\\FatalErrorException: Trait \'App\\Tools\\MarketTimeZone\' not found in /var/www/html/StockMarketSimulator/app/Http/Controllers/PagesController.php:16Stack trace:#0 {main} '))in AbstractProcessingHandler.php (line 37)
at AbstractProcessingHandler->handle(array('message' => 'Symfony\\Component\\Debug\\Exception\\FatalErrorException: Trait \'App\\Tools\\MarketTimeZone\' not found in /var/www/html/StockMarketSimulator/app/Http/Controllers/PagesController.php:16Stack trace:#0 {main}', 'context' => array(), 'level' => 400, 'level_name' => 'ERROR', 'channel' => 'local', 'datetime' => object(DateTime), 'extra' => array(), 'formatted' => '[2024-09-30 21:25:36] local.ERROR: Symfony\\Component\\Debug\\Exception\\FatalErrorException: Trait \'App\\Tools\\MarketTimeZone\' not found in /var/www/html/StockMarketSimulator/app/Http/Controllers/PagesController.php:16Stack trace:#0 {main} '))in Logger.php (line 337)
at Logger->addRecord(400, object(FatalErrorException), array())in Logger.php (line 616)
at Logger->error(object(FatalErrorException), array())in Writer.php (line 203)
at Writer->writeLog('error', object(FatalErrorException), array())in Writer.php (line 114)
at Writer->error(object(FatalErrorException))in Handler.php (line 71)
at Handler->report(object(FatalErrorException))in Handler.php (line 35)
at Handler->report(object(FatalErrorException))in HandleExceptions.php (line 81)
at HandleExceptions->handleException(object(FatalErrorException))in HandleExceptions.php (line 123)
at HandleExceptions->handleShutdown()