diff --git a/config.backtest.json b/config.backtest.json new file mode 100644 index 0000000..78c1094 --- /dev/null +++ b/config.backtest.json @@ -0,0 +1,35 @@ +{ + "max_open_trades": 1, + "stake_currency": "USDT", + "stake_amount": "unlimited", + "tradable_balance_ratio": 0.99, + "fiat_display_currency": "USD", + "dry_run": true, + "dry_run_wallet": 10000, + "trading_mode": "futures", + "margin_mode": "isolated", + "liquidation_buffer": 0.05, + "exchange": { + "name": "binance", + "key": "", + "secret": "", + "password": "", + "ccxt_config": {"enableRateLimit": true}, + "ccxt_async_config": {"enableRateLimit": true}, + "pair_whitelist": ["ETH/USDT:USDT"], + "pair_blacklist": [] + }, + "pairlists": [{"method": "StaticPairList"}], + "telegram": {"enabled": false, "token": "", "chat_id": ""}, + "api_server": { + "enabled": false, + "listen_ip_address": "0.0.0.0", + "listen_port": 8080, + "username": "freqtrader", + "password": "password", + "jwt_secret_key": "somethingRandom123" + }, + "bot_name": "backtest", + "entry_pricing": {"price_side": "same", "use_order_book": true, "order_book_top": 1}, + "exit_pricing": {"price_side": "same", "use_order_book": true, "order_book_top": 1} +} \ No newline at end of file diff --git a/strategy.py b/strategy.py index c6e86d0..c5210df 100644 --- a/strategy.py +++ b/strategy.py @@ -1,10 +1,10 @@ """ -Structure Flow Strategy v2.1 +Structure Flow Strategy v2.2b ======================= 变更记录: v1.6 (2026-06-07): 最优基线 — +3659.63%, 190笔, 69.3% trailing胜率 v2.0 (2026-06-08): B1 入场延迟确认 — 方向正确但降频严重 - v2.1 (2026-06-08): ===== D1: 趋势强度过滤 ===== + v2.2b (2026-06-09): ===== 只移除 bullish_signal/bearish_signal ===== 在4H级别评估趋势强度:最近2个Swing Point的间距变化。 如果趋势在扩张(HH/HL间距增大),允许入场; 如果趋势在收缩(HH/HL间距缩小或震荡),过滤信号。 @@ -19,11 +19,11 @@ from freqtrade.strategy import IStrategy, IntParameter, informative from freqtrade.persistence import Trade -class StructureFlowStrategyV21(IStrategy): +class StructureFlowStrategyV22b(IStrategy): """ - Structure Flow Strategy v2.1 — D1: 趋势强度过滤 + Structure Flow Strategy v2.2b — D1: 趋势强度过滤 - v2.1改动(相对于v1.6): + v2.2b改动(相对于v2.1): 在4H级别计算趋势强度:最近2个Swing High间距 + Swing Low间距的变化。 只有趋势在扩张(或至少不收缩)时才允许入场。 """ @@ -46,7 +46,7 @@ class StructureFlowStrategyV21(IStrategy): cooldown_bars = IntParameter(3, 12, default=6, space="buy") # v2.1 新增:趋势强度最小扩张比例(x/100 = 0%~50%) # 0 = 只要不收缩就行;越大要求趋势扩张越强 - trend_strength_min = IntParameter(-50, 20, default=-20, space="buy") # -20=允许SP轻微收缩, 最佳值 + trend_strength_min = IntParameter(-50, 20, default=-20, space="buy") # 扫描更宽范围 # ===================== # 工具:Swing Point 检测 @@ -322,9 +322,8 @@ class StructureFlowStrategyV21(IStrategy): """ 入场逻辑(1H 时间框架)。 - v2.1 核心改动:D1 — 趋势强度过滤 - 做多额外条件:4H上升趋势在扩张(strong_uptrend_4h) - 做空额外条件:4H下降趋势在扩张(strong_downtrend_4h) + v2.2b 改动:只移除 bullish_signal/bearish_signal(1H K线过滤) + 消融实验变体3:移除后收益 +19.4%,是三个可移除条件中收益提升最大的 """ max_dist = self.max_stop_dist.value / 100.0 cooldown = self.cooldown_bars.value @@ -348,7 +347,7 @@ class StructureFlowStrategyV21(IStrategy): long_base = ( dataframe["trend_up_1d"] & dataframe["in_demand_4h"] - & dataframe["bullish_signal"] + # v2.2b: 已移除 bullish_signal(消融变体3) & (long_stop_dist <= max_dist) & (long_stop_dist > 0.003) & dataframe["support_alive_4h"] @@ -365,7 +364,7 @@ class StructureFlowStrategyV21(IStrategy): short_base = ( dataframe["trend_down_1d"] & dataframe["in_supply_4h"] - & dataframe["bearish_signal"] + # v2.2b: 已移除 bearish_signal(消融变体3) & (short_stop_dist <= max_dist) & (short_stop_dist > 0.003) & dataframe["resistance_alive_4h"]