Hypotheses
Quantiacs Futures Trend-Following (WMA200 / ROCP20 / 2% sideways band), faithful port on a 7-name OKX USDT-perp basket, daily, long/short, equal-weight across active legs
Faithful port of Quantiacs' MIT-licensed 'strategy-futures-trend-following' (strategy.ipynb, multi-pass `strategy(data)` function); credit to Quantiacs. The source's universe is the Quantiacs futures set. Our platform…
Strategies
- QuantiacsTrendFollowingOkxBasket Abandoned
Hypothesis
Faithful port of Quantiacs' MIT-licensed 'strategy-futures-trend-following' (strategy.ipynb, multi-pass `strategy(data)` function); credit to Quantiacs. The source's universe is the Quantiacs futures set. Our platform cannot trade CME futures, so the basket is OKX USDT perpetual futures with daily history back to at least 2021-01-24: BTC, ETH, SOL, ADA, LINK, BCH and TRX. OKX is under-represented in the corpus at 2.7%. RULES, identical per asset, computed on each asset's own 1-DAY close: ma = WMA(close, 200), a……Show moreShow less
Faithful port of Quantiacs' MIT-licensed 'strategy-futures-trend-following' (strategy.ipynb, multi-pass `strategy(data)` function); credit to Quantiacs. The source's universe is the Quantiacs futures set. Our platform cannot trade CME futures, so the basket is OKX USDT perpetual futures with daily history back to at least 2021-01-24: BTC, ETH, SOL, ADA, LINK, BCH and TRX. OKX is under-represented in the corpus at 2.7%. RULES, identical per asset, computed on each asset's own 1-DAY close: ma = WMA(close, 200), a TA-Lib linear-weighted moving average with weights 1..200, newest weight highest. roc = ROCP(ma, 20) = ma[t]/ma[t-20] - 1. sideways_threshold = 0.02. positive_trend = roc > 0.02; negative_trend = roc < -0.02; sideways = |roc| <= 0.02. side_positive_trend = the last non-sideways state was positive; side_negative_trend = the last non-sideways state was negative; both are False before any non-sideways bar. Position state machine per asset, a port of the xarray code: start at 0. On each bar, in this order: if positive_trend, raw = +1; if negative_trend, raw = -1; otherwise raw is unset. fp = the forward-filled previous position, taking raw into account. If side_negative_trend and fp > 0, raw = 0. If side_positive_trend and fp < 0, raw = 0. position = raw if set, else the previous position (ffill), initialised to 0. In effect the asset goes long when the WMA's 20-day change exceeds +2% and short when it is below -2%. While it is sideways the position is held. Note that a positive trend sets side_positive_trend, so a long can only be stopped by a negative regime, which already flips it short through sell_signal. The stop branches therefore rarely produce a flat state, and the developer must reproduce the source's ordering exactly rather than simplify it. WEIGHTS: output = position / sum(|position|) across the basket, so each non-flat asset gets ±1/N_active of the gross book and nothing is held when all are flat. PLATFORM ADAPTATIONS (not in the source): (1) Gross notional = account equity × leverage 1.0, so each active leg's notional = equity / N_active, signed. (2) Execution: Quantiacs applies day-t weights from the next day. On a 24/7 venue our `next_bar_open_fill` capability is `use_equivalent`, so orders are market orders at the signal bar's close, which equals the next daily bar's open. (3) The source rebalances to its target weights every day. To avoid paying taker fees on tiny drift trades, a leg is resized only when its target sign changes, N_active changes, or its notional drifts more than rebalance_tolerance (fixed at 20%) from target. This is the only rule added beyond the source. (4) The source has no stop-loss, and none is added; exits come only from the state machine. (5) OKX fees are 0.05% taker, about 0.10% round trip, and funding is applied through the ledger. WARM-UP: indicators need 200 + 20 bars. The registered warm-up is 360 daily bars, which also covers the tunable maximum of 300 + 40. This fixes the prior contract's 1825-bar warm-up, which was the source's 5-year `lookback_period` data window rather than an indicator requirement and exceeded the basket's joint history. The source's own performance claims are unverified; our backtest decides.
Analysis
strategy-futures-trend-following
Backtest and paper results are hypothetical. Trading involves risk of loss.