key history by date

This commit is contained in:
hackerESQ
2024-09-11 21:58:34 -05:00
parent 2448fe5c76
commit 0f9c72f7cb
3 changed files with 24 additions and 16 deletions
@@ -77,13 +77,15 @@ class YahooMarketData implements MarketDataInterface
{
return collect($this->client->getHistoricalQuoteData($symbol, ApiClient::INTERVAL_1_DAY, $startDate, $endDate))
->map(function($history) use ($symbol) {
->mapWithKeys(function($history) use ($symbol) {
return [
'symbol' => $symbol,
'date' => $history->getDate()->format('Y-m-d'),
'close' => (float) $history->getClose(),
];
$date = $history->getDate()->format('Y-m-d');
return [ $date => [
'symbol' => $symbol,
'date' => $date,
'close' => (float) $history->getClose(),
]];
});
}
}