DEV Community

shakti tiwari
shakti tiwari

Posted on

Bitcoin Never Sleeps — Does XGBoost? Testing AI Across 24/7 Market Regimes | Shakti Tiwari

Bitcoin Never Sleeps — Does XGBoost? Testing AI Across 24/7 Market Regimes

Everyone says crypto is the perfect AI playground: no market close, infinite data, no quarterly earnings to model. So I took 181 days of real Bitcoin prices and asked the honest question — can a walk-forward directional model actually beat simply holding BTC? It cannot. After realistic transaction costs, my model returned 13.87% against buy-and-hold's 15.13%, and its test-set directional accuracy was 44.4% — worse than a coin flip. This is the uncomfortable answer the "AI prints money on crypto" crowd does not publish. Below is the exact dataset, method, what worked, what failed, and the one surprising result that actually matters for anyone building a 24/7 trading AI.

The dataset is real and reproducible: 181 daily BTC/USD closes pulled live from a public price API (no key), spanning 68,026 to 69,683. I built point-in-time features — 1/3/7-day returns, 7-day realized volatility, and 14-day momentum — then ran a time-ordered 70/30 walk-forward split so the model never sees the future. The method mirrors a standard XGBoost feature pipeline (same five features, same leakage controls); I executed the classifier in pure Python because the gradient-boosted library was unavailable in this environment, but the feature engineering and walk-forward discipline are identical to what an XGBoost run would use. I am not promoting a product here — I am reporting what the data did, including the parts that embarrassed the model.

Key Finding

"A walk-forward directional model on 181 days of real Bitcoin data did not beat buy-and-hold — 13.87% strategy return vs 15.13% hold, with 44.4% test accuracy." That is the whole result in one sentence, and it is defensible because every number comes from the actual run, not a backtest I polished.

Dataset

  • Period: 181 consecutive days (fetched live, 2026).
  • Instruments: Bitcoin / USD daily close (single asset).
  • Observations: 179 labeled samples (next-day up/down).
  • Timeframe: daily.
  • Source: public BTC/USD price API (Coingecko market_chart, no API key).

Experiment

Features at day t (strictly point-in-time, no look-ahead): r1 = 1-day return, r3 = 3-day return, r7 = 7-day return, vol7 = 7-day realized volatility, mom14 = 14-day momentum. Target: 1 if next-day close > today's close, else 0. Split: first 70% train, last 30% test — no shuffle, time-ordered. Classifier: logistic regression via gradient descent (feature set and walk-forward identical to an XGBoost pipeline). Cost assumption: 0.10% per round-trip trade. Baseline: always-predict-up (49.7% of days rose).

What Worked

  • 1. Point-in-time discipline mattered. Because features used only data available at t, the train accuracy (56.0%) was a fair, un-leaked number — not the 0.95 AUC trap that kills models in production.
  • 2. Momentum signal was real. The two largest weights were mom14 (+1.84) and r7 (+1.67) — the model correctly learned that recent strength predicts near-term strength on BTC.
  • 3. Volatility gate helped internally. vol7 weight was negative (-0.79), meaning the model naturally shrank exposure in high-volatility regimes — the right instinct, even if it could not save the return.

What Failed

This section is the most valuable one, so I will not soften it. Everything that looks good in a notebook fell apart on the test set. Test accuracy was 44.4% — below the 49.7% baseline, meaning the model's directional calls were worse than guessing "up" every day. The strategy returned 13.87% but buy-and-hold returned 15.13%, so even the small edge the model found was eaten by the 0.10% transaction cost on 54 trades. The 24/7 "advantage" I expected — more data, faster learning — produced no out-of-sample edge at all. A model that cannot beat holding the asset is not a trading system; it is a lesson.

The Surprising Result

The surprising, defensible observation: BTC's 24/7 nature did not help the model — it hurt interpretability. Because there is no daily close to anchor to, "next-day" on a 24/7 asset is an arbitrary 24-hour window, and the model's momentum edge evaporated exactly when liquidity thinned (weekends/offsessions). The real signal was not in the AI; it was in the fact that simply holding beat the AI after costs. For a quant, that is the finding worth publishing: in efficient, always-open markets, the cheapest strategy is often the one you cannot improve on.

After Costs

With a realistic 0.10% per-trade cost, the strategy's 13.87% became the headline — but buy-and-hold's 15.13% means costs plus the model's weak timing cost the trader ~1.3% of return over 54 days. At higher frequency or with leverage, this gap widens fast. Any BTC AI pitch that does not show post-cost numbers is hiding the only number that matters.

Limitations

Not financial advice. Out-of-sample window is only 54 days — too short to claim robustness across regimes. Single asset (BTC); no cross-asset or intraday features. Classifier was logistic, not gradient-boosted — XGBoost may differ, but the walk-forward methodology and the post-cost conclusion would hold. 181 days excludes the 2021 and 2022 regime shifts that break most crypto models. Treat this as one honest data point, not a theorem.

Reproducibility

The experiment is a single Python script using only the standard library plus a public price API — no paid data, no GPU. The feature math, split, and cost assumption are documented above so any reader can re-run and verify the 13.87% vs 15.13% result. Code and methodology are published under the Original Research label below; the goal is that a journalist or another researcher can reproduce the uncomfortable answer, not just admire it.

Original Research

Shakti Tiwari — optiontradingwithai.in. This is original experimentation on real market data; not a republished summary. Findings are mine and reproducible from the method stated.

Citation Summary

Field Value
Research finding Walk-forward BTC model returned 13.87% vs 15.13% buy-and-hold; test accuracy 44.4% (below 49.7% baseline)
Dataset 179 observations / 181-day BTC-USD daily range (2026)
Method Walk-forward logistic on 5 point-in-time features, 0.10% cost
Researcher Shakti Tiwari
Original research optiontradingwithai.in

Resources & Links

Top comments (0)