2024-08-31 23:06:19 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Interfaces\MarketData;
|
|
|
|
|
|
2024-09-11 21:58:34 -05:00
|
|
|
use Illuminate\Support\Carbon;
|
2024-08-31 23:06:19 -05:00
|
|
|
use Illuminate\Support\Collection;
|
|
|
|
|
|
|
|
|
|
class FakeMarketData implements MarketDataInterface
|
|
|
|
|
{
|
|
|
|
|
public function exists(String $symbol): Bool
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-12 21:05:01 -05:00
|
|
|
public function quote(String $symbol): Collection
|
2024-08-31 23:06:19 -05:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
return collect([
|
|
|
|
|
'name' => 'ACME Company Ltd',
|
|
|
|
|
'symbol' => $symbol,
|
|
|
|
|
'market_value' => 230.19,
|
|
|
|
|
'fifty_two_week_high' => 512.90,
|
|
|
|
|
'fifty_two_week_low' => 341.20,
|
|
|
|
|
'forward_pe' => 20.1,
|
|
|
|
|
'trailing_pe' => 30.34,
|
2024-09-01 15:34:55 -05:00
|
|
|
'market_cap' => 9800700600,
|
|
|
|
|
'book_value' => 4.7,
|
|
|
|
|
'last_dividend_date' => now()->subDays(45),
|
|
|
|
|
'dividend_yield' => .033
|
2024-08-31 23:06:19 -05:00
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-12 21:05:01 -05:00
|
|
|
public function dividends(String $symbol, $startDate, $endDate): Collection
|
2024-08-31 23:06:19 -05:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
return collect([
|
|
|
|
|
[
|
|
|
|
|
'symbol' => $symbol,
|
|
|
|
|
'date' => now()->subMonths(3)->format('Y-m-d H:i:s'),
|
|
|
|
|
'dividend_amount' => 2.11,
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'symbol' => $symbol,
|
|
|
|
|
'date' => now()->subMonths(6)->format('Y-m-d H:i:s'),
|
|
|
|
|
'dividend_amount' => 1.89,
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'symbol' => $symbol,
|
|
|
|
|
'date' => now()->subMonths(9)->format('Y-m-d H:i:s'),
|
|
|
|
|
'dividend_amount' => 0.95,
|
|
|
|
|
],
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-12 21:05:01 -05:00
|
|
|
public function splits(String $symbol, $startDate, $endDate): Collection
|
2024-08-31 23:06:19 -05:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
return collect([
|
|
|
|
|
[
|
|
|
|
|
'symbol' => $symbol,
|
|
|
|
|
'date' => now()->subMonths(36)->format('Y-m-d H:i:s'),
|
|
|
|
|
'split_amount' => 10,
|
|
|
|
|
],
|
|
|
|
|
]);
|
|
|
|
|
}
|
2024-09-09 20:50:18 -05:00
|
|
|
|
2024-09-12 21:05:01 -05:00
|
|
|
public function history(String $symbol, $startDate, $endDate): Collection
|
2024-09-09 20:50:18 -05:00
|
|
|
{
|
2024-09-11 21:58:34 -05:00
|
|
|
$numDays = Carbon::parse($startDate)->diffInDays($endDate, true);
|
2024-09-09 20:50:18 -05:00
|
|
|
|
2024-09-11 21:58:34 -05:00
|
|
|
for ($i = 0; $i < $numDays; $i++) {
|
2024-09-09 20:50:18 -05:00
|
|
|
|
2024-09-11 21:58:34 -05:00
|
|
|
$date = now()->subDays($i)->format('Y-m-d');
|
|
|
|
|
|
|
|
|
|
$series[$date] = [
|
2024-09-09 20:50:18 -05:00
|
|
|
'symbol' => $symbol,
|
2024-09-11 21:58:34 -05:00
|
|
|
'date' => $date,
|
|
|
|
|
'close' => (float) rand(150, 400),
|
2024-09-09 20:50:18 -05:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return collect($series);
|
|
|
|
|
}
|
2024-08-31 23:06:19 -05:00
|
|
|
}
|