Skip to content

Fix #8268: align PortfolioStatistics win/loss metric definitions#9385

Open
aiSynergy37 wants to merge 1 commit intoQuantConnect:masterfrom
aiSynergy37:fix/issue-8268-portfolio-stat-definitions-v2
Open

Fix #8268: align PortfolioStatistics win/loss metric definitions#9385
aiSynergy37 wants to merge 1 commit intoQuantConnect:masterfrom
aiSynergy37:fix/issue-8268-portfolio-stat-definitions-v2

Conversation

@aiSynergy37
Copy link
Copy Markdown
Contributor

@aiSynergy37 aiSynergy37 commented Apr 11, 2026

What

  • Clarifies PortfolioStatistics metric XML docs to refer to transactions (not trades) for:
    • AverageWinRate
    • AverageLossRate
    • WinRate
    • LossRate
  • Propagates the same terminology to related API/statistics docs (PerformanceMetrics, BacktestSummary, and supporting constructor/parameter docs).
  • Adds a regression test in PortfolioStatisticsTests that demonstrates the intended behavior when transaction classification differs from signed profit/loss.

Why

Issue #8268 points out a mismatch between the metric definitions and how PortfolioStatistics is actually computed. The implementation uses transaction record values and transaction classification counts, so the docs should reflect that behavior to avoid misleading users.

How

  • Updated XML comments and parameter docs from "trades" to "transactions" in relevant statistics and API types.
  • Added WinLossRatesCanDifferFromAverageRatesWhenUsingTransactionClassification to verify:
    • average rates come from signed transaction profit/loss and running capital
    • win/loss rates can follow provided transaction classification counts

Testing

  • dotnet build Tests/QuantConnect.Tests.csproj --no-restore -p:NuGetAudit=false -p:TreatWarningsAsErrors=false
  • dotnet test Tests/QuantConnect.Tests.csproj --no-build --filter "Name=WinLossRatesCanDifferFromAverageRatesWhenUsingTransactionClassification" (test host crashes in this environment with Python.NET GIL finalizer error unrelated to these changes)

Closes #8268

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.

PortfolioStatistics WinRate Definition

2 participants