v2.2b: 当前最优基线 - 回测+4673%/+17%最大回撤 + backtest配置

This commit is contained in:
2026-06-08 17:54:00 +08:00
parent 2141a1f8e1
commit 0bdf1f8267
2 changed files with 45 additions and 11 deletions

35
config.backtest.json Normal file
View File

@ -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}
}

View File

@ -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_signal1H 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"]