Skip to content

Features/src notebooks update#41

Open
phuo-nv wants to merge 3 commits into
NVIDIA-AI-Blueprints:mainfrom
phuo-nv:features/src-notebooks-update
Open

Features/src notebooks update#41
phuo-nv wants to merge 3 commits into
NVIDIA-AI-Blueprints:mainfrom
phuo-nv:features/src-notebooks-update

Conversation

@phuo-nv
Copy link
Copy Markdown
Collaborator

@phuo-nv phuo-nv commented May 11, 2026

Summary

This PR fixes cumulative portfolio value/backtest curves so they begin at the requested regime/trading start date with an initial value of 1.0.

Previously, return computation dropped the first price row because the first return is undefined, and cumulative returns were built directly from the first realized return. As a result, cumulative value plots began on the first return date and at 1 + first_return, rather than at the selected start date and 100% portfolio value.

Changes

  • Add explicit cumulative-date anchoring in portfolio_backtester

    • prepends the regime start date when it precedes the first return date
    • prepends cumulative value 1.0
    • exposes cumulative_dates for consumers
  • Update rebalancing cumulative series assembly

    • uses anchored cumulative dates from the backtester
    • avoids duplicating boundary dates between rolling backtest windows
  • Add regression coverage

    • verifies cumulative returns start at the regime start date
    • verifies the first cumulative value is exactly 1.0
  • Preserve existing KDE helper compatibility

    • allows generate_samples_kde to accept dict-style KDE settings used by existing tests

Validation

  • uv run --extra dev pytest
  • uv run --extra dev ruff check src/backtest.py src/rebalance.py src/cvar_utils.py tests/test_core.py

Notes

This fixes the library/source behavior. Demo-specific progressive plotting changes are handled separately where needed.

@phuo-nv phuo-nv requested a review from jgoldberg-nvidia May 11, 2026 20:55
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