Betric — Portfolio Project by Muhammad Daffa Ashdaqfillah

A Bitcoin direction experiment with XGBoost and a companion iOS prototype. A chronological holdout and a cost-adjusted simulation exposed the model's limits.

Betric — Portfolio Project by Muhammad Daffa Ashdaqfillah

Published on April 30, 2026

Project Details

Betric’s iOS prototype and original experiment. The write-up below covers the separate 120-minute model.
Betric’s iOS prototype and original experiment. The write-up below covers the separate 120-minute model.

I started Betric to see whether recent Bitcoin price and volume could help predict where the price would close an hour or two later. I built the training and evaluation pipeline, tried several definitions of an upward move, and exported the selected model. The 120-minute classifier picked up a small signal on held-out data. The strategy I tested in simulation showed a near-total loss after costs.

What the candle history could support

The experiment loaded 7,515,048 one-minute candles from January 2012 through April 2026. After sorting and deduplicating the timestamps, I found a 19-hour gap. The notebook inserted 1,160 synthetic minutes to keep the time index regular, carried forward the last close, and flagged windows that encountered the missing data. It screened those windows out when constructing the labeled dataset.

Every five minutes, the pipeline built an overlapping OHLCV bar from the preceding 180 minutes. I removed raw price and volume levels before fitting. The 249 inputs included ATR divided by the close, distance from moving averages as a ratio, rolling volume z-scores, and log returns and volatility over windows from 15 minutes to 24 hours. I added lagged values and interactions such as RSI deviation in high-volatility regimes.

For the 60-minute target, I graphed the monthly share of up labels and quarterly return volatility, then checked feature-to-target correlations and pairs of features with absolute correlation above 0.95. I compared early and late feature distributions with the Kolmogorov–Smirnov statistic. Distance to the 60-minute high had a statistic of 0.133, one sign that the input distribution moved over time.

Choosing a prediction target

A simple direction label counts any positive future close-to-close return as up. I also explored raising the positive threshold from 0.05% to 0.20%, and dropping examples whose absolute return was below 0.10%. At 30 minutes, a 0.10% positive threshold reduced the up class from 49.57% to 35.08%. Dropping small moves instead reduced the usable sample count to 990,428 while keeping the classes roughly even.

I tuned the three direction candidates with 30 Optuna trials each. The saved run resumed from a manually selected shortlist after an interrupted walk-forward grid. The numbers below come from the final validation fold of each Optuna study. The sample counts are for the full labeled data before splitting.

Forecast horizonLabeled rowsUp labelsBest validation balanced accuracy
30 minutes1,450,80149.57%53.30%
60 minutes1,450,78950.33%53.53%
120 minutes1,450,76551.00%54.29%

Tuning, calibration, and the holdout

Betric evaluation sequence. Build rolling features, tune XGBoost, fit the probability calibrator, then score the chronological holdout.
Betric evaluation sequence. Build rolling features, tune XGBoost, fit the probability calibrator, then score the chronological holdout.

The selected XGBoost classifier used a binary logistic objective. Optuna varied depth, learning rate, row and column subsampling, L1 and L2 penalties, and minimum child weight. Its selected configuration capped training at 887 trees with depth 8 and a learning rate of 0.0266. Training used log loss with early stopping, and positive examples were weighted using the training split’s class ratio.

The 120-minute candidate had the highest tuning score. I held out the latest 15% of its labeled rows, or 217,615 examples. A 60-row embargo, equivalent to five hours at the sampling cadence, separated the preceding fit and calibration data from the holdout. An earlier slice provided early stopping, decision-threshold selection, and sigmoid calibration. Both holdout columns use the selected threshold of 0.50.

Holdout metricRaw modelAfter calibration
Accuracy52.08%52.13%
Balanced accuracy52.08%52.11%
ROC AUC0.52750.5275
F1, up class0.52630.5322
Log loss0.69440.6935
Brier score0.25060.2502

Calibration made a small improvement to probability error while leaving ranking performance unchanged. At 52.11%, balanced accuracy was only 2.11 percentage points above a one-class prediction on a balanced basis.

The trading simulation

The notebook mapped calibrated predictions to long or short positions and lagged positions by one sampled row. It subtracted 0.04% in fees and 0.02% in slippage whenever the simulated position changed.

Simulation outputResult
Turnover events counted by the notebook31,214
Rows with positive net return51.01%
Simulated net return−99.999964%
Maximum drawdown≈ −100%

The simulator compounded 120-minute returns sampled every five minutes, so successive return windows overlap. The drawdown is an output of that setup and cannot be read as the loss of an executable portfolio. Given that limitation and the weak holdout result, I treated this run as a failed strategy experiment.

From a notebook to an app

The notebook saved the raw and calibrated estimators as Python artifacts and exported the raw booster to ONNX with its feature order. The SwiftUI prototype followed a separate integration path. It fetched Binance candles, computed and ordered features in Swift, and ran a bundled XGBoost model through ONNX Runtime. The app's bundled model is a different artifact from the 120-minute model evaluated above.

The Next.js prototype displays market data, predictions, and history from a local API. These two interfaces let the project explore what an inference contract looks like in an app, down to feature order, tensor shape, and the difference between a model score and an observed outcome.