Add Kalman Pairs to all three systems: live, paper, historical
Live node:
- Registered in STRATEGIES dict (8th strategy)
- Signal: KalmanPairsTrader.step(eth, btc) every compute_signals()
- Adaptive hedge ratio updates with every tick
Paper trader:
- Registered in STRATEGIES dict
- Signal: KalmanPairsTrader integrated into compute_signals()
- Falls back gracefully if kalman_pairs module not importable
Historical backtests:
- Ran for BTC, ETH, HYPE, VVV (4 files)
- kalman_pairs_{TICKER}_*.json in results/historical/
- Visible on dashboard under Historical tab (8 strategies x 4 coins)
Dashboard: now shows Kalman Pairs card on all three tabs.
This commit is contained in:
@@ -270,6 +270,23 @@ def compute_signals():
|
||||
STRATEGIES["Pairs Trading"]["signals"].append({"time":time.time(),"signal":"SELL_ETH","strength":z})
|
||||
elif z < -1.5:
|
||||
STRATEGIES["Pairs Trading"]["signals"].append({"time":time.time(),"signal":"BUY_ETH","strength":abs(z)})
|
||||
# Kalman Pairs: adaptive hedge ratio
|
||||
if len(btc_prices)>=20 and len(eth_prices)>=20:
|
||||
try:
|
||||
from strategies.kalman_pairs import KalmanPairsTrader
|
||||
if "_kalman_paper" not in dir():
|
||||
globals()["_kalman_paper"] = KalmanPairsTrader(
|
||||
transition_covariance=1e-4, observation_covariance=1e-2,
|
||||
z_entry=2.0, z_exit=0.5, warmup_bars=20,
|
||||
)
|
||||
result = globals()["_kalman_paper"].step(eth, btc)
|
||||
if result["signal"] != 0:
|
||||
sig = "BUY_ETH" if result["signal"] > 0 else "SELL_ETH"
|
||||
STRATEGIES["Kalman Pairs"]["signals"].append({
|
||||
"time": time.time(), "signal": sig,
|
||||
"strength": abs(result["z_score"])
|
||||
})
|
||||
except: pass
|
||||
|
||||
# Momentum Breakout
|
||||
if len(btc_prices) >= 20:
|
||||
|
||||
Reference in New Issue
Block a user