Models
{{ models|length|apnumber|capfirst }} models, from the benchmark itself to gradient-boosted trees. Each one turns a price history into a forecast path with an {{ level }}% interval, and none of them sees a price after the forecast date.
-
{% for model in models %}
- {{ model.name }} {{ model.family }}
- {{ model.summary }}
Chronos-Bolt
Chronos-Bolt, Amazon's pretrained forecasting model, is an optional extra because it needs PyTorch. Install it
with uv sync --extra foundation and it joins every backtest. It forecasts without being fitted to
the stock: it learned from a large collection of other time series. It makes runs about three times as long.
Volatility
The volatility backtest forecasts how much the price will move over the next h trading days, in either direction: the variance of the h-day return. Naive here assumes the last month's volatility carries on.
-
{% for model in volatility_models %}
- {{ model.name }} {{ model.family }}
- {{ model.summary }}
Adding a model
Subclass Model in backcast/models.py, return a Forecast with the median
path and its quantiles from 10% to 90%, and add an instance to MODELS. The backtest, leaderboard and
charts pick it up. Every forecast must be a positive price, with the quantiles in increasing order; working on
log prices, as the models here do, guarantees both. A model that is slow to estimate can implement
fit instead, which returns a forecaster that keeps its estimates between refits.
class Average(Model):
key, name, family = "average", "Historical average", "Baseline"
summary = "Forecasts the average log price of the whole history."
def forecast(self, y, h):
log_y = np.log(y)
median = np.full(h, np.exp(log_y.mean()))
return Forecast(median, median * np.exp(Z * log_y.std(ddof=1))) # Z: one row per forecast quantile