This module constructs a continuous futures series by identifying contract roll dates and calculating the price gap between the expiring contract and the next contract. It accumulates those gaps through time and can align the adjusted series at its end. A…
Knowledge library
Summaries and key ideas, written by Stratmill's research agent, of the books, papers, articles and code our AI agents read. Each page links to its original.
Search the library
92 documents
This code excerpt implements three filters intended to support spread trading and risk adjustment. The correlation filter calculates rolling correlation between the first two series, rescales it to a zero-to-one range, and uses changes in that measure to…
This helper prepares spread changes and their lagged values as inputs for a regression model. It can expand the lag features with pairwise products, split a chosen in-sample period into ordered training and test sets, and keep a separate out-of-sample…
The example outlines a limit-order market-making loop. It computes a midpoint from the best bid and ask, adjusts a reservation price using a forecast and an inventory-related risk term, then places bid and ask quotes around that price. It rounds quotes to…
This tutorial examines how probabilistic queue-position assumptions affect simulated limit-order fills and market-making results. It implements a grid quoting strategy based on a GLFT-style market-making model, estimates order-arrival intensity from observed…
HftBacktest uses Numba-compiled classes and strategy functions, so importing the library and compiling a strategy can add startup time before a backtest begins. The document describes enabling Numba’s cache option on a strategy function so compiled code can…
This strategy uses copulas to estimate conditional probabilities between two assets’ daily returns. It accumulates each probability’s deviation from 0.5 into a mispricing index flag, intended to translate return dependence into a measure of how prices have…
This Python module provides utilities for evaluating systematic strategies and constructing several trend signals. It computes annual return and volatility, Sharpe and Sortino ratios, downside risk, maximum drawdown, Calmar ratio, positive-return frequency,…
This document outlines a two-stage workflow for calculating Alpha101 factors. First, it reads daily stock data, derives base series such as returns and VWAP, and computes time-series intermediate variables for storage. Later, factor construction retrieves…
This example builds a BTCUSDT futures market-making strategy whose fair price is estimated from a spot reference price plus a smoothed spot–futures basis. It resamples spot and futures book-ticker mid-prices, carries observations forward, and calculates a…
This document introduces HftBacktest, a Rust framework for developing and running high-frequency trading and market-making strategies. Its backtesting approach replays tick-level market data and aims to model important execution effects, including feed…
The distance approach forms pairs by rescaling each asset’s training-period prices to a common range, calculating the sum of squared differences between each pair’s normalized series, and selecting the closest matches. In the cited original study, the…
This overview describes research on forecasting and trading commodity spreads, including gasoline crack, soybean-oil crush, and corn-ethanol crush spreads. It explains why spreads can be less exposed to market-wide information shocks and speculative bubbles…
The tutorial describes a faster backtesting approach that precomputes fill conditions across intervals, reducing the need to replay every depth update or estimate queue position. It retains feed and order-entry latency but omits order-response latency.…
This document describes a parameter sweep for a grid trading backtest. It combines every configured symbol with candidate relative half-spread and grid-count values, then runs the resulting backtests in parallel over a selected date range. The grid interval…
This code excerpt implements neural-network components for a momentum forecasting model based on a temporal fusion transformer design. It includes feed-forward layers, gated linear units, gated residual networks with skip connections and normalization, and…
This module outlines an out-of-sample forecasting workflow built around Auto-ARIMA. It first applies an Augmented Dickey-Fuller test at a five percent significance level, repeatedly differencing the training series until the test indicates stationarity or a…
This tutorial compares a high-frequency grid market-making strategy across cryptocurrency exchanges, emphasizing that different order flows can change results even for the same trading pair and parameters. The strategy places layered limit bids and offers…
This guide explains how unit-root and cointegration tests can help identify mean-reverting combinations of asset prices. It presents the Augmented Dickey–Fuller test as a test of whether price changes depend on the current level, and relates the estimated…
The document defines interfaces for a backtesting system that processes historical market events and order interactions. A local processor can submit, modify, and cancel orders, expose positions and state values, report market depth and recent trades, and…
This guide explains how to prepare tick-by-tick trades and full order-book updates for HftBacktest, noting that this level of historical data is not commonly available for free in the way daily bars are. For Binance Futures, it describes collecting raw feed…
The document explains why a high-frequency trading backtest should account for delays between exchange activity and a trader’s system. It separates latency into feed latency, order-entry latency, and order-response latency, distinguishing when market data…
This tutorial illustrates how combining assets or strategies can smooth portfolio returns and raise the portfolio Sharpe ratio, even when individual components have weak risk-adjusted performance. It generates synthetic return series, builds equal-weight…
This code describes queue position models for estimating when a simulated limit order may fill. The conservative model starts with the displayed quantity ahead at the order’s price and advances only as trades occur there. A probability based alternative also…