ramseshk
f5ffe4baee
feat: NautilusTrader + VectorBT unified framework for Hyperliquid
...
Add complete framework for testing and deploying quant strategies:
Framework (framework/):
- HyperliquidInstrumentCatalog: loads perps as NT CryptoPerpetual
- HyperliquidDataProvider: real candle/orderbook/mark-price data
- HyperliquidExecutionProvider: live + PaperExecutionProvider: simulated
- BaseHlStrategy: shared NT strategy lifecycle with signal library
- StrategyConfig: YAML-based parameter management
- DeployOrchestrator: CLI for backtest -> paper -> live pipeline
Backtesting (backtests/):
- VBTBacktestRunner: VectorBT vectorized backtests on real HL candles
- NTBacktestRunner: NautilusTrader event-driven backtest engine
NT Strategy ports (strategies/nt/):
- PairsTradingNT: BTC/ETH ratio Z-score mean reversion
- HurstVPINNT: Hurst exponent regime + VPIN flow imbalance
- ASMarketMakingNT: Avellaneda-Stoikov stochastic control MM
E2E verified: real HL candles fetch, VectorBT backtest (Sharpe 5.2
on Hurst/VPIN), instrument catalog, deploy CLI --list, strategy signals.
Existing live/node.py and paper_trader.py unchanged.
2026-08-06 17:23:49 +08:00
ramseshk
08a95e8fe2
Proper Avellaneda-Stoikov: reservation price + optimal spread model
2026-08-06 16:00:00 +08:00
ramseshk
70d43fefe0
Complete Funding Rate Arb: real API data for live + paper
...
New module: strategies/funding_arb.py
- get_funding_rates(): fetches predicted funding from Hyperliquid
Uses metaAndAssetCtxs (primary) + predictedFundings (fallback)
- funding_arb_signal(): generates entry/exit signals
Entry: |annual_rate| > threshold (3% testnet, 5% mainnet)
Exit: rate drops below 2% or flips sign
- 30s cache to avoid rate-limiting
Live node:
- Replaced proxy-based funding (20-period return) with real API
- Calls get_funding_rates(use_testnet=True) every compute_signals()
- Lowered threshold to 3% APR for testnet (lower liquidity)
Paper trader:
- Replaced manual funding calc with unified funding_arb_signal()
- Proper entry/exit logic with position tracking
- 5% APR threshold for mainnet data
Current rates: BTC +0.87% APR, ETH -0.82% APR
(Arb fires when rates exceed threshold during volatility)
2026-08-05 07:09:29 +00:00
ramseshk
f4c8bca15a
Kalman Filter Pairs Trading System — full production-grade implementation
...
Core engine (pure NumPy, zero external deps beyond NumPy):
- kalman_filter.py: KalmanFilter + KalmanPairsTrader
- Time-varying observation matrix H_t = [1, X_t]
- RTS smoother for offline analysis
- Properties: alpha, beta, spread = Y - (alpha + beta*X)
- Signal: z-score crossing z_entry/z_exit/z_stop thresholds
Pair discovery (pure NumPy):
- pair_discovery.py: Engle-Granger cointegration + OU half-life
- ADF test with MacKinnon critical values (no statsmodels)
- Half-life estimation via OLS on AR(1) residuals
- Pair screening: cointegrated + 1-20 period half-life
- Rolling OLS hedge ratio for baseline comparison
Production system:
- trading_system.py: KalmanPairsTradingSystem
- Multi-pair orchestration with risk overlay
- Capital allocation, stop-loss, drawdown controls
- KalmanPairsConfig dataclass (YAML-compatible)
Backtesting:
- backtest.py: Walk-forward backtest with realistic execution
- Transaction costs, capital tracking, per-trade PnL
- Side-by-side Kalman vs rolling OLS comparison
- Metrics: CAGR, Sharpe, Sortino, max DD, win rate, turnover
Tuning:
- tuning.py: Grid search over transition_covariance
- Train/validation split (chronological)
- Objective: maximize Sharpe - penalty * max_drawdown
Regime-shift test results:
Kalman: Sharpe 2.17, beta adapts from 2.0 -> 0.5 in ~50 bars
OLS 60d: Sharpe 0.17 (stuck on old beta)
OLS 120d: Sharpe 0.66 (even slower adaptation)
Integration: Added to historical_runner.py as kalman_pairs strategy
2026-08-05 06:47:33 +00:00
ramseshk
9768bf80cc
Cartea-Jaimungal, Queue Imbalance, Guéant MM: 3 new quant finance strategies + backtests
2026-08-04 06:19:19 +00:00
ramseshk
e2b3f40b37
Hawkes OFI + Deep LOB: two new strategies from advanced microstructure research
2026-08-04 06:01:19 +00:00
ramseshk
c1da0cbe65
Wire up real Hyperliquid integration and funding rate API
...
Replaced the placeholder live node with a proper NautilusTrader
TradingNode that connects to Hyperliquid Testnet using the
official adapter. Added:
- common/hyperliquid_api.py: direct REST calls to Hyperliquid's
info endpoint for funding rates, predicted fundings, and
asset contexts
- backtests/run_backtest.py: CLI runner for strategy backtests
- Updated funding_rate_arb.py to fetch real funding rates
instead of using a hardcoded placeholder
- Added requests to requirements.txt
2026-08-03 11:37:47 +00:00
ramseshk
b59dcc3629
Initial project scaffold: five quant strategies for Hyperliquid Testnet
...
Set up the directory structure and wrote placeholder logic for:
- Order Book Imbalance: trades on L2 bid/ask skew
- Iceberg/TWAP detection: follows whale accumulation patterns
- Funding rate arbitrage: delta-neutral carry on perp funding
- Pairs trading: BTC/ETH spread mean reversion
- Avellaneda-Stoikov market making: optimal bid/ask quoting
Also added shared risk manager, portfolio tracker, and a plain-language strategy walkthrough in docs/.
2026-08-03 11:12:20 +00:00