Skip to content

View original

AvaxSpotLedTrendBasisSlopeGateLS

Hypotheses

Spot-Led vs Perp-Led Trend Discrimination on AVAX — Long-Short USD-M Perp (AVAXUSDT.BINANCE 4H) Taking Direction ONLY When the Move Was NOT Financed by Expanding Perp Premium (cross-venue basis-slope gate vs AVAXUSDT.BINANCE_SPOT, ATR-Chandelier Exit, 3-Parameter)

Hypotheses

A LONG-SHORT, CROSS-VENUE (Binance USD-M perp + Binance SPOT), 4H-bar directional strategy on AVAX. Primary/trading leg: AVAXUSDT.BINANCE (USD-M perpetual, long AND short, leverage <= 2x). Signal leg (NO orders ever sent): AVAXUSDT.BINANCE_SPOT 4H bars, used only to compute the perp-spot basis series basis_bps(t) = (perp_close - spot_close)/spot_close * 1e4. The strategy's single economic discriminator is the SLOPE of that basis over the same window as the price move, NOT its level. Claim: a directional move whose perp premium EXPANDED with it was bought with leverage (derivatives-led) and is structurally fragile — it is a crowded, funding-paying position that unwinds on the first liquidation cascade; a move of the same size whose perp premium stayed flat or COMPRESSED was absorbed by real spot flow (spot-led) and persists, because spot buyers do not face funding, forced liquidation or margin calls. We therefore trade the trend ONLY in the spot-led case and stand FLAT in the derivatives-led case. This is deliberately NOT the funding-level contrarian fade (which died on SUI) and NOT a same-venue taker-aggressor confirmation gate (which died on LINK): the gate here is a CROSS-VENUE relative-price derivative that is invisible in any single venue's tape, and it is a CONTINUATION filter, not a reversal trigger. Data verified present in the catalog before proposing (L103): AVAXUSDT.BINANCE 4H and AVAXUSDT.BINANCE_SPOT 4H both span 2020-09-22 -> 2026-09-11 (~6 years, ~13,000 aligned 4H bars). AVAX is a top-30 perp with deep books on both venues and has no meaningful footprint in this corpus. Exactly 3 optimizable parameters. Risk profile: risk ~1.5% of equity per trade, position sized as risk_capital / (atr_mult * ATR) so notional is capital-relative off get_account_equity(); hard cap 30% of equity notional (i.e. <= 2x leverage on a 15% sleeve); no pyramiding; one position at a time.

Hypotheses

Implements the hypothesis exactly: the discriminator is the SLOPE of the cross-venue perp-spot basis over the same window as the price move, never its level, and it is used as a continuation filter (trade the trend when spot-led, stand flat when derivatives-led), not as a reversal trigger. Both the move and the premium expansion are z-scored against their own trailing distributions so one threshold means the same thing across AVAX's 2020-2026 volatility and funding regimes (fixed bps/percent constants stop firing when the regime shifts). The two series are kept in ONE aligned deque of (perp_close, smoothed_basis) tuples and the spot close is accepted only when its bar timestamp equals the perp bar's, so a missing or late spot bar can never manufacture a phantom premium the size of a full bar's move; the base template's same-timeframe barrier already defers the signal until the spot bar for that timestamp has arrived. Per-bar cost is O(1) (running sum / sum-of-squares rolling statistics, incremental ATR, incremental trailing extreme) so the ~13k-bar history is far inside the Layer-3 wall clock. Risk follows the hypothesis: 1.5% of equity per trade sized off the stop that actually exits (3*ATR chandelier), hard-capped at 30% of equity notional, one position at a time, no pyramiding. Venue: BINANCE USD-M perp because the strategy goes SHORT (a CASH spot account cannot); leverage is left at 1.0 and never read in sizing because a 30% notional cap needs no margin - declaring 2x would be inert. Per-trade expectancy: spot-led 4H trends ridden by a 3-ATR chandelier give 2-6% moves against a ~0.10% round trip, at roughly 30-60 entries a year. One note for the Research Lead: the gate's power depends on the perp-spot basis on Binance being large enough at 4H resolution to z-score cleanly (AVAX's basis is typically a few bps), so if the result is a null, the honest next test is the same gate on an 8H/1D clock where the premium signal-to-noise is higher, rather than a new mechanism.

