Skip to content

🧹 Add sensible limit checks for max_drawdown#16

Open
ymcbzrgn wants to merge 2 commits into
mainfrom
jules-7262551468397269019-fee65ae9
Open

🧹 Add sensible limit checks for max_drawdown#16
ymcbzrgn wants to merge 2 commits into
mainfrom
jules-7262551468397269019-fee65ae9

Conversation

@ymcbzrgn
Copy link
Copy Markdown
Owner

🎯 What: Added validation to MaxDrawdown protection to ensure max_allowed_drawdown is between 0.0 and 1.0.

💡 Why: This improves maintainability and prevents unexpected behavior from invalid configuration values, providing earlier failure and clearer error messages.

✅ Verification: Ran tests/plugins/test_protections.py which includes the new test_MaxDrawdown_invalid_config test case to verify exceptions are correctly raised. Ran pre-commit hooks to ensure formatting correctness.

✨ Result: MaxDrawdown protection now throws OperationalException on invalid limits.


PR created automatically by Jules for task 7262551468397269019 started by @ymcbzrgn

Copilot AI review requested due to automatic review settings May 11, 2026 11:03
@google-labs-jules
Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds validation to the MaxDrawdown protection to fail fast when max_allowed_drawdown is configured outside an expected range, and adds a regression test to ensure invalid configs raise OperationalException during bot initialization.

Changes:

  • Added an OperationalException guard in MaxDrawdown.__init__ when max_allowed_drawdown is outside [0.0, 1.0].
  • Added a unit test covering invalid max_allowed_drawdown values (> 1.0 and < 0.0).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
freqtrade/plugins/protections/max_drawdown_protection.py Adds range validation for max_allowed_drawdown and raises OperationalException on invalid configuration.
tests/plugins/test_protections.py Adds test_MaxDrawdown_invalid_config asserting invalid drawdown limits fail with the expected exception message.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +28 to +32
if not (0.0 <= self._max_allowed_drawdown <= 1.0):
raise OperationalException(
f"MaxDrawdown protection: max_allowed_drawdown must be between 0.0 and 1.0, "
f"but got {self._max_allowed_drawdown}."
)
Comment on lines +28 to +32
if not (0.0 <= self._max_allowed_drawdown <= 1.0):
raise OperationalException(
f"MaxDrawdown protection: max_allowed_drawdown must be between 0.0 and 1.0, "
f"but got {self._max_allowed_drawdown}."
)
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.

2 participants