Skip to content

[pull] develop from freqtrade:develop#1787

Merged
pull[bot] merged 3 commits into
Uncodedtech:developfrom
freqtrade:develop
Jun 13, 2026
Merged

[pull] develop from freqtrade:develop#1787
pull[bot] merged 3 commits into
Uncodedtech:developfrom
freqtrade:develop

Conversation

@pull

@pull pull Bot commented Jun 13, 2026

Copy link
Copy Markdown

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

ducky-duke and others added 3 commits June 8, 2026 15:23
…edundant calc

should_exit already computes current_profit_best = calc_profit_ratio(bound)
(bound = high for longs, low for shorts). ft_stoploss_adjust then recomputed the
exact same value as calc_profit_ratio(bound). Thread the precomputed value down
through ft_stoploss_reached so it is reused, removing one of the three
calc_profit_ratio calls per exit check.

calc_profit_ratio is ~6s cumulative on a 2-month 1m-detail backtest; this drops
~1/3 of its calls. bound_profit defaults to None (recomputed on demand), so the
live after-fill callers of ft_stoploss_adjust are unchanged. Output is
bit-identical: a full 1m-detail backtest produced identical trades and the
strategy/backtesting test suites pass.

Add test_should_exit_bound_profit_reuse covering the truthy-candle-bound path
(long + short x trailing / custom_stoploss) that the rest of the stoploss suite
never exercises (every other stoploss test uses low=None/high=None, so the reuse
branch never fires). It asserts the optimized path adjusts the stop identically
to the on-demand fallback and to an explicitly passed bound_profit; a
profit-sensitive custom_stoploss makes the assertion sensitive to a wrong
forwarded value.
- Explain the `if bound_profit is None` fallback: should_exit always
  forwards it (== current_profit in dry/live), so the None branch is
  only the after-fill callers, which pass no bound and recompute to
  current_profit.
- Trim the redundant "computed on demand when None" from both
  bound_profit docstrings (already implied by the Optional type).
- Parametrize use_custom_stoploss with a boolean flag instead of
  passing an identical lambda twice; assign the lambda in the test.
- Reword test comments for a future reader (drop PR-relative
  "develop"/"optimized" framing and the confusing "truthy bound").
perf(backtest): reuse current_profit_best in stoploss check, drop a redundant calc
@pull pull Bot locked and limited conversation to collaborators Jun 13, 2026
@pull pull Bot added the ⤵️ pull label Jun 13, 2026
@pull pull Bot merged commit 3c293b7 into Uncodedtech:develop Jun 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants