Add ZHMeanReversionStrategy ported from ZH-trading repo#82
Open
ZhuRong818 wants to merge 3 commits into
Open
Conversation
Port the mean reversion strategy from ZH-trading/strategies/v2/meanrev.py to freqtrade IStrategy interface for backtesting. Buys when price drops below rolling mean by entry_threshold, exits on reversion. Includes dynamic stoploss via stop_multiple and Kelly-compatible parameter space. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The workflow subcommand (mlsys-io#10) introduced a positional argument that crashed the CLI argument parser on every command. This was fixed upstream in mlsys-io/freqtrade#11. Update the submodule pointer from ab093ff to 2607696. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Upgrade from pure mean reversion to hybrid strategy with multi-signal confirmation. Adds Bollinger Band lower band touch, RSI oversold, and volume spike as entry filters, plus trailing stop for better exits. Key results vs v1: - Stocks 5m: -2.57% → -1.13%, win rate 40% → 56% - Indices 5m: -0.11% → +0.18% (turned profitable) - Stocks 1d: win rate 54% → 75% - Mixed 1d: win rate 67% → 88% Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
[ZH-trading/strategies/v2/meanrev.py](https://github.com/Z
huRong818/ZH-trading/blob/main/strategies/v2/meanrev.py)
to freqtrade
IStrategyinterface for backtestingbenchmark_all.pyforinclusion in the full benchmark suite
entry_threshold, exits on reversion to mean, withdynamic stoploss via
stop_multipleLogic Mapping
MarketContext.mid_pricedataframe["close"]np.mean(prices[-window:])close.rolling(20).mean()deviation < -entry_threshold→ BUYenter_long = 1mid >= moving_avg - exit_threshold→ EXITexit_long = 1kelly_size()stop = mid - abs(dev) * stop_multiplecustom_stoplossreturns-entry_threshold × stop_multipleKey findings:
rate) — matches the strategy's original design for
high-frequency mean reversion on volatile assets
positive returns but few trades
than mean-revert