Skip to content

fix(backtest): include initial equity in maximum drawdown - #68

Merged
KageRyo merged 1 commit into
mainfrom
feature/65-initial-equity-drawdown
Oct 11, 2026
Merged

KageRyo merged 1 commit into
mainfrom
feature/65-initial-equity-drawdown

Conversation

@KageRyo

@KageRyo KageRyo commented Oct 11, 2026

Copy link
Copy Markdown
Owner

Summary

The first recorded equity previously became the initial drawdown peak, so a first loss from starting capital 1.0 to 0.8 followed by recovery incorrectly reported zero drawdown. Include 1.0 only in the drawdown calculation input; that example now reports -20%.

Public equity-curve points and timestamps, serialized result fields, returns, Sharpe samples, and trade/signal counts retain their contracts. Document the initial reference and negative-or-zero sign convention in both READMEs and the backtesting guide.

Closes #65.

Validation

  • First-loss/recovery and consecutive-loss regressions failed before the fix, then passed; later peak-to-trough and neutral cases also pass.
  • Full suite: 131 passed; coverage83.65% (required80%). Compatibility assertions cover other metrics, timestamps, and public result keys.
  • Wheel/sdist build and strict Twine checks passed.
  • ruff check .
  • ruff format --check .
  • pyright
  • pytest

Checklist

  • Branch follows feature/<issue>-<description>.
  • No credentials, .env files, or generated market data were committed.
  • English and 正體中文 documentation are aligned.
  • Outputs remain clearly labelled as informational, not financial advice.

@sonarqubecloud

Copy link
Copy Markdown

@KageRyo
KageRyo merged commit 825feb5 into main Oct 11, 2026
13 checks passed
@KageRyo
KageRyo deleted the feature/65-initial-equity-drawdown branch October 11, 2026 09:39
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.

fix(backtest): include initial equity when calculating maximum drawdown

1 participant