Skip to content

Update drawdown calculation to use High/Low instead of close only prices#9354

Open
JosueNina wants to merge 6 commits intoQuantConnect:masterfrom
JosueNina:feature-8699-update-drawdown-ohlc-equity-curve
Open

Update drawdown calculation to use High/Low instead of close only prices#9354
JosueNina wants to merge 6 commits intoQuantConnect:masterfrom
JosueNina:feature-8699-update-drawdown-ohlc-equity-curve

Conversation

@JosueNina
Copy link
Copy Markdown
Collaborator

Description

  • Drawdown previously used only the Close price of each equity curve candlestick
  • Now uses High for peak tracking and Low for drawdown measurement, giving a more accurate result
  • Falls back to using only the close price for non-candlestick data

Related Issue

Closes #8699

Motivation and Context

N/A

Requires Documentation Change

N/A

How Has This Been Tested?

It was tested using unit tests.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Refactor (non-breaking change which improves implementation)
  • Performance (non-breaking change which improves performance. Please add associated performance test and results)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Non-functional change (xml comments/documentation/etc)

Checklist:

  • My code follows the code style of this project.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • My branch follows the naming convention bug-<issue#>-<description> or feature-<issue#>-<description>

@JosueNina JosueNina changed the title WIP: Update drawdown calculation to use OHLC High/Low instead of close only prices WIP: Update drawdown calculation to use High/Low instead of close only prices Mar 26, 2026
@Brnken
Copy link
Copy Markdown

Brnken commented Mar 27, 2026

Did I build this

@JosueNina JosueNina changed the title WIP: Update drawdown calculation to use High/Low instead of close only prices Update drawdown calculation to use High/Low instead of close only prices Mar 27, 2026
@aiSynergy37
Copy link
Copy Markdown

I investigated the failing Benchmarks job and the instability is concentrated in EmptySingleSecuritySecondEquityBenchmark. I pushed a targeted optimization commit that avoids extra allocations/type checks in Statistics.CalculateDrawdownMetrics while preserving the OHLC drawdown logic from this PR.

Commit: KeerthiCHS@e20ceda
Branch: KeerthiCHS:pr-9354-benchmark-fix

You can apply it on this PR branch with:
git fetch https://github.com/KeerthiCHS/Lean.git pr-9354-benchmark-fix
git cherry-pick e20cedab182160f637af457de0c9b21794bde29a

@aiSynergy37
Copy link
Copy Markdown

I opened a direct helper PR with the benchmark-stability fix from this branch:
#9357

Commit mirrored: e20cedab182160f637af457de0c9b21794bde29a
You can cherry-pick this commit or merge #9357 then merge #9354.

@JosueNina
Copy link
Copy Markdown
Collaborator Author

Hey @aiSynergy37, thanks for the contribution. I cherry-picked your commit

Copy link
Copy Markdown
Collaborator

@jhonabreul jhonabreul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

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.

Update Drawdown Calculation Use OHLC of the Equity Curve

4 participants