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…
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
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 document describes an indicator for visualizing pair trading by overlaying one instrument’s price series on another. When the two series diverge, the example strategy sells the relatively higher pair and buys the lower one; both positions are closed when…
A forum user asks how to check whether enough funds are available before starting a spread-arbitrage order algorithm. The stated motivation is to avoid opening only one leg of a paired trade when the account cannot support both sides. A reply points to…
A forum exchange discusses why VeighNa’s StatisticalArbitrageStrategy example uses a ten-unit price offset when starting its spread-trading algorithm. The questioner describes the order logic: a leg order is sent when the spread order price would otherwise…
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 code describes a mean-reversion strategy for the spread between Dalian Commodity Exchange coke and coking coal futures. It calculates a weighted value spread using contract prices, contract multipliers, and a specified leg ratio, then estimates the…
A trading-system forum discussion explains why a conventional CTA strategy that works on outright futures may fail when applied directly to exchange-listed spread contracts. The reported symptoms include missing backtest data and occasional trades with…
This repository overview introduces a collection of systematic trading approaches, including moving-average momentum, cointegration-based pairs trading, candlestick signals, and an opening-range breakout. It also points to projects in options, portfolio…
The document presents a pairs-trading question about two stocks believed to have a long-run cointegrating relationship. It describes fitting a linear relationship between their prices, then standardizing a series associated with that relationship using a…
This implementation describes a threshold-based rule for a cointegrated pair. It opens a long-spread trade when the spread falls to or below a lower entry level, or a short-spread trade when it rises to or above an upper entry level. A trade closes when the…
This indicator guide explains how to build a synthetic spread from two price series and use its deviations to identify possible pair-trading entries. Users choose the instruments, combine their series with an arithmetic operation, and can reverse,…
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 page organizes a beginner-oriented quantitative trading curriculum and links to lessons and example strategy projects. The listed foundations include Python, pandas analysis, historical and financial data access, visualization, and DataFrame plotting.…
The document describes a proposed dashboard indicator for monitoring active symbols and pairs in spread or equity trading. Its interface is meant to track changes in the selected symbols, retain settings during terminal changes, and let users set each pair's…
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 indicator is designed to compare two instruments for a convergence trade. It plots an averaged line for each instrument and a third line that represents the distance between them, with colors distinguishing divergence from convergence. The suggested…
This Chinese-language forum exchange explains how to track execution information for a spread-trading algorithm. A participant asks how to obtain a spread’s opening average price and its fill prices and quantities. The reply recommends receiving algorithm…
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 document explains how to trade a cointegrated pair using entry and exit levels produced by a minimum-profit optimization method. It defines a spread from the two asset prices and a hedge coefficient. When the spread falls below the buy threshold, the…
This code excerpt describes two operations used in a cointegration-based statistical arbitrage workflow. The first multiplies each asset’s price series by the corresponding coefficient in a cointegration vector and sums across assets, producing a portfolio…
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…
The document outlines a mean-reversion strategy for two assets selected for cointegration. It uses the Engle–Granger two-step approach: regress one price series on the other, test whether the residuals are stationary, then fit an error-correction model and…