From 0434bc696117e70ea9027a927f59f2dc5df70234 Mon Sep 17 00:00:00 2001 From: hackerESQ Date: Fri, 25 Oct 2024 15:41:07 -0500 Subject: [PATCH] feat:configurable time of day to capture daily changes --- app/Models/Portfolio.php | 2 +- config/investbrain.php | 4 +++- routes/console.php | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/Models/Portfolio.php b/app/Models/Portfolio.php index 6b41029..6c2285e 100644 --- a/app/Models/Portfolio.php +++ b/app/Models/Portfolio.php @@ -138,7 +138,7 @@ class Portfolio extends Model $holdings->each(function($holding) use (&$total_performance, $dividends) { - $period = CarbonPeriod::create($holding->first_transaction_date, now())->filter('isWeekday'); + $period = CarbonPeriod::create($holding->first_transaction_date, now()->isBefore(Carbon::parse(config('daily_change_time_of_day'))) ? now()->subDay() : now())->filter('isWeekday'); $holding->setRelation('dividends', $dividends->where('symbol', $holding->symbol)); diff --git a/config/investbrain.php b/config/investbrain.php index 022d222..cb4ad56 100644 --- a/config/investbrain.php +++ b/config/investbrain.php @@ -13,5 +13,7 @@ return [ 'fake' => App\Interfaces\MarketData\FakeMarketData::class, ], - 'self_hosted' => env('SELF_HOSTED', true) + 'self_hosted' => env('SELF_HOSTED', true), + + 'daily_change_time_of_day' => env('DAILY_CHANGE_TIME', '23:00') ]; \ No newline at end of file diff --git a/routes/console.php b/routes/console.php index d417ab6..e0e489f 100644 --- a/routes/console.php +++ b/routes/console.php @@ -14,7 +14,7 @@ Schedule::command(RefreshMarketData::class)->everyMinute()->weekdays(); * * This scheduled job records daily changes to your portfolios every weekday */ -Schedule::command(CaptureDailyChange::class)->dailyAt('23:00')->weekdays(); +Schedule::command(CaptureDailyChange::class)->dailyAt(config('daily_change_time_of_day'))->weekdays(); /** *