fix(notifier): align P&L table NAV with daily_pnl basis, add SPY column#94
Merged
Merged
Conversation
Three improvements to the evening P&L history table: 1. NAV consistency: previously stored after-hours portfolio_value (8-10pm ET) while daily_pnl used Alpaca's last_equity (4pm official close) as baseline, causing NAV to move in the opposite direction of daily_pnl on some days. Now reconstructs NAV as initial_last_equity + cumulative daily_pnl so NAV[today] - NAV[yesterday] == daily_pnl[today] always holds, matching the same 4pm-close basis as SPY benchmark data. 2. SPY daily return column: fetches SPY close-to-close return via yfinance for each displayed date, making relative performance immediately visible. Degrades gracefully to "n/a" on fetch failure. 3. Removed redundant Daily DD column: was identical in sign/magnitude to Dly Ret (just clamped at 0), providing no additional information. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
daily_pnlused Alpaca'slast_equity(4pm official close) as baseline — causing NAV to move opposite to daily P&L on some days. Now reconstructs NAV asinitial_last_equity + cumulative daily_pnlsoNAV[today] - NAV[yesterday] == daily_pnl[today]always holds, matching the same 4pm-close basis as SPY benchmark data.n/aon fetch failure.Test plan
python main.py --mode eveningand verify P&L table in Telegram shows SPY column and consistent NAVNAV[today] - NAV[yesterday] == Net P&Lfor every row🤖 Generated with Claude Code