feat: proper Order Book Imbalance strategy for BTC-USD on HL

strategies/nt/obi_nt.py:
- Dual-mode OBI: candle proxy (backtest) + real L2 orderbook (live)
- Volume-based imbalance: buy_vol / (buy_vol + sell_vol) over rolling window
- Entry when |imbalance| > 0.35, exit on reversion < 0.10
- Stop-loss 2%, take-profit 0.5%, cooldown 3 bars
- compute_signal(price, orderbook=None) for paper trader integration

backtests/vbt_runner.py:
- Replaced placeholder z-score with proper volume-based OBI
- Buy vol = volume where close > open, sell vol = volume where close < open
- Rolling window imbalance computation
- Parameter sweep support with 12 combos tested

Registered across: deploy.py, nt_runner.py, dashboard, strategies/nt/__init__

Verified:
- VectorBT OBI backtest: 15 trades, -7.2% on default (window=20)
- Param sweep best: w=30 t=0.35 → sharpe -0.82, 49% win, 23% DD
- Real L2 orderbook signal: BUY obi=0.880 (bids 88% of depth)
- NT backtest engine: 201 bars, 8 days, 236ms
This commit is contained in:
ramseshk
2026-08-07 10:50:43 +08:00
parent 879372f69e
commit 37da46a016
6 changed files with 315 additions and 6 deletions
+3 -2
View File
@@ -573,8 +573,9 @@ async def list_vbt_strategies():
{"key": "pairs", "name": "Pairs Trading", "coins": ["BTC", "ETH"]},
{"key": "hurst_vpin", "name": "Hurst VPIN", "coins": ["BTC"]},
{"key": "as_mm", "name": "Avellaneda-Stoikov MM", "coins": ["BTC"]},
{"key": "momentum", "name": "Momentum Breakout", "coins": ["BTC"]},
{"key": "mean_rev", "name": "Mean Reversion", "coins": ["BTC"]},
{"key": "obi", "name": "Order Book Imbalance", "coins": ["BTC"]},
{"key": "momentum", "name": "Momentum Breakout", "coins": ["ETH"]},
{"key": "mean_rev", "name": "Mean Reversion", "coins": ["ETH"]},
])