Skip to content

fix(notifier): align P&L table NAV with daily_pnl basis, add SPY column#94

Merged
diana-jydai merged 1 commit into
mainfrom
fix/pnl-table-nav-spy-alignment
May 28, 2026
Merged

fix(notifier): align P&L table NAV with daily_pnl basis, add SPY column#94
diana-jydai merged 1 commit into
mainfrom
fix/pnl-table-nav-spy-alignment

Conversation

@diana-jydai
Copy link
Copy Markdown
Collaborator

Summary

  • NAV consistency: NAV was using after-hours portfolio value (8-10pm ET) while daily_pnl used Alpaca's last_equity (4pm official close) as baseline — causing NAV to move opposite to daily P&L 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.
  • SPY daily return column: adds SPY close-to-close return for each row, making relative performance immediately visible. Degrades gracefully to n/a on fetch failure.
  • Removed redundant Daily DD column: was identical to Dly Ret (just clamped at 0), provided no additional information.

Test plan

  • Run python main.py --mode evening and verify P&L table in Telegram shows SPY column and consistent NAV
  • Confirm NAV[today] - NAV[yesterday] == Net P&L for every row
  • Confirm SPY fetch failure degrades gracefully (n/a, no crash)

🤖 Generated with Claude Code

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>
@diana-jydai diana-jydai merged commit fb03575 into main May 28, 2026
1 check passed
@diana-jydai diana-jydai deleted the fix/pnl-table-nav-spy-alignment branch May 28, 2026 05:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant