The method selects hedge ratios for a basket spread by minimizing the absolute estimated half-life of mean reversion. It treats one price series as the target and the remaining series as explanatory assets, forming the spread as the target minus their…
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
765 documents
A user reports that a VeighNa spread backtest loads no data after changing an example notebook from bar mode to tick mode. The database’s tick overview shows records for both futures legs, but debugging finds no rows when the SQLite query filters by a leg’s…
The document introduces stationarity and cointegration as the basis for pairs trading. It describes a stationary series as having a stable mean and variance, and presents a pair as cointegrated when the difference between their prices is stationary. Under…
The article examines three futures strategies in China’s oilseed complex: soybean crush spreads, soybean oil versus palm oil substitution spreads, and soybean oil versus soybean meal companion spreads. It outlines the production and consumption logic behind…
The document explains a threshold-selection method for pairs trading when the modeled log price follows an Ornstein–Uhlenbeck process. It builds on earlier work by deriving expressions for the expected first-passage time with two-sided boundaries, then uses…
This overview contrasts efficient markets, where prices are assumed to incorporate available information, with inefficient markets, where prices may diverge from estimated value. It outlines the weak, semi-strong, and strong forms of the efficient market…
This example describes a mean-reversion strategy for two SHFE futures contracts. It uses a Kalman filter to update the hedge ratio between the instruments, calculates the resulting spread, and standardizes it against a rolling window to create a z-score. The…
This document outlines a daily strategy for trading a set of assets using a cointegration vector estimated with the Johansen method on training data. It applies the vector to log prices to form a combined process, then sums its recent changes to determine…
A VeighNa forum discussion explains how to preserve variables in a spread trading strategy across restarts. The suggested approach is to implement JSON file loading and saving in the strategy lifecycle: load stored values when the strategy starts and write…
The strategy tracks the daily price difference between continuous WTI and Brent crude futures and compares it with a 20-day simple moving average. When the spread is above its average, it takes positions intended to profit from a decline toward that…
This module describes an interactive dashboard for examining two-asset pairs through cointegration tests and mean-reversion models. Its analytics include Engle–Granger and Johansen portfolio construction, augmented Dickey–Fuller results, cointegration…
The article introduces time series concepts for financial analysis, including univariate and multivariate data, stationarity, autocorrelation, trend, seasonality, and decomposition. It describes using ACF and PACF to examine lag dependence, and outlines a…
This implementation describes a pairs strategy that estimates conditional probabilities from a fitted copula applied to each asset’s return ranks. It converts prices to returns, maps returns through marginal cumulative distribution functions, and uses the…
This example describes a two-stock pairs strategy based on the assumed long-term relationship between securities. It regresses one stock's price on the other's, then standardizes the regression residual using its recent mean and standard deviation. When the…
The method searches for hedge ratios that make a portfolio spread more stationary according to the Augmented Dickey–Fuller (ADF) test statistic. It defines the spread as the target asset’s price series minus a weighted sum of the other price series, then…
The Spread Oscillator compares two selected symbols by first forming a normalized price ratio: the first symbol’s close divided by the second symbol’s close, scaled by one hundred. It then computes exponential moving averages of that ratio using configurable…
This forum exchange addresses why a spread-trading algorithm may submit orders marked as opening even when the strategy intends to close a position. A trader observes that closing a long spread appears to send orders in the opposite directions, which raises…
The code implements a Cox–Ingersoll–Ross model for a mean-reverting portfolio, extending an Ornstein–Uhlenbeck model interface. It supports fitting the model to portfolio prices or to two assets, and estimates the long-run mean, reversion speed, and variance…
This implementation models a spread as a collection of instrument legs, with separate multipliers for calculating its quoted price and translating spread quantities into leg quantities. It combines leg bid and ask prices, reversing which side is used for…
This document explains how to build a multi-contract strategy using synchronized bar data, per-leg targets, and order management. Its example computes the spread between two weighted contract prices, updates a rolling window, and uses Bollinger Bands to…
The document describes a two-leg spread strategy built around Bollinger Bands. It calculates a weighted price difference between two contracts, samples the spread on a five-minute schedule, and compares it with a rolling mean and standard deviation. A move…
This guide explains execution algorithms that divide large orders, react to market prices, and adjust positions on a grid or across a spread. It describes time-weighted execution, iceberg orders, a tick-driven sniper approach, conditional orders, and…
This document describes a graphical interface for defining and monitoring spread trades. Users can create standard or flexible spreads, specify leg instruments and directions, set a pricing formula, identify an active leg, and enter minimum trade volume. The…
This strategy forms a spread from two instruments’ bar closes, weighted by configurable leg ratios. It updates the spread at five-minute intervals, keeps a rolling history, and calculates a moving average with upper and lower bands based on the spread’s…