This commit is contained in:
hackerESQ
2024-08-24 22:19:40 -05:00
parent 5e89e66e7b
commit 54cf25aabc
13 changed files with 423 additions and 179 deletions
+10 -5
View File
@@ -25,6 +25,9 @@ class MarketData extends Model
'market_value',
'fifty_two_week_high',
'fifty_two_week_low',
'forward_pe',
'trailing_pe',
'market_cap'
];
public static function setSplitsHoldingSynced($symbol)
@@ -49,15 +52,17 @@ class MarketData extends Model
]);
// check if new or stale
if (!$market_data->exists || now()->diffInMinutes($market_data->updated_at) >= config('market_data.refresh')) {
if (
!$market_data->exists
|| is_null($market_data->updated_at)
|| $market_data->updated_at->diffInMinutes(now()) >= config('market_data.refresh')
) {
// get quote
// $quote = app(MarketDataInterface::class)->quote($symbol);
$quote = app(MarketDataInterface::class)->quote($symbol);
// fill data
// $market_data->fill($quote->toArray());
$market_data->fill($quote->toArray());
}
// save with timestamps updated