Skip to content

View original

DefiVsL1SectorMomentumBasketRotationLongShort

Hypotheses

DeFi vs L1 Sector Long-Short Momentum Basket Rotation (Weekly)

Hypotheses

A DOLLAR-NEUTRAL CROSS-SECTOR MOMENTUM ROTATION strategy: two 2-instrument baskets (DeFi/infra: LINK + AAVE; L1 majors: BTC + ETH) where the strategy ROTATES which sector to long vs short based on trailing 4-week relative momentum. RATIONALE driven by the now-DEFINITIVE session finding: 14+ strategy attempts across 5 mechanism categories have all failed. The analyst's most recent calibration update explicitly acknowledges 'EVERY class-level pattern extraction I have made this session has been wrong' and identifies remaining genuinely-untested categories. This proposal explicitly answers the analyst's explicit recommendation: 'Statistical arbitrage on sector baskets (long DEX-token basket vs short L1-token basket as a single position)' — a TRULY untested mechanism in this session. KEY DIFFERENTIATION from the 4 falsified cross-asset pairs (ETH/BTC, BNB/ETH, SOL/ETH, LINK/ETH): (a) MULTI-INSTRUMENT per side — 2 DeFi instruments vs 2 L1 instruments — internal diversification within each leg dilutes the single-asset asymmetry that killed all pair MR strategies. (b) MOMENTUM-based, NOT mean-reversion — the strategy ROTATES to whichever sector has been outperforming, betting on momentum persistence; this is structurally different from MR which assumes drift reverses. (c) SECTOR-vs-SECTOR thesis — instead of betting two assets revert to each other, the strategy bets that the OUTPERFORMING SECTOR continues outperforming (academic momentum literature: Asness/Frazzini/Pedersen). (d) WEEKLY rebalancing — low frequency, fee-friendly, captures cross-sectional sector trends documented in equity factor models. (e) ZERO supplementary data dependency. (f) MAXIMALLY SIMPLE — 1 decision parameter (momentum lookback weeks=4). DIFFERENTIATION FROM L1 BASKET (in pipeline): L1SectorBasketCrossSectionalMomentumLongShortDaily ranks WITHIN one sector (5 L1s); this strategy ranks BETWEEN two sectors. Different signal, different math, complementary diversification.

Hypotheses

Iteration-6 fix targets the reported backtest-gate failure only: 'Sharpe 0.09 disagrees in sign with total_return -13.89%'. Both figures are derived from the SAME mark-to-market equity curve in runner.py, so a positive mean daily return with a negative compounded return is volatility drag (mu - sigma^2/2 < 0), i.e. the book carried far more per-bar variance than its edge justified. Two structural causes are fixed without touching the momentum ranking, the calendar anchor, the O(1) synced buffer, or the imports/structure that already cleared Layers 1-3: (1) legs were entered once and never re-sized, so only a sector flip ever touched them — a winning leg compounded while its short shrank and the 'neutral' basket accumulated a large net delta whose variance swamped the sector spread; the weekly rotation now issues delta market orders (NETTING OMS) to bring each same-side leg back to the shared target notional when it drifts past rebalance_band, which is exactly what 'weekly rebalancing' means in the hypothesis and also realizes PnL periodically instead of leaving it unrealized for years. (2) gross_exposure drops 0.95 -> 0.60 (declared bounds 0.30-0.90): drag scales with exposure squared while the mean scales linearly, so the compounded return now follows the sign of the per-trade edge. Note honestly: a Sharpe of 0.09 means the sector-momentum spread showed little edge in the last run, and lower variance makes the metrics coherent rather than manufacturing an edge — if the next backtest is coherent but flat, the mechanism itself is falsified.

Hypotheses