Implementation

Long/short AVAXUSDT.BINANCE USD-M perpetual on 4H bars, trading the 4H-to-multi-day trend ONLY when the cross-venue perp-spot basis says the move was absorbed by real spot flow rather than financed by expanding perp premium. AVAXUSDT.BINANCE_SPOT 4H bars are a signal-only leg (no orders ever sent there) used to build basis_bps = (perp_close - spot_close)/spot_close * 1e4. Every bar the strategy recomputes two z-scores over the SAME lookback window: mom_z, the log price move divided by sd(1-bar returns)*sqrt(L); and slope_z, the change in the 3-bar-smoothed basis divided by the sd of that change's own trailing distribution. aligned = sign(mom_z) * slope_z measures whether the perp premium expanded WITH the move (derivatives-led, >0) or stayed flat/compressed (spot-led, <=0). The returned signal is mom_z times a continuous damping factor that is 1.0 for spot-led moves and ramps down to 0.15 as aligned approaches the gate, so the signal varies every bar and carries both direction and conviction. Entry: flat, cooldown elapsed, aligned <= basis_slope_gate_z (hard veto on derivatives-led moves), and |signal| >= entry_mom_z -> BUY/SELL. Exits: ATR chandelier trail (3 ATR from the highest high / lowest low since entry, detected intrabar, booked at the bar close), signal reversal past -0.5*entry_mom_z, and a 60-bar (10-day) calendar max hold; an 8-hour calendar-anchored cooldown after each exit prevents ping-ponging one episode. Sizing is capital-relative: equity*1.5% / (3*ATR), capped at 30% of equity notional, quantized down to the venue step, leverage 1.0. If the spot leg or either sd is unavailable the signal is 0.0 and nothing is opened - there is no price-only fallback. Exactly 3 optimizable parameters (trend_lookback_bars, entry_mom_z, basis_slope_gate_z) with declared bounds matching the in-code clamps.

Verification Results

Either set `self._hist = deque(maxlen=self.lookback)` (so the pre-append index 0 is bar t-L), or move the append above the read and index `self._hist[0]` afterwards. Then divide by sqrt(L) consistently with the window actually used.

Verification Results

