[pull] develop from freqtrade:develop#1787
Merged
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 : )