Negative expectancy on a reliable 324-trade / 6.7-year sample: avg_trade_return_pct -0.28% (below ZERO), profit_factor 0.94, total_return -13.67%, Sharpe -0.010 (CI [-0.76, 0.74] straddles zero), expectancy -$63/trade with avg_loss (2156) exceeding avg_win (2109). The trades correctly implement the hypothesis (dollar-neutral, balanced 162 long / 162 short, weekly rebalance), so this is a FAIR test of the DeFi-vs-L1 sector-momentum-persistence premise — and the premise is measurably falsified: there is no positive gross edge, and returns are regime-dependent (normal tercile -33.1%, stressed +31.4%, regime_spread 1.35) rather than a stable sector spread. Commission is only 1.5% of gross with fee-friendly weekly turnover, so this is NOT fee-fragility — the signal is gross-negative. The single real decision parameter (lookback) cannot invert a PF-0.94, below-zero-expectancy signal; there is nothing to optimize toward. This is the 6th iteration and the developer pre-committed that a coherent-but-flat/negative result falsifies the mechanism — that outcome is now observed. Matches the multi-instrument long-short basket class prior (L45/L63, multi_instrument ~0/84): the book-level result is regime beta, not per-sector edge. Not worth 2 hours of optimization. abandon_class=negative_expectancy.

Implementation

Dollar-neutral cross-sector momentum rotation on BINANCE USD-M daily bars. Two 2-instrument baskets (DeFi: LINKUSDT+AAVEUSDT; L1: BTCUSDT+ETHUSDT). On a calendar-anchored weekly grid (epoch-day index divisible by rebalance_days), each basket's trailing 28-day mean member return is compared; the strategy goes long both members of the outperforming sector and short both members of the underperforming one, equal notional per leg. The weekly rotation now also re-equalizes every surviving leg back to the common target notional whenever it has drifted more than rebalance_band off it, so the book stays dollar-neutral instead of compounding into a net directional position, and gross exposure is capped at 0.60 of equity.

Verification Results

Clarify the hypothesis text/title to read 'weekly rebalancing on daily bars' so the Layer-1.5 string heuristic and future QA passes do not re-flag it. No code change needed.

Verification Results

Hypothesis title says '(Weekly)' and the pipeline consistency check flagged config.bar_type = BTCUSDT.BINANCE-1-DAY-LAST-EXTERNAL as contradicting a weekly timeframe. On inspection the hypothesis's mechanical claim is WEEKLY REBALANCING (not weekly bars): it specifies 'weekly rebalancing' and 'lookback weeks=4'. The code implements exactly that via a 7-day calendar-anchored rotation grid (rebalance_days=7) with a 28-day momentum lookback on daily bars, and the daily bars are structurally required for the per-bar _reconcile step (a flipped leg re-enters on the very next daily bar). The weekly-rotation semantics, instruments, direction, sizing and core edge all match the hypothesis, so this is a labeling discrepancy, not a mechanism swap or broken signal. Not blocking.

Verification Results

Confirm the base FactoryStrategy honors a subclass min_bars_required override for warm-up gating; if it does not, warm-up is instead guaranteed by the len(self._synced) >= lookback+1 guards inside _sector_momentum/calculate_signal, which already prevent premature signals.

Verification Results

min_bars_required(self) overrides the framework method (static analyzer base_shadow warning). It returns lookback_days+2, which is a sensible warm-up requirement for the momentum window, so the override appears deliberate and correct rather than accidental shadowing.

Verification Results

Sandbox smoke test is negative (total_return -13.67%, Sharpe -0.006, avg_trade_return_pct -0.28%, PF 0.96) and this is the 6th iteration whose changes target volatility drag / dollar-neutrality drift rather than establishing edge. The developer honestly notes 'if the next backtest is coherent but flat, the mechanism itself is falsified.' Metrics are now internally coherent (sign of Sharpe matches return), which was the point of the fix, but there is no positive gross edge visible yet. Regime split shows the return is regime-dependent (normal tercile -35.5%, stressed +31.6%) rather than a stable sector-momentum spread. Analyst should judge on full-history + optimized numbers; if the coherent result is flat/negative, this is a falsified premise, not a fee problem (commission only 1.4% of gross, weekly turnover is fee-friendly).

Backtest Review

Trades faithfully implement the hypothesis: dollar-neutral, balanced 162 long / 162 short across the two sector baskets, weekly rebalanced — this is a fair test of the sector-momentum premise, not a broken mechanism.

