Fix: do not gracefully fail when symbol not found
This commit is contained in:
@@ -14,6 +14,7 @@ use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
class AlpacaMarketData implements MarketDataInterface
|
||||
{
|
||||
@@ -51,9 +52,7 @@ class AlpacaMarketData implements MarketDataInterface
|
||||
|
||||
$quote = $response->json('trade');
|
||||
|
||||
if (is_null(Arr::get($quote, 'p'))) {
|
||||
throw new \Exception('Could not find ticker on Alpaca');
|
||||
}
|
||||
throw_if(empty(Arr::get($quote, 'p')), NotFoundHttpException::class, "Symbol `{$symbol}` was not found");
|
||||
|
||||
$fundamental = cache()->remember(
|
||||
'ap-symbol-'.$symbol,
|
||||
@@ -159,6 +158,8 @@ class AlpacaMarketData implements MarketDataInterface
|
||||
|
||||
$history = $response->json('bars');
|
||||
|
||||
throw_if(empty($history), NotFoundHttpException::class, "Symbol `{$symbol}` was not found");
|
||||
|
||||
$chunkedHistory = collect($history)
|
||||
->mapWithKeys(function ($history) use ($symbol) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user