Files
investbrain/app/Console/Commands/RefreshMarketData.php
T

51 lines
1.0 KiB
PHP
Raw Normal View History

2024-08-29 23:36:44 -05:00
<?php
namespace App\Console\Commands;
2024-08-30 21:58:38 -05:00
use App\Models\MarketData;
2024-08-29 23:36:44 -05:00
use Illuminate\Console\Command;
2024-08-30 21:58:38 -05:00
class RefreshMarketData extends Command
2024-08-29 23:36:44 -05:00
{
/**
* The name and signature of the console command.
*
* @var string
*/
2024-08-30 21:58:38 -05:00
protected $signature = 'market-data:refresh
{--force= : Ignore refresh delay}';
2024-08-29 23:36:44 -05:00
/**
* The console command description.
*
* @var string
*/
2024-08-30 21:58:38 -05:00
protected $description = 'Refresh market data from market data provider';
2024-08-29 23:36:44 -05:00
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
2024-08-30 21:58:38 -05:00
// get all symbols from market data
$symbols = MarketData::get(['symbol']);
2024-08-29 23:36:44 -05:00
2024-08-30 21:58:38 -05:00
foreach ($symbols as $symbol) {
$this->line('Refreshing ' . $symbol->symbol);
$symbol->refreshMarketData();
2024-08-29 23:36:44 -05:00
}
}
}