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
+8 -4
View File
@@ -2,6 +2,7 @@
namespace App\Interfaces\MarketData;
use Illuminate\Support\Carbon;
use Illuminate\Support\Collection;
class FakeMarketData implements MarketDataInterface
@@ -66,13 +67,16 @@ class FakeMarketData implements MarketDataInterface
public function history($symbol, $startDate, $endDate): Collection
{
$numDays = Carbon::parse($startDate)->diffInDays($endDate, true);
for ($i = 0; $i < 14; $i++) {
for ($i = 0; $i < $numDays; $i++) {
$series[] = [
$date = now()->subDays($i)->format('Y-m-d');
$series[$date] = [
'symbol' => $symbol,
'date' => now()->subDays($i)->format('Y-m-d'),
'close' => (float) rand(1, 100),
'date' => $date,
'close' => (float) rand(150, 400),
];
}