Skip to content
All hypotheses

Hypotheses

Faithful port of QuantConnect BasePairsTradingAlphaModel: BTC/ETH price-ratio band reversion vs a 500-bar EMA of the ratio, ±1% bands, 1-day insight hold, alternating direction (OKX USDT swaps, DAILY)

This states QuantConnect LEAN's BasePairsTradingAlphaModel faithfully (Apache-2.0, credit: QuantConnect Corporation,…

Hypothesis

This states QuantConnect LEAN's BasePairsTradingAlphaModel faithfully (Apache-2.0, credit: QuantConnect Corporation, https://github.com/QuantConnect/Lean/blob/856327ff33869cba98393781000c4ab1d2af423d/Algorithm.Framework/Alphas/BasePairsTradingAlphaModel.py). The source is a complete, tradeable pairs rule, not a utility library. Its has_passed_test() returns True, so the base model trades every pair in its universe with no cointegration test. We run it on ONE pair: the BTCUSDT.OKX and ETHUSDT.OKX USDT perpetual……Show moreShow less

This states QuantConnect LEAN's BasePairsTradingAlphaModel faithfully (Apache-2.0, credit: QuantConnect Corporation, https://github.com/QuantConnect/Lean/blob/856327ff33869cba98393781000c4ab1d2af423d/Algorithm.Framework/Alphas/BasePairsTradingAlphaModel.py). The source is a complete, tradeable pairs rule, not a utility library. Its has_passed_test() returns True, so the base model trades every pair in its universe with no cointegration test. We run it on ONE pair: the BTCUSDT.OKX and ETHUSDT.OKX USDT perpetual swaps. OKX is 0.3% of the corpus against BINANCE's 67%, and both legs have daily history from 2020-01-02. Pair order follows the code. Symbols are sorted, so asset1 = BTCUSDT.OKX, asset2 = ETHUSDT.OKX, and ratio = close(asset1) / close(asset2) = BTC/ETH. Default parameters, exactly as written: lookback = 1, resolution = DAILY, threshold = 1 (percent). Derived values: prediction_interval = 1 day; mean = EMA(500) of the ratio (the 500 is hard-coded); upper = mean x 1.01; lower = mean x 0.99. Identity indicators on the daily closes feed the ratio and EMA. There is no signal until the EMA(500) is ready, which is about mid-May 2021. State machine: the pair starts FLAT_RATIO. It never re-emits the direction it is already in, and it never resets to flat. It only toggles when the opposite band is crossed. Naming quirk: the code calls the ratio > upper case 'LONG_RATIO' but trades it as SHORT asset1 / LONG asset2. Translate the actions, not the enum names. Insights last prediction_interval = 1 day. Under LEAN's default EqualWeighting portfolio construction, targets go to zero when insights expire. So each trade is held for one daily bar, and the book is flat until the next toggle. Sizing: each leg = 50% of equity, leverage 1.0, dollar-neutral. OKX fees are 0.02% maker / 0.05% taker per leg. Point-in-time pre-study on our catalog: 19 toggles in about 5.3 years. The mean next-day spread return was about +0.11% per trade, with standard deviation about 1.5% (t ≈ 0.3). That is about the same as the round-trip cost. The book is expected to be flat about 99% of the time.

Analysis

BasePairsTradingAlphaModel

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