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
53 documents
The document presents a fee-model design for a trading system, with fees calculated from an order’s execution details. Common fees distinguish maker orders, which add liquidity, from taker orders, which remove it. The fee amount can be proportional to…
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 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 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…
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 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…
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…
This note proposes screening Chinese metaverse-sector equities using two signals: rank by the day’s opening-auction value and retain the leading five, then require at least two limit-up events within a stated 500-day lookback. It includes platform-specific…
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 document contains reusable strategy calculations for price returns, volatility scaling, trend following, and MACD signals. Its intermediate trend strategy combines the signs of one-month and one-year returns, weighted by a parameter, and applies that…
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…
This module fits a bivariate mixture of Clayton, Student-t, and Gumbel copulas, motivated by a mixed-copula pairs trading approach. It first maps each input series to empirical cumulative probabilities, then estimates component parameters and mixture weights…
This document explains a method for selecting profit-taking and stop-loss boundaries for a mean-reversion strategy modeled with an Ornstein–Uhlenbeck process. A position is closed when it reaches either boundary or when its maximum holding horizon expires.…
The document outlines safeguards for cryptocurrency futures trading during sharp market moves and delayed updates. It recommends monitoring the gap between a futures contract and its underlying spot price, and between last price and mark price, as signs that…
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 note proposes a short-term Chinese equity screen that selects stocks with a price amplitude above one, an appearance on the prior day's trading list with buying greater than selling, and a rising DEA indicator. The rationale is to combine elevated…
This document describes an analytical method for choosing entry and exit levels in a statistical arbitrage strategy whose log price follows an exponential Ornstein–Uhlenbeck process. The trade cycle runs from an entry level to an exit level and back to the…
This reference explains how information theory can measure dependence between variables, including asset returns. It introduces entropy as uncertainty, then defines mutual information as the reduction in uncertainty about one variable from observing another.…
This document describes a class for applying an exponential Ornstein–Uhlenbeck model to mean-reverting portfolio prices. It inherits fitting and portfolio construction from an OU model, then works in log-price space to estimate optimal liquidation levels,…
The document explains how to form and evaluate long-short stock portfolios, focusing on pairs trading. It compares hedge-ratio methods: ordinary least squares minimizes portfolio variance under a correlated random-walk and Gaussian framework, while total…