Backtest Review

Fee-friendly by construction: commission only 1.5% of gross, weekly turnover — the failure is NOT a fee problem.

Backtest Review

Metrics are now internally coherent (Sharpe sign matches total_return), so the iteration-6 volatility-drag fix worked mechanically.

Backtest Review

Negative expectancy on a decisive 324-trade / 6.7-year sample: avg_trade_return_pct -0.28% (below ZERO), profit_factor 0.94, total_return -13.67%, expectancy -$63/trade, Sharpe -0.010 (CI [-0.76, 0.74] straddling zero).

Backtest Review

No positive gross edge: avg_win 2109 < avg_loss 2156, win_rate 0.49 — the sector-momentum spread does not persist. The 'edge' is regime-dependent noise, not a stable signal: normal tercile -33.1% vs stressed +31.4%, so the result flips sign with regime rather than being a repeatable cross-sector spread.

Backtest Review

6th iteration; the developer explicitly pre-committed that a coherent-but-flat/negative result falsifies the mechanism — that is now the observed outcome. The 1 real decision parameter (lookback) has nothing to tune toward: the signal is gross-negative.

Backtest Review

Matches the multi-instrument long-short basket class prior (L45/L63, multi_instrument ~0/84): book-level return is regime beta, not per-name/per-sector edge.

Analysis

Backtest gate: - metrics unreliable: Incoherent: Sharpe 0.09 disagrees in sign with total_return -13.89% — the Sharpe is computed from the mtm_equity_curve series while the return comes from the equity curve. Judge on the equity curve.

Iteration History

Verification failed (Layer 4 — QA review) [class=code_defect]: - [edge_concern] Secondary to the blocking defect: the sandbox is negative (total_return -17.0%, Sharpe 0.04, PF 0.97, avg_trade_return_pct -0.061%, max_drawdown 40.9% CI to 80.8%) and market-neutral by construction — no evidence the rotation clears costs. But this isn't why it's blocked, and it should be re-judged on a corrected implementation since the current rotation dates are themselves an artifact of the uptime-anchored schedule. - The weekly rebalance is driven by a PROCESS-RELATIVE BAR COUNTER with a -(10**9) sentinel — the exact anti-pattern item 18 flags critical for rotation strategies. `self._signal_bar_count += 1` then rebalance when `(_signal_bar_count - _last_rebalance) >= rebalance_days` with `_last_rebalance = -(10**9)`. Uptime-anchored, not calendar-anchored: (1) fires a full 4-leg rebalance on the first bar after every restart (1 - (-1e9) >= 7 instantly), so a live crash-restart loop churns the whole book; (2) the weekly grid is pinned to process start, not the bar date, so rotation dates float and parity/replay can never reproduce them. For a strategy whose only edge is WHEN it rotates, this is disqualifying. - _last_rebalance is set on the very first call even though _rebalance() returns early (no aligned history), so the first real trading rebalance — and the whole weekly grid — is offset from an arbitrary bar. Fixed automatically once the schedule moves onto the bar timestamp.

Iteration History

Verification failed (Layer 1 — config): config.instrument_id and config.bar_type are REQUIRED (got instrument_id=None, bar_type=None). Set both to the hypothesis's instrument, e.g. instrument_id='BTCUSDT.BINANCE', bar_type='BTCUSDT.BINANCE-4-HOUR-LAST-EXTERNAL'.

Iteration History

sandbox_timeout: Verification failed (Layer 3 — sandbox backtest): smoke test exceeded the 300s wall-clock limit on a ~20000-bar window (2400 days of BTCUSDT.BINANCE-1-DAY-LAST-EXTERNAL). This almost always means per-bar work that scales with history — e.g. rescanning the full funding/supplementary series, or rebuilding a list and calling min()/sorted() inside calculate_signal()/on_bar() on every bar. Precompute sorted timestamp arrays ONCE in __init__ and use bisect, or cache lookups keyed by timestamp, so per-bar cost is O(log n) not O(n).
Strategy report

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