ramseshk
9d817ac2fa
feat: VBT trade log — show asset, entry/exit prices, Hyperliquid fees
...
Backend (vbt_runner.py):
- Add asset (BTC/ETH) to each trade record
- Compute per-trade fee using HL taker rate (0.05%)
entry_fee = size * entry_px * fee_rate
exit_fee = size * exit_px * fee_rate
- Add pnl_gross (before fees) and pnl_net (after fees)
- Add fee_rate field for transparency
Server (server.py):
- Normalize old backtest trades: add missing asset, fee,
pnl_net, pnl_gross fields
- Holyliquid default fee rate: 0.05% taker
Frontend (vbt.html):
- Trade log table now shows:
Time | Side + Asset | Size | Entry | Exit | Fee | PnL (net) | Duration
- Asset shown as inline badge in Side column
- Fee column with explicit USD amount
- PnL now explicitly labeled 'net' (after fees)
- Fallback to old 'pnl' field for legacy backtest files
2026-08-07 15:35:33 +08:00
ramseshk
9ee13a45bb
fix: LTTB downsampling crashes on string timestamps + abs→Math.abs
...
- _lttb_downsample: equity curve timestamps are ISO strings,
not numeric. Rewrote to use array indices for triangle area
instead of trying to multiply string * float.
- Fixed IndexError from reusing 'a' variable incorrectly
- Also fixed earlier: abs(dd) → Math.abs(dd) in vbt.html
2026-08-07 15:26:42 +08:00
ramseshk
870df57051
fix: dashboard errors — Math.abs, API routing, fetchHistorical guard
...
Fixes three bugs in dashboard:
1. vbt.html: bare abs(dd) → Math.abs(dd) — fixes ReferenceError
2. server.py: Add /cv/ routing for Next.js quant dashboard
- Mount _next static assets at /cv/_next (not /cv/ which eats API routes)
- Add /cv/api/* routes for backtests/historical, detail, recalc, risk
- Add /cv/ws WebSocket endpoints for live/paper metrics
- Add /cv/ catchall for Next.js HTML pages
3. dashboard-next/src/lib/api.ts: add res.ok guard to fetchHistorical()
— prevents SyntaxError when API returns HTML error pages
4. sim/maker.py: guard observe() against zero mid_price
2026-08-07 15:19:18 +08:00
ramseshk
e58c5951b7
feat: Phase 5 — integration layer (analytics pipeline, production node v2, CLI) + 12 tests
...
live/integrator.py (AnalyticsPipeline):
Real-time pipeline: data → microstructure → signals.
Accumulates book snapshots + trades, computes OBI, VPIN, microprice,
spread, depth, trade imbalance, HFT regime, and emits composite
signal with confidence and breakdown. Per-coin isolation.
live/node_v2.py (ProductionNode):
Rebuilt production node integrating ALL Phase 1-4 modules:
- REST data fetching (order book, mark prices, funding rates)
- AnalyticsPipeline per coin for real-time microstructure signals
- Treasury for position/capital/PnL/breaker management
- ToxicityFilter integration via HlMakerPool makers
- HlMakerPool for per-coin A-S quoting
- CrossVenueMonitor, FundingBasisMonitor, LiquidationRiskOverlay
- Paper trading with probabilistic fill simulation
- Dashboard metrics JSON output (equity, treasury, analytics, maker)
- Periodic status logging
cli.py (unified CLI):
Subcommands integrating all modules:
collect — Run Hyperliquid data collector to Parquet
analyze — Run microstructure analytics on stored data
simulate — Run market-making simulator on stored data
run — Start production trading node (paper or live)
backtest — Run VectorBT backtest
12 integration tests (all pass):
- AnalyticsPipeline: empty, book, trade, VPIN, emit, regime, isolation
- ProductionNode: creation, tick cycle (3 ticks), metrics JSON output
- CLI: import verification
Total test suite: 184 tests, all passing.
2026-08-07 14:54:47 +08:00
ramseshk
4f66ef36a9
feat: Phase 4 — controlled strategy deployment module + 38 tests
...
New live/ sub-modules for production-ready market making:
live/filters/toxicity.py (ToxicityFilter):
VPIN-based pre-trade filter. Accumulates buy/sell volume, computes
VPIN via microstructure module, produces quoting decision:
- allow_quoting: bool
- size_multiplier: 0.0–1.0 (graduated reduction approaching alarm)
- granular thresholds (threshold vs alarm) with smooth reduction
live/treasury.py (Treasury):
Central capital/risk management — single source of truth:
- Position tracking per coin (opening, closing, average entry)
- Realized + unrealized PnL computation
- Pre-trade constraint checks (inventory limits, fee estimates)
- Circuit breaker (drawdown, trade count, toxic fill rate, API errors)
- Liquidation distance monitoring
- Automatic cooldown reset after trip expiry
live/makers/hl_btc_eth.py:
HlMaker — per-coin market maker integrating:
- AvellanedaStoikovMaker (Phase 3) for optimal quotes
- ToxicityFilter for pre-trade gating
- Treasury for position/risk checks
HlMakerPool — manages multiple HlMaker instances with shared treasury
and coordinated observe_all()/quote_all()
live/monitors/cross_venue.py (CrossVenueMonitor):
Cross-exchange lead-lag detection via cross-correlation at multiple
lags. Spot premium (basis proxy) computation. Multi-venue summary.
live/monitors/funding_basis.py (FundingBasisMonitor):
Funding regime classification, momentum detection, carry PnL
estimation, basis spread analysis. Uses microstructure/funding.py.
live/monitors/liq_risk.py (LiquidationRiskOverlay):
Per-position liquidation distance monitoring with tiered warnings
(safe/warning/danger/critical). Recommended position reduction.
38 tests across 4 files (all pass):
test_live_filters.py (5)
test_live_maker.py (9)
test_live_monitors.py (11)
test_live_treasury.py (13)
Total test suite: 172 tests, all passing.
2026-08-07 14:47:08 +08:00
ramseshk
639dd4fb6d
feat: Phase 3 — event-driven market-making simulator + 53 tests
...
New sim/ module — 7 files + init, replays stored L2/trade data
through a realistic market-making simulation:
sim/engine.py (SimulationEngine):
Event-driven core — processes L2 updates, trades, mark prices
sequentially. Orchestrates queue model, maker quotes, fill sim,
constraints, scenarios. Supports periodic re-quoting and
stale order cancellation.
sim/queue.py (QueueModel):
Price-time FIFO queue per price level. Tracks where maker orders
sit in queue. Simulates order eating by aggressor trades.
fill_probability() — Poisson thinning model for fill odds.
sim/maker.py:
AvellanedaStoikovMaker — stochastic control quoting with
aeta, k, tau parameters. Reservation price based on inventory.
quote() and quote_with_skew() with configurable inventory tilt.
GridMaker — evenly-spaced grid quoting at N levels.
sim/fills.py:
FillSimulator — partial fills, adverse selection probability,
cancel latency (gaussian RTT). FillEvent/CancelEvent tracking.
adverse_selection_intensity() — measures post-fill price moves.
sim/constraints.py:
InventoryConstraint — long/short/net/gross position limits.
FundingConstraint — hourly funding cost estimation.
FeeSchedule — maker/taker fee calculation.
LiquidationRisk — liquidation price and safety distance.
CircuitBreaker — PnL, trade count, toxic rate, slippage trips.
ConstraintManager — unified pre-trade constraint check.
sim/scenario.py:
ScenarioEngine — randomized exchange downtimes, latency spikes,
volatility bursts. State query per sim_time for spread/trade-rate.
sim/reporter.py:
PnLReporter — component-level PnL breakdown:
spread_capture, inventory_pnl, fees, funding, adverse_selection.
SimulationStats — trade counts, fill rates, drawdown, sharpe.
Equity curve tracking and max drawdown computation.
53 new tests across 4 files (all pass):
test_sim_queue.py (12) — order placement, FIFO, fills, cancels
test_sim_maker.py (9) — A-S quotes, inventory skew, grid maker
test_sim_constraints.py (14) — limits, funding, fees, liquidation, breakers
test_sim_reporter.py (12) — PnL components, equity curve, stats
test_sim_engine.py (6) — full engine integration
Total test suite: 134 tests, all passing.
2026-08-07 14:39:59 +08:00
ramseshk
fcfc136384
feat: Phase 2 — microstructure analytics + 81 tests
...
New microstructure/ module with pure-function analytics:
microstructure/book.py:
microprice() — depth-weighted mid price
mid_price() — simple bid/ask midpoint
order_book_imbalance() — ranged [-1, 1] volume skew
depth_imbalance() — imbalance at fixed price distance
spread_stats() — spread, spread_bps, mid, bid, ask
depth_resiliency() — bid/ask volume within impact radius
queue_depletion_prob() — Poisson fill probability at level
batch_book_stats() — aggregate stats across snapshots
microstructure/trades.py:
classify_lee_ready() — Lee-Ready aggressor classification
classify_bulk_lee_ready() — batch classification with mids/bids/asks
compute_markouts() — forward mid-price change at configurable horizons
markout_summary() — mean/std/t-stat per side per horizon
trade_volume_profile() — size bucket distribution
trade_arrival_rate() — rolling trades/sec with burst detection
microstructure/toxicity.py:
compute_vpin() — volume-synchronized informed trading probability
compute_vpin_time_series() — rolling VPIN with alarm threshold
fill_toxicity() — adverse price movement post-trade
adverse_selection_ratio() — per-side adverse selection
liquidation_clustering() — cluster detection in liquidation events
microstructure/funding.py:
funding_regime() — classify regime (neutral/positive/negative/high)
funding_predictability() — AR(1) autocorrelation analysis
funding_carry_pnl() — cumulative carry PnL estimation
basis_spread() — perp premium over spot (bps)
basis_convergence_speed() — mean-reversion half-life via AR(1)
microstructure/signals.py:
composite_signal() — weighted OBI + trade + VPIN + funding signal
SignalPipeline — stateful pipeline accumulating book/trade updates
detect_hft_regime() — regime classifier for HFT strategy selection
Bug fixes in Phase 1:
- data/latency.py: proper linear-interpolation percentiles
- data/normalizer.py: UTC timezone for naive datetimes
- data/normalizer.py: detect_sequence_gap returns gap-1 (missing count)
- microstructure/toxicity.py: consistent vpin_value key in compute_vpin
81 tests across 4 test files (store, normalizer, latency, microstructure)
2026-08-07 14:34:18 +08:00
ramseshk
a7f811eb81
feat: Phase 1 — real-time & historical data system
...
New data/ module with:
- data/store.py: Parquet-based raw message storage with background writer
thread. Messages partitioned by channel/coin/date. Thread-safe queue.
Supports pyarrow Parquet with zstd compression. Includes read_range()
helper for replay.
- data/collectors/hyperliquid.py: HL WebSocket + REST collector
- WebSocket: l2Book (full book reconstruction), trades, allMids (mark prices)
- REST pollers: funding rates, predicted funding, open interest, liquidations
- Per-coin OrderBook class with snapshot/update reconstruction
- Sequence gap detection with per-coin re-snapshot on gap
- Latency tracking (exchange transport, signal, order, roundtrip)
- Periodic stats reporter (book stats + latency summary every 60s)
- CLI entrypoint: python -m data.collectors.hyperliquid --coins BTC ETH
- data/normalizer.py: Timestamp normalization (ms, s, ISO strings from
HL/Binance/Bybit/OKX/Coinbase/Deribit) + SequenceTracker with gap detection
- data/latency.py: Rolling-window latency metrics (p50/p90/p95/p99) for
transport, signal computation, order submission, and roundtrip
- Added pyarrow + aiohttp to requirements.txt
2026-08-07 14:28:21 +08:00
ramseshk
b13ce68fef
fix: inverted condition in loadResults — new API response format was falling into wrong branch
2026-08-07 14:17:03 +08:00
ramseshk
6889e06a86
feat: VBT dashboard overhaul — pagination, caching, LTTB downsampling, deep links, export, more metrics
...
- Merge vbt_server.py into server.py (eliminate duplicated VBT API)
- Add server-side pagination (offset/limit) with metadata (total, has_more)
- Add server-side ?asset= filtering to results endpoint
- Add JSON file caching with 5s TTL to avoid re-parsing on every request
- Add LTTB (Largest-Triangle-Three-Buckets) downsampling for equity curves
- Add pre-computed drawdown curve to result detail response
- Add /api/vbt/result/{filename}/csv endpoint for trade export
- Add Calmar ratio and expectancy to results metadata
- Rebuild vbt.html frontend with:
- URL hash deep-linking (#filename) for bookmarkable views
- JSON and CSV export buttons in detail panel
- More metrics: Calmar, Sortino, Expectancy, End Equity (10 total)
- Running backtest progress indicator with elapsed seconds
- Pagination controls (prev/next) with page info
- Filter/sort changes auto-apply (no manual refresh needed)
- Better error states with retry buttons
- Run strategy selector independent of filter
2026-08-07 14:14:40 +08:00
ramseshk
92ba6a564a
chore: ignore generated VBT backtest result files
2026-08-07 12:59:34 +08:00
ramseshk
887a33f278
feat: trade log table, strategy params panel, B+W color scheme
...
Dashboard:
- Trade log table: all trades with time, side, size, entry/exit price, PnL, duration
in scrollable panel below charts
- Strategy params panel: displays all coefficients (z_entry, gamma, obi_entry,
grid_levels, etc.) for the selected strategy
- Color scheme: professional black/white
• positive: #03A9F4 (light blue)
• negative: #FF5252 (red)
• neutral: #777 (gray)
• backgrounds: #0a0a0a / #111 / #181818
• borders: #222 / #333
VBT runner:
- _extract_metrics now captures trades from pf.trades.records_readable
(Avg Entry Price, Avg Exit Price, PnL, Return, Duration, Direction)
- _strategy_params() returns key coefficients per strategy type
- _empty_result includes empty trades/params
New vbt_server.py: minimal standalone dashboard (no live trading machinery,
no memory guard, no broadcast loop) — avoids crashing issues
2026-08-07 12:53:52 +08:00
ramseshk
121c67ae5f
feat: VBT dashboard — asset badges, interval/bar selectors, sort/filter
...
Dashboard (vbt.html):
- Interval selector: 1m, 5m, 15m, 1h, 4h, 1d (all Hyperliquid intervals)
- Candle limit selector: 100-5000 bars (6 levels)
- Asset selector: auto/BTC/ETH/SOL for run
- Strategy filter dropdown
- Sort dropdown: Latest, Sharpe, Return%, Min DD, Trades
- Asset badge on every result item in sidebar
- Asset interval filter for results list
- Improved layout: compact 3-row control panel
API (server.py):
- /api/vbt/results: new sort param (sharpe/return/dd/trades/date)
new interval filter, asset field with _infer_asset()
- /api/vbt/run: new coin param, interval already supported
coin suffix in saved filenames
- _infer_asset(): maps strategy names to BTC/ETH/BTC-ETH/SOL
Verified: sort=sharpe shows A-S S=+11.37, interval=1h filters
correctly, 7 dashboard controls rendered, asset badges on all items
2026-08-07 12:41:08 +08:00
ramseshk
623345c4d7
fix: normalize old backtest field names in VBT dashboard API
...
Old files used pnl_pct (not total_return_pct), max_dd (decimal,
not max_drawdown_pct %), num_periods (not n_bars), no profit_factor.
Added _normalize_vbt_fields() that:
- Maps pnl_pct/ann_return_pct → total_return_pct
- Converts max_dd (decimal) → max_drawdown_pct (percentage)
- Maps num_periods → n_bars
- Computes profit_factor from trades (gross_wins / gross_losses)
- Computes win_rate from trades if missing
Both /api/vbt/results and /api/vbt/result/{filename} now normalise.
Verified: old Cartea-Jaimungal file now shows ret=0.82%, pf=1.18, bars=720
2026-08-07 12:35:18 +08:00
ramseshk
737b24895c
fix: VBT dashboard — proper metrics display + redesigned UI
...
- Fixed total_return_pct, profit_factor, n_bars showing 0 in detail view
by using ?? operator instead of || 0 and fixing renderDetail logic
- Run Backtest now renders result directly from API response
(no re-fetch race condition)
- Redesigned UI: monospace trading terminal aesthetic
- Darker palette (#090d14 background, #0d1321 cards)
- Indigo histogram, proper grid layout
- Subtle borders (1px #1a2332), better spacing
- Status indicator with pulse animation
- Sidebar shows Sharpe, Return%, Profit Factor per result
- 8 metric cards: Return, Sharpe, DD, Win Rate, PF, Trades,
End Equity, Sortino
- Smaller, cleaner fonts, monospace throughout
- Bumped memory guard to 2GB to prevent dashboard getting killed
2026-08-07 12:31:24 +08:00
ramseshk
3606e7f92e
feat: proper Grid MM, Composite MM, Hurst/VPIN, Iceberg, A-S strategies
...
New strategies (strategies/nt/):
- GridMMNT: symmetric limit order grid around mid-price, captures spread from
oscillation. Simulates fills from candle high/low. Rebuilds grid every 20 bars.
- CompositeMMNT: weighted ensemble of OBI (30%) + A-S inventory skew (40%) +
Hurst/VPIN (30%). Votes: +1 long, -1 short, 0 neutral. Entry |score| > 0.5.
- IcebergNT: volume spike detection for whale accumulation. Dual-mode:
candle proxy (volume > avg*2.5, >= 3 consecutive same-direction) and
L2 wall detection (single level > avg*3). Exit on stop-loss/time/spike-fade.
Fixed strategies:
- Hurst/VPIN VBT: added proper VPIN proxy from candle volume (buy_vol when close
> open, sell_vol when close < open). 50-bar rolling VPIN window. Signal:
H>0.55 AND VPIN>0.25 AND |direction|>0.05. Exit: H<0.45 or direction flips.
- Hurst/VPIN paper trader: added HurstVPINLive integration (was missing entirely)
- A-S VBT: replaced placeholder spread filter with proper A-S simulation using
reservation price formula (mid - q*gamma*sigma^2*tau), inventory tracking
- A-S NT formula: fixed to standard: mid - q*gamma*sigma^2*tau (was scaled by
notional and gamma_scale improperly)
- Iceberg VBT: new volume spike detection replacing the old trend proxy
Registry: all 7 strategies now ✅ (pairs, hurst_vpin, as_mm, obi, grid_mm,
composite_mm, iceberg)
VBT backtest results (500 BTC 1h bars):
pairs: -2.81% 13 trades 38% win
hurst_vpin: -0.77% 1 trade (VPIN now active, very selective)
as_mm: -16.38% 73 trades 29% win
obi: -7.19% 15 trades 7% win
grid_mm: -4.79% 22 trades 33% win
iceberg: 0 trades (threshold strict for 1h BTC data)
2026-08-07 11:42:32 +08:00
ramseshk
37da46a016
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
2026-08-07 10:50:43 +08:00
ramseshk
879372f69e
merge: resolve conflicts, keep local framework changes
2026-08-06 17:52:55 +08:00
ramseshk
9cf871be46
Fix order pricing: 1-tick advantage at best bid/ask + process guard
...
A-S was quoting at best bid/ask (0% win) — orders filled but
0.04% round-trip maker fee exceeded spread capture.
Now: bid+1 / ask-1 = captures spread minus 1 tick each side.
Signal-driven strategies: same 1-tick pricing instead of
0.03% offset that crossed the book or sat too far away.
Added fcntl file lock to prevent duplicate live nodes.
Added IOC fallback (market-crossing) when post-only rejected.
A-S win rate: 0% → 25% (first 8 trades with new pricing)
2026-08-06 09:47:21 +00:00
ramseshk
6934bfdaa0
feat: VectorBT results dashboard with Plotly charts
...
Dashboard (dashboard/):
- New /api/vbt/results — list VBT backtest results with full metrics
- New /api/vbt/result/{file} — load result + equity curve (auto-decimated >500pts)
- New /api/vbt/run — run backtests on-demand from the UI
- New /api/vbt/sweep — parameter sweep as heatmap data
- New /api/vbt/strategies — list available strategy keys
- New /vbt — interactive HTML dashboard (Plotly.js):
- Equity curve chart with area fill
- Drawdown waterfall chart
- Returns distribution histogram
- Metric cards: Sharpe, Sortino, max DD, win rate, profit factor
- Strategy filter sidebar
- One-click backtest runner
- Fix BACKTEST_DIR auto-detection for local/dev paths
API verified: all 5 endpoints tested against live data
2026-08-06 17:43:47 +08:00
ramseshk
39545ac94b
fix: NT backtest engine venue registration and bar precision
...
- Fix add_venue call with required OmsType, AccountType, Money params
- Fix Bar volume precision to match instrument size_precision
- Fix subscribe_bars to use BarType not InstrumentId
- Fix _submit_order to gracefully handle NT internal API
- All tests pass: VBT, NT, signals, paper exec, param sweep
2026-08-06 17:33:52 +08:00
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
8461ed5097
Live open orders/positions + A-S gamma fix + MR 60-tick window
...
1. Live dashboard now shows real open orders (87) and positions (2)
from Hyperliquid API, cached every 5s to avoid 429 rate limit.
2. A-S gamma scaling: gamma*500K gives ~0 skew at max inventory
(was bash.003, functionally identical to naive dual-quote).
3. Mean Reversion: 60-tick window with 0.5σ threshold
(20s of 1s ticks was noise, not mean-reverting).
4. Sizes reduced for margin safety (wallet 86, 9 concurrent orders).
5. Kalman win_rate bug fixed: added net_pnl/gross_pnl field support.
2026-08-06 09:13:51 +00:00
ramseshk
2429394cd8
Deep audit fixes: A-S gamma scaling + Mean Rev window
...
1. A-S reservation price now uses gamma*500000 scaling.
Before: bash.003 skew on 4K BTC (invisible, same as naive dual-quote)
After: ~0 skew at max inventory (0.05% of mid — enough to suppress one side)
2. Mean Reversion: 20-tick → 60-tick window, threshold 1.0σ → 0.5σ.
20 seconds of 1s ticks is noise, not mean-reverting.
60 seconds captures real short-term reversion dynamics.
Fill attribution verified: BTC sizes differ by 50 μBTC, ETH by 0.0025 — all above matching tolerance.
Orderbook null guards present — no crash on failed fetch.
2026-08-06 08:34:37 +00:00
ramseshk
a6905f2691
Fix win_rate() for Kalman Pairs: add net_pnl/gross_pnl field support
...
Bug: win_rate() only checked pnl_net/pnl_gross/pnl fields,
but Kalman backtests save trades with net_pnl/gross_pnl (underscore-first).
Result: all 4 Kalman assets showed 0% win on 27-35 trades.
After fix:
BTC: 0% → 45% (16/35)
ETH: 0% → 47% (16/34)
HYPE: 0% → 51% (14/27)
VVV: 0% → 57% (19/33)
Also corrected paper trader coin assignments for Mean Reversion
and Momentum Breakout (was BTC, should be ETH).
2026-08-06 08:26:35 +00:00
ramseshk
37b8496dc2
Optimal position sizing: 4x BTC, 40x ETH utilization
...
Strategy Old→New Notional Capital Utilization
─────────────────────────────────────────────────────────
OBI (BTC) 3→1 12%→51% (4x)
Iceberg (BTC) 3→4 13%→54% (4x)
Funding (BTC) 4→8 14%→58% (4x)
A-S MM (BTC) 5→1 15%→61% (4x)
Hurst VPIN (BTC) 5→4 15%→64% (4x)
Momentum (ETH) →8 1%→38% (40x)
Mean Reversion (ETH) →3 1%→43% (45x)
Kalman Pairs (ETH) 0→8 10%→48% (5x)
Pairs Trading (ETH) 1→2 11%→52% (5x)
ETH strategies were using <1% of capital — essentially generating no PnL.
Kelly-based optimal sizing: 40-65% utilization is the sweet spot for
balancing return vs drawdown at 00/strategy scale.
2026-08-06 08:16:48 +00:00
ramseshk
74113ab624
A-S MM backtest: 4 assets with FIFO round-trip PnL
...
Results on real 5m candle data (7 days):
BTC: +0.65% PnL | 506 matched | 72% win | 1044 fills
ETH: 0.00% PnL | 505 matched | 57% win
HYPE: 0.00% PnL | 510 matched | 61% win
VVV: 0.00% PnL | 512 matched | 42% win
Side-selection via reservation price reduces adverse fills.
BTC shows clear edge: spreads are wider in absolute terms.
2026-08-06 08:11:46 +00:00
ramseshk
f9bed72b1c
Proper A-S: side selection via reservation price (not spread formula)
...
The AS optimal spread formula gives absurd spreads at crypto scale.
Real market makers quote at the MARKET spread (best bid/ask) and use
AS to decide WHEN to quote based on inventory-adjusted fair value:
r = s - q * gamma * sigma^2 * tau
If r < best_bid (long-biased) → stop quoting bid
If r > best_ask (short-biased) → stop quoting ask
If circuit breaker active → pause both sides
Decoupled: spread is market-driven, inventory skew is AS-driven.
2026-08-06 08:04:49 +00:00
ramseshk
a5de7d526f
Proper Avellaneda-Stoikov: reservation price + optimal spread model
2026-08-06 08:00:08 +00:00
ramseshk
08a95e8fe2
Proper Avellaneda-Stoikov: reservation price + optimal spread model
2026-08-06 16:00:00 +08:00
ramseshk
50f8f4f970
Refactor: review, fix, and test entire codebase
...
Live node:
- Fix null-handling for open_ords and get_fills requests
- Cap equity_history, strategy_equity at 600-1000 entries (memory leak fix)
- Dynamic strategy count in startup log
- Loop error recovery: catch exceptions, backoff 5s, continue
Dashboard server:
- Fix backtest detail API: check HISTORICAL_DIR first
- This was causing all historical detail views to show zeros
Tests (5 suites, all passing):
1. Signal generation: Mean Reversion VWAP + Momentum + Pairs + OBI
2. Backtest: SPX mean reversion on 500-point series
3. Hurst/VPIN: 15 signals from 280 dollar bars
4. Memory guard: RSS monitoring, GC thresholds
5. Dashboard API: historical listing + SPX detail
38 backtests on dashboard, 2 SPX entries with real trade data.
2026-08-06 07:52:02 +00:00
ramseshk
392bde44a0
Fix backtest detail API — check historical/ subdirectory first
...
Bug: /api/backtest/{name} only looked in backtests/results/,
but all historical backtests are saved in backtests/results/historical/.
Fix: check HISTORICAL_DIR first, then fall back to BACKTEST_DIR.
This fixes SPX backtest detail showing zero prices/fees.
2026-08-06 07:44:07 +00:00
ramseshk
6fcf5e7c7d
TradeXYZ SPX S&P 500 Mean Reversion backtest
...
Data: real Hyperliquid SPX perpetual candles (licensed S&P 500).
1h 30d: +0.26% PnL, 38 trades, 74% win rate
30m 7d: +0.14% PnL, 22 trades, 77% win rate
Strategy: Z-score mean reversion on 20-bar rolling window.
Entry at ±1.5σ, exit at ±0.3σ reversion. 1% capital per trade.
2026-08-06 07:34:55 +00:00
ramseshk
cbbd0ef941
Fix Mean Reversion VWAP bug — was never firing
...
Root cause: VWAP weighted the current price highest so dev≈0 always.
- Use prior 19 prices (exclude current) for mean/std calculation
- Compare current price vs prior mean, normalized by prior std
- Paper trader: was using BTC prices instead of ETH (wrong coin)
- Threshold unified: 1.0σ (was 1.5σ in paper, 1.0σ in live)
Backtests show BTC Mean Reversion: +76.42% PnL, 91% win, 22 trades.
2026-08-06 07:28:31 +00:00
ramseshk
ff3e68855c
Repo cleanup: README with full stack summary + .gitignore + remove stale backups
2026-08-06 07:21:04 +00:00
ramseshk
3cc68cd46a
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
2026-08-06 07:13:17 +00:00
ramseshk
b0eaee47db
Hurst/VPIN backtest: 1 trade, 0% PnL (synthetic — selective by design)
2026-08-06 07:03:12 +00:00
ramseshk
cf376f2995
Deploy Hurst/VPIN directional strategy to live + paper
...
Live node:
- Added Hurst VPIN to STRATEGIES (BTC, 0.00024 size, 00)
- Feed BTC price into dollar-bar Hurst/VPIN every 5 ticks
- Signal: BUY/SELL when H>0.55 + VPIN>0.25 + direction bias
Paper trader:
- Added Kalman Pairs, Avellaneda-Stoikov, Hurst VPIN strategies
- All 00 allocation, matching live node asset distribution
- Hurst/VPIN signal from BTC mid-price dollar bars
Strategy file: hurst_vpin_live.py (lightweight price-tick mode)
2026-08-06 06:51:51 +00:00
ramseshk
a8ed3cafe0
Fix memory guard: remove RLIMIT_AS (blocks Python heap), VmRSS-only
2026-08-06 06:40:08 +00:00
ramseshk
298b9c8020
Memory guard: 512MB hard cap, GC at 256MB, 2GB swap
2026-08-06 06:31:16 +00:00
ramseshk
e5a81132ef
Memory guard: 512MB hard cap, GC at 256MB, +swap
2026-08-06 14:30:34 +08:00
ramseshk
2176910fab
QuantReport: handle API error responses, restart paper trader
2026-08-06 06:19:42 +00:00
ramseshk
c98681c130
Fix historical cards + Hurst/VPIN strategy
...
Historical tab fix:
- StrategyCard: handle BacktestSummary type (not Strategy)
- Pass coin/badge/stats/pnlPct/status props for historical
- Historical cards now show proper data
Hurst/VPIN directional strategy (Hyperliquid BTC-USD):
- Dollar bars (constant-notional 0K)
- Hurst exponent R/S analysis on 128-bar window
- VPIN on 50-bucket volume imbalance
- Quote-driven entry: both signals agree → BUY/SELL
- Exit: Hurst decays below exit threshold
2026-08-06 04:49:00 +00:00
ramseshk
6a39125fee
Fix detail view crash + QuantReport safety check
...
- QuantReport: handles empty backtestId gracefully (live/paper)
- QuantReport: only fetches for historical tab (has backtest data)
- Shows No data available for live/paper views
- Ubuntu font throughout: layout, header, tabs, cards
- Consistent Hallmark Cobalt light palette
2026-08-06 04:37:23 +00:00
ramseshk
6552511978
Hallmark Cobalt: unified light palette + Ubuntu fonts
...
Layout: Ubuntu + Ubuntu Mono (next/font/google), light mode
CSS: Hallmark Cobalt palette — cool paper bg, hairlines,
electric cobalt primary, slate secondary
Cards: white bg, hairline borders, muted type badges
Header/tabs: Ubuntu Mono labels, Ubuntu tab buttons
Removed: dark mode, Inter/JetBrains Mono, purple gradients
2026-08-06 04:22:50 +00:00
ramseshk
98ee58dfaa
Hallmark redesign + QuantReport fix
...
Header/Tabs: Hallmark Cobalt aesthetic
- Hairlines, cool paper bg, JetBrains Mono + Inter
- Electric cobalt accent on active tab
- No branding, no purple badges, no gradients
QuantReport: inline in strategy detail view
- Renders below trade history on every tab
- API maps strategy name -> file prefix
- Proper backtestId from historical data
Server: strategy-name-to-prefix lookup
ofi, avellaneda, iceberg, momentum, mean_rev,
funding_arb, kalman_pairs, pairs
2026-08-06 04:14:21 +00:00
ramseshk
8cb59239c6
Hallmark Cobalt header: clean professional nav
...
Removed: FTDT Quant Lab branding, purple badges, green pulse dot,
shadcn Tabs dependency, backdrop blur noise
Replaced with: Hallmark Cobalt engineered aesthetic
- Hairline borders (#e0e4ec), cool paper (#f8f9fb)
- JetBrains Mono header labels, Inter tab buttons
- Electric cobalt (#0ea5e9) signal accent on active tab
- Flat text labels: Live · Paper · Historical
- Status dot + CONNECTED/OFFLINE subtle indicator
- No shadows, no gradients, no rounded cards
2026-08-06 03:59:41 +00:00
ramseshk
232d2dae10
Quant Report inline: embed in strategy detail view
...
Removed: popup button + fullscreen overlay
Added: QuantReport renders directly below trade history
in every strategy detail view (live, paper, historical).
White background, 6-panel layout, QF-Lib header.
2026-08-06 03:56:23 +00:00
ramseshk
79870925f7
Fix QuantReport: fuzzy file matching + proper backtestId from historical data
...
- API: fuzzy matcher resolves files by strategy name substring
- Frontend: backtestId now uses historical[name].name (the filename)
- Server restarted with quant_report endpoint
2026-08-06 03:50:28 +00:00
ramseshk
0e08543823
QF-Lib Quant Report: full strategy performance analytics
...
Backend: strategies/quant_report.py
- equityCurve: daily PnL from trade history
- monthlyReturns: heatmap matrix (years x months)
- yearlyReturns: bar chart data with mean
- monthlyReturnDistribution: histogram bins
- qqPlot: theoretical vs observed quantiles
- rollingStats: 6-month rolling return + volatility
API: /api/quant-report/{name}
Computes full report from any backtest JSON file
Frontend: QuantReport.tsx
- Strategy Performance chart (equity curve, blue line)
- Monthly Returns heatmap (blue saturation)
- Yearly Returns bar chart with mean line
- Distribution histogram
- Normal QQ plot with diagonal reference
- Rolling Statistics (6-month, dual line)
- QF-Lib header with logo and metadata
- Access via QF-Lib Report button in detail view
2026-08-06 03:37:25 +00:00