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
121 documents
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…
This method estimates portfolio weights for a spread using the Box–Tiao canonical decomposition. It first reorders the price columns so the selected dependent asset comes first, demeans the data, and fits a first-order vector autoregression. It combines the…
This implementation explains how a bivariate Gaussian copula represents dependence between two variables after their observations have been converted to uniform pseudo-observations. It estimates the dependence parameter by mapping those observations through…
This code implements a collection of cross-sectional and time-series equity alpha factors, mainly using close, open, high, low, volume, returns, and VWAP data. The factors combine operations such as rolling ranks, correlations, moving averages, extrema, and…
This code module outlines methods for constructing sparse portfolios intended to exhibit mean reversion. It includes Box–Tiao canonical decomposition, greedy support selection, semidefinite optimization under volatility constraints, and sparsity methods…
The document describes a software implementation of the Johansen cointegration method for forming mean-reverting portfolios from asset prices. It computes cointegration vectors, orders them by eigenvalue, and converts each vector into hedge ratios normalized…
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 module implements analytical trading calculations for an Ornstein–Uhlenbeck mean-reverting process, following a published statistical-arbitrage model. Given an entry threshold, an exit threshold, and transaction costs, it computes expected trade length,…
This tutorial develops bivariate copulas as a way to describe dependence separately from the marginal distributions of two variables. It defines tail dependence and the Fréchet–Hoeffding bounds, then explains how an empirical copula can be estimated from…
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 document is a historical price table for a broad set of country and regional exchange-traded funds. It lists dates alongside one price series for each ETF, with examples spanning markets such as Japan, Brazil, Germany, India, and the United Kingdom. The…
The document presents a framework for trading a mean-reverting portfolio, often formed by holding one asset and shorting another. It models portfolio value with an Ornstein–Uhlenbeck process, estimates the long-run mean, reversion speed, and volatility by…
The module implements the two-step Engle–Granger approach to constructing a portfolio intended to be mean reverting. It uses ordinary least squares to regress a chosen dependent asset’s price on the other price series, defaulting to the first input column as…
This introduction explains how cointegration can help create a mean-reverting portfolio from price series that are not themselves mean-reverting. By combining multiple assets with suitable weights, a trader may construct a spread or portfolio whose value…
This implementation describes convergence trading for two cointegrated assets as a portfolio optimization problem. It estimates error-correction speeds and other model parameters from price data, then computes portfolio weights under both unconstrained and…
This document describes a trading rule that measures a spread’s latest value against its recent average and standard deviation. It uses separate lookback windows for the mean and standard deviation, then calculates a z-score to identify unusually high or low…
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 document describes helper calculations commonly used to construct quantitative signals from price or other tabular time series. Its functions cover rolling sums, averages, standard deviations, correlations, covariances, ranks, products, extrema,…
This code sample implements parts of the Alpha101 factor set using historical equity fields such as open, high, low, close, volume, returns, and volume-weighted average price. The formulas combine rolling ranks, moving averages, correlations, price changes,…
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 module implements the bivariate Nelsen 13 copula, a tool for modeling dependence between two uniform variables. It provides the copula cumulative distribution and density, a conditional distribution, random pair generation, and a parameter estimator…
The document implements a threshold autoregressive model for testing whether a spread adjusts differently after positive and negative deviations. It first differences the input series to form changes, lags the spread by one period, and assigns each lagged…