Skip to content
All strategies

Strategies

Country-ETF 36-Month Loser Reversal, Long-Only, 12 Overlapping Monthly Cohorts (8 USEQ single-country ETFs, DAILY bars) — faithful-mechanism adaptation of QuantConnect/Quantpedia country-index mean reversion

Outcome: Abandoned

CountryEtfLoserReversalCohorts

Outcome Summary

CountryEtfLoserReversalCohorts adapted a 19-country, 36-month long/short reversal rule to the 8 single-country ETFs in USEQ, dropping the short leg and using 12 overlapping monthly cohorts that each buy the two worst negative 36-month losers. The code implemented a custom cross-leg alignment barrier and O(1) deque-based formation returns, following the hypothesis's warning about sandbox timeouts. Even so, the run was abandoned after 2 iterations with reason 'coding_stuck_3_timeouts', so it never produced backtest metrics and never reached review, optimization or analysis.

Hypothesis

Source: QuantConnect Strategy Library #23 'Mean Reversion Effect in Country Equity Indexes' (Quantpedia), section 'Method'. Source rule: rank 19 country ETFs by 36-month return, long the bottom 4, short the top 4, rebalance every 36 months. AS WRITTEN IT IS NOT TESTABLE HERE: our USEQ universe has only 8 single-country ETFs (EWG, EWJ, EWT, EWU, EWY, EWZ, FXI, INDA), so bottom-4 plus top-4 is the whole universe, and a 36-month rebalance gives about 7 rebalances since 2000. The source's reported returns are treated……Show moreShow less

Source: QuantConnect Strategy Library #23 'Mean Reversion Effect in Country Equity Indexes' (Quantpedia), section 'Method'. Source rule: rank 19 country ETFs by 36-month return, long the bottom 4, short the top 4, rebalance every 36 months. AS WRITTEN IT IS NOT TESTABLE HERE: our USEQ universe has only 8 single-country ETFs (EWG, EWJ, EWT, EWU, EWY, EWZ, FXI, INDA), so bottom-4 plus top-4 is the whole universe, and a 36-month rebalance gives about 7 rebalances since 2000. The source's reported returns are treated as unverified. Adaptation that keeps the economic mechanism (long-horizon overreaction and valuation mean reversion at the country-index level): (1) drop the short leg, per L137 on neutral books and because the reversal premium in the literature sits mainly in the loser leg; (2) replace the single 3-year rebalance with 12 overlapping monthly cohorts in the Jegadeesh-Titman style, each held 12 months, which gives about 12x more independent formation dates; (3) the universe is defined by a point-in-time rule, not a list: every single-country ETF in the USEQ universe file that has at least 756 sessions of history at the formation date. INDA joins in 2015 and FXI in 2007. Each month, the cohort buys the 2 worst 36-month (756-session) total-price-return names, and only those with a NEGATIVE 36-month return; if fewer qualify, that cohort's slot stays in cash. Each cohort gets 1/12 of equity split equally across its names. Honest caveat for the analyst: this sits in the USEQ-daily family that L128 flags. It is proposed because the user's source mechanism cannot be expressed at 1H or on crypto (there are no country indexes, and a 36-month lookback on crypto's roughly 6-year history leaves almost no sample), so the priority is low and the predictions are modest. Implementation note, given the recent run of sandbox timeouts on 2400-day daily windows: keep a rolling deque or a precomputed close array per ETF and compute 756-session returns in O(1) per bar. Never rescan history in on_bar.

This is the hypothesis's Jegadeesh-Titman adaptation of the Quantpedia country-index reversal: long leg only, 12 overlapping monthly cohorts held 12 months, bottom 2 by 36-month return, negative-return filter, 1/12 of equity per cohort, point-in-time universe. The month is taken from the bar's own timestamp, so the schedule is the same across restarts, backtests and paper. Cohort holdings ({slot: {leg: shares}}), _last_month and _last_eval_ts are persisted state; the price deques are rebuilt on warmup. Alignment……Show moreShow less

This is the hypothesis's Jegadeesh-Titman adaptation of the Quantpedia country-index reversal: long leg only, 12 overlapping monthly cohorts held 12 months, bottom 2 by 36-month return, negative-return filter, 1/12 of equity per cohort, point-in-time universe. The month is taken from the bar's own timestamp, so the schedule is the same across restarts, backtests and paper. Cohort holdings ({slot: {leg: shares}}), _last_month and _last_eval_ts are persisted state; the price deques are rebuilt on warmup. Alignment rule: the base same-timeframe barrier is turned off, because a leg with no bars yet (INDA before 2012) would block every bar. It is replaced by an own barrier: a rebalance at session ts runs only when every active leg (last bar within 10 days) has delivered its bar stamped exactly ts. Ranks and fills therefore use contemporaneous closes, and no extra bar is newer than the decision time (L139). Per-bar cost is O(8): fixed deques of length lookback+1, and the 36-month return is last/first. There is no history rescan, so the sandbox timeout is not a risk (L106/L174). Gross is at most 0.98x equity against USEQ's 2x cap (L114). The 756-session warm-up exceeds the base's 500-bar buffer, so history lives in the strategy's own deques and min_bars_required is 1. Caveats for the analyst: (1) L175: overlapping cohorts on a NETTING account are booked per instrument as one position that is scaled in and out monthly. total_trades will be small and avg_trade_return_pct describes net holding periods, not individual cohorts; judge on the equity curve. (2) The sandbox's ~2400-day window leaves about 3.5 years after the 3-year warm-up, and the first year ramps cohorts in, so the trade count will be low. With only 8 names the sample is thin by construction (the same L128 concern the hypothesis flags).

coding_stuck_3_timeouts

Implementation

Long-only 36-month loser reversal on the 8 USEQ single-country ETFs (EWG, EWJ, EWT, EWU, EWY, EWZ, FXI, INDA), daily bars. On the first aligned session of each calendar month, cohort slot (month % 12) is re-formed. It buys the 2 names with the worst 756-session price return, and only if that return is negative; an unfilled slot stays in cash. Each cohort holds for 12 months and gets 1/12 of 98% equity, split into 2 equal name slots, sized in whole shares. The book target per ETF is the sum of cohort share counts, and each month only the net difference per ETF is traded: a BUY to add, a reduce-only SELL to trim, a full close when the target reaches 0. Eligibility is point-in-time: a name needs 757 closes of history in the run (INDA and FXI join late).

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 EWG.USEQ-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).

Outcome Summary

This complex, multi-leg, long-lookback daily-bar design never got through coding before hitting repeated timeouts, so a future iteration should start from a simpler, cheaper implementation that can produce a first backtest.

The strategy was abandoned at the coding stage with reason 'coding_stuck_3_timeouts', after 2 iterations. The backtest-review, analyst and risk-officer stages never ran.

A long-only adaptation of the Quantpedia country-index mean-reversion rule: each month, buy the 2 worst 36-month (756-session) performers among 8 USEQ single-country ETFs, only if their 36-month return is negative, and hold each of 12 overlapping monthly cohorts for 12 months.

There are no performance numbers. The backtest report is empty, no optimization ran, and there is no return, Sharpe or trade count.

Analysis

Mean Reversion Effect in Country Equity Indexes

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