This expert advisor compares the overlaid price histories of two currency pairs and trades when their divergence retreats from a recent maximum. It starts from a chosen point, scales the second pair’s price range to roughly match the chart pair, and measures…
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 documentation describes a simulator for autoregressive series and pairs whose cointegration error follows an AR(1) process. One series is modeled through its changes, while a linear combination of the two series represents the spread or cointegration…
The Pearson approach forms equity pairs by ranking stocks on the correlation of their monthly returns during a formation period. For each stock, it selects the most highly correlated peers and combines their returns into a benchmark portfolio, using either…
The time series approach begins after a pair or group of assets has already been selected, for example through cointegration testing. It models the resulting spread to produce trading signals, shifting the focus from finding related securities to deciding…
This indicator plots the price difference between two chosen trading symbols, with AUDUSD and NZDUSD given as defaults. Each symbol has a weight parameter, allowing the displayed spread to reflect a weighted difference rather than only an unadjusted…
This module describes selecting three partner stocks for each target in a four-stock vine-copula statistical arbitrage framework. It compares four approaches using ranked daily returns: a baseline that sums pairwise Spearman correlations, a multivariate…
This module describes a method for selecting upper and lower trading thresholds for a mean-reverting cointegration pair. It estimates a hedge ratio using either Engle–Granger or Johansen analysis, constructs the cointegration error as the spread, and fits an…
This implementation describes a distance-based statistical arbitrage method for forming and trading equity pairs. In a training period, each price series is scaled using its own minimum and maximum, and candidate pairs are ranked by the sum of squared…
This document extends a cointegration-based spread strategy from pairs to three or more assets. It forms a weighted combination of log prices using a cointegration vector, then derives a spread return from the same weights. Under stated stationarity…
This example demonstrates a portfolio-strategy backtest for a pair trading strategy on two Dalian Commodity Exchange continuous contracts. It configures minute data over a specified historical interval and supplies commission rates, slippage, contract sizes,…
The study applies machine learning to estimate an optimal rebalancing frequency for pairs trading. It uses minute-level prices for 50 large cryptocurrencies from Binance during 2022 and 2023. For each asset pair, a simulated pairs-trading algorithm…
A forum exchange addresses how to monitor current account profit or obtain opening fill prices inside a spread trading strategy. The question notes that the spread-trading forum’s trade callback cannot be called directly from the strategy, and asks for…
This documentation describes a function for estimating the half-life of a mean-reverting process under an Ornstein-Uhlenbeck assumption. The model represents changes in a variable as a pull toward a level, plus Gaussian noise. The half-life is a way to…
This implementation describes an equity pairs strategy that selects stocks with highly correlated historical returns, then compares each stock’s return with a portfolio of its selected peers. It estimates a regression coefficient during a formation period…
The document explains statistical pairs trading as a market-neutral mean-reversion approach. It describes selecting two securities with historically similar price behavior, then selling the relatively expensive leg and buying the relatively cheap leg when…
The document describes an indicator intended to plot cumulative profit and loss for configured spread or equity positions as an equity line in a chart subwindow. Users set each active pair’s volume, direction, and activation state, can provide a symbol…
This code implements a bivariate mixture of Clayton, Frank, and Gumbel copulas, framed as a dependency model for a mixed-copula pairs trading strategy. It transforms each input series to empirical marginal quantiles, then fits the mixture weights and…
This broad guide surveys algorithmic trading approaches, including momentum, statistical arbitrage and pairs trading, market making, machine learning, and options. It outlines how each approach seeks opportunities: following trends, trading relative-price…
This module generates synthetic pairs whose relationship is defined by a hedge ratio and a mean-reverting cointegration error. It first simulates the change in one asset’s price as an autoregressive process, cumulatively sums those changes into a price…
This reference explains two utilities for copula-based trading research: a linearly interpolated empirical cumulative distribution function (ECDF), and a quick selector for candidate pairs. A standard empirical CDF is a step function, which can map sparse…
This module supports copula analysis by mapping observations to marginal empirical cumulative probabilities, with optional linear interpolation and probability bounds. It provides a multivariate row-wise transform, fits a supplied copula to two series after…
Hedge ratios set the relative sizes of legs in a spread so that price differences do not leave the position unintentionally unbalanced in dollar terms. The document introduces a simple price-ratio method, then describes normalizing weights so the dependent…
This method adapts mean-reversion pairs trading to the risk that a spread shift reflects a lasting structural change rather than a temporary deviation. It models the pair spread as having two Markov-switching states, each with its own mean and volatility,…
This code describes a C-vine copula wrapper intended for statistical arbitrage research. It fits candidate vine structures to quantile-transformed data, restricts the candidate ordering according to a chosen target variable, and selects the structure with…