clean up scheduled commands
also add comments to each command
This commit is contained in:
@@ -53,7 +53,7 @@ class CaptureDailyChange extends Command
|
||||
return $holding->market_data->market_value * $holding->quantity;
|
||||
});
|
||||
|
||||
$portfolio->daily_changes()->create([
|
||||
$portfolio->daily_change()->create([
|
||||
'date' => now(),
|
||||
'total_market_value' => $total_market_value,
|
||||
'total_cost_basis' => $total_cost_basis,
|
||||
|
||||
@@ -39,8 +39,7 @@ class RefreshDividendData extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
// $holdings = Holding::where('quantity', '>', 0)->distinct()->get(['symbol']);
|
||||
$holdings = Holding::distinct()->get(['symbol']);
|
||||
$holdings = Holding::where('quantity', '>', 0)->distinct()->get(['symbol']);
|
||||
|
||||
foreach ($holdings as $holding) {
|
||||
$this->line('Refreshing ' . $holding->symbol);
|
||||
|
||||
@@ -41,16 +41,15 @@ class RefreshMarketData extends Command
|
||||
public function handle()
|
||||
{
|
||||
// get all symbols from market data
|
||||
$symbols = Holding::where('quantity', '>', 0)
|
||||
$holdings = Holding::where('quantity', '>', 0)
|
||||
->select(['symbol'])
|
||||
->distinct()
|
||||
->get()
|
||||
->pluck('symbol');
|
||||
->get();
|
||||
|
||||
foreach ($symbols as $symbol) {
|
||||
$this->line('Refreshing ' . $symbol);
|
||||
foreach ($holdings as $holding) {
|
||||
$this->line('Refreshing ' . $holding->symbol);
|
||||
|
||||
MarketData::getMarketData($symbol);
|
||||
MarketData::getMarketData($holding->symbol);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ class RefreshSplitData extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$holdings = Holding::distinct()->get(['symbol']);
|
||||
$holdings = Holding::where('quantity', '>', 0)->distinct()->get(['symbol']);
|
||||
|
||||
foreach ($holdings as $holding) {
|
||||
$this->line('Refreshing ' . $holding->symbol);
|
||||
|
||||
@@ -12,14 +12,14 @@ class SyncHoldingData extends Command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'holding-data:refresh';
|
||||
protected $signature = 'holding-data:sync';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Refresh holdings';
|
||||
protected $description = 'Syncs holdings with transactions and dividends';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
|
||||
Reference in New Issue
Block a user