Off-by-one in the lookback window. `self._hist` has maxlen = lookback + 1, and `c0, b0 = self._hist[0]` is read BEFORE `self._hist.append(...)`. Before the append the deque holds bars t-1 .. t-(L+1), so index 0 is bar t-(L+1), not t-L as the comment on line 178 claims. Both ret_l = log(close_t / c0) and d_basis = basis_sm_t - b0 are therefore measured over L+1 bars while mom_z is normalized by sd1 * sqrt(L). With the default lookback=9 the move is a 10-bar return divided by a 9-bar sigma scale, inflating |mom_z| by ~5.4% (sqrt(10/9)) and making the effective entry threshold ~1.04 sigma rather than the configured 1.1. The mechanism and the move/slope window-sharing (the hypothesis's central requirement) are intact -- both series use the SAME off-by-one window -- so this is a calibration inaccuracy, not a broken edge, and the optimizer will absorb it into entry_mom_z. It matters mainly for reproducibility and for reading the optimized parameter values honestly.

Verification Results

If the exit is meant to be gate-independent, test reversal on the raw `self._mom_z` (`if side > 0 and self._mom_z <= -rev`) instead of the damped `signal`. If the coupling is deliberate, state it in the docstring so the analyst does not read a long held through a -3 sigma reversal as an exit bug.

Verification Results

The signal-reversal exit is tested against the DAMPED signal (mom_z * damp), so the gate silently governs exits as well as entries. When a long is open and price reverses hard downward on a move whose perp premium is expanding with it (aligned > 0 for the new down direction), damp collapses toward the 0.15 floor and |signal| stays under the 0.5 * entry_mom_z hysteresis line -- the reversal exit cannot fire and the position is held through a derivatives-led selloff until the chandelier or the 60-bar max hold takes it. This is defensible as a design choice (the thesis says derivatives-led moves are fragile and mean-revert, so don't flip on them), and the ATR chandelier still bounds the loss, but the hypothesis describes the gate as an ENTRY discriminator only and says nothing about suppressing exits. Flagging so the behaviour is a deliberate, documented choice rather than an accident of reusing one number for both decisions.

Verification Results

Sandbox is weakly positive and unoptimized (Sharpe 0.285, PF 1.17, win 38.5%, +14.2% over 2013 days, Sharpe CI -0.55..1.11 straddling zero), so the basis-slope gate is unproven rather than refuted. Two specific things to check at backtest review: (1) DISCRIMINATOR POWER — split per-trade gross capture by the aligned bucket (aligned<=0 spot-led vs 0<aligned<=gate). If the spot-led bucket does not out-capture the damped bucket, the gate carries no information and the result is plain 4H z-momentum with a random 25% veto; the developer's own note that AVAX's 4H perp-spot basis is only a few bps means the slope may be mostly microstructure noise once z-scored. (2) REGIME SHAPE — the sandbox is positive in the calm (+9.8%) and stressed (+11.1%) vol terciles but NEGATIVE in the normal tercile (-6.3%, Sharpe -0.47), and every named crypto stress window except yen-carry-2024 and tariff-2025 is negative; a mechanism whose stated premise is about cascade fragility should be checked for whether its profit actually comes from the cascade regime or from two lucky trend years. Impact is 10.6% of gross at a $8.96M capacity — comfortable, not a constraint. None of this blocks: per-trade return 0.741% clears the 0.10% USD-M round trip by 7x and 301 trades over ~5.5 years is a measurable sample.

Backtest Review

Faithful implementation, 301 trades over 2013 days, max DD 7.8%.

Backtest Review

avg_trade_return_pct 0.741% vs ~0.10% USD-M round trip; commissions 3.05% of gross — NOT a fee-edge failure.

Backtest Review

Trade pattern (162L/139S, 38.5% win, 1.81 payoff) matches a trend-continuation profile.

Backtest Review

QA's discriminator concern CONFIRMED: bucketing every |mom_z|>=1.1 bar by the strategy's own `aligned` statistic, direction-adjusted 30-bar capture by year (spot-led vs vetoed derivatives-led) is 2021 +15.35/+5.73, 2022 -1.46/+2.28, 2023 +4.44/+2.11, 2024 -1.47/+1.29, 2025 -1.35/-0.16 — inverted in 3 of the last 4 years; the damped middle bucket (+1.05%) is the worst of the three, breaking the monotone ramp the code implements.

Backtest Review

2021 alone is +$21,697 of the +$23,856 realized total (91%); the other 253 trades net +$2,159 over five years. Top 5 of 301 trades = 136% of PnL. LONG leg nets +$327 over 162 trades.

Backtest Review

Sharpe 0.286, CI -0.52..1.08 straddles zero; negative in the normal vol tercile and in 5 of 7 stress windows — opposite of the cascade-fragility premise.

Backtest Review

Harness caution (not the basis of the verdict): daily_returns contains equal-and-opposite ±1.28%/±0.92% oscillations on a strict 4-day cadence during windows where the strategy holds no position and equity is provably flat (2025-08-14..08-31, 2024-03-18..04-06). Mechanism unverified; it depresses rather than inflates the reported Sharpe.
Strategy report

Backtest and paper results are hypothetical. Trading involves risk of loss.