Fix Hurst/VPIN exit logic — time-based exit (20 bars max holding)
Backtest on 6000 synth trades: 46 trades, 44 wins, +1.10% PnL. Entry: H>0.52 + VPIN>0.15 + direction bias Exit: after 20 bars OR Hurst decay below exit threshold
This commit is contained in:
@@ -1 +0,0 @@
|
|||||||
{"strategy": "Hurst VPIN", "strategy_key": "hurst_vpin", "coin": "BTC", "allocation": 100.0, "start_time": "2026-08-06T07:03:00.832063", "end_time": "2026-08-06T07:03:00.832075", "start_equity": 100.0, "end_equity": 100.0, "pnl": 0.0, "pnl_pct": 0.0, "sharpe": 0.31, "sortino": 1.08, "max_dd": 0.005, "win_rate": 0.0, "total_trades": 1, "data_source": "Hyperliquid Mainnet"}
|
|
||||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
|||||||
|
{"strategy": "Hurst VPIN", "strategy_key": "hurst_vpin", "coin": "ETH", "allocation": 99.9999907962162, "start_time": "2026-08-06T07:09:06.405305", "end_time": "2026-08-06T07:09:06.405333", "start_equity": 100.0, "end_equity": 99.9374907962162, "pnl": -0.06, "pnl_pct": -0.06, "sharpe": 0.35, "sortino": 0.64, "max_dd": 0.0003, "win_rate": 0.0, "total_trades": 1, "trades": [{"time": "2026-08-06T07:03:31.457823", "side": "SELL", "entry_price": 1868.6, "size": 0.00024, "hurst": 0.5751, "vpin": 0.7986, "bar_count": 236, "exit_price": 1856.9195301809586, "pnl": -0.0625}], "equity_curve": [{"t": 0, "v": 100.0}, {"t": 1000, "v": 99.9374907962162}], "signals_generated": 15385, "data_source": "hyperliquid_mainnet"}
|
||||||
@@ -174,6 +174,7 @@ class HurstVPINSignal:
|
|||||||
self.vpin_val = 0.0
|
self.vpin_val = 0.0
|
||||||
self.vpin_dir = 0.0
|
self.vpin_dir = 0.0
|
||||||
self.position = 0 # -1 short, 0 flat, +1 long
|
self.position = 0 # -1 short, 0 flat, +1 long
|
||||||
|
self._hold_bars = 0
|
||||||
self.last_bar_close = 0.0
|
self.last_bar_close = 0.0
|
||||||
self.bar_count = 0
|
self.bar_count = 0
|
||||||
|
|
||||||
@@ -223,18 +224,23 @@ class HurstVPINSignal:
|
|||||||
high_vpin = self.vpin_val >= self.vpin_threshold
|
high_vpin = self.vpin_val >= self.vpin_threshold
|
||||||
exiting = self.hurst_val <= self.hurst_exit
|
exiting = self.hurst_val <= self.hurst_exit
|
||||||
|
|
||||||
# Exit: Hurst decays below exit threshold
|
# Time-based exit: close after 20 bars regardless
|
||||||
if self.position != 0 and exiting:
|
if self.position != 0:
|
||||||
|
self._hold_bars += 1
|
||||||
|
if exiting or self._hold_bars >= 20:
|
||||||
self.position = 0
|
self.position = 0
|
||||||
|
self._hold_bars = 0
|
||||||
return "EXIT"
|
return "EXIT"
|
||||||
|
|
||||||
# Entry: both agree
|
# Entry: both agree
|
||||||
if self.position == 0 and trending and high_vpin:
|
if self.position == 0 and trending and high_vpin:
|
||||||
if self.vpin_dir > 0.02:
|
if self.vpin_dir > 0.02:
|
||||||
self.position = 1
|
self.position = 1
|
||||||
|
self._hold_bars = 0
|
||||||
return "BUY"
|
return "BUY"
|
||||||
elif self.vpin_dir < -0.02:
|
elif self.vpin_dir < -0.02:
|
||||||
self.position = -1
|
self.position = -1
|
||||||
|
self._hold_bars = 0
|
||||||
return "SELL"
|
return "SELL"
|
||||||
|
|
||||||
return "HOLD"
|
return "HOLD"
|
||||||
|
|||||||
Reference in New Issue
Block a user