The script trades a spread between Dalian Commodity Exchange coke and coking coal futures. It estimates the spread from each contract's close, volume multiplier, and a fixed contract ratio, then calculates a z-score from a rolling set of daily observations.…
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
41 documents
This example trades a spread between continuous Light Sweet Crude Oil and RBOB Gasoline futures. It estimates a return relationship by regressing crude returns on gasoline returns over a rolling history, then measures the recent spread against its mean and…
This statistical-arbitrage demo tracks closing prices for two instruments, takes their logarithms, and uses the difference as a spread signal. When the spread crosses configured positive or negative thresholds, it opens opposing legs: short the first…
This script presents a spread-style signal using continuous YM and NQ futures. It divides the YM close by the NQ close, smooths that ratio with a 200-period simple moving average, and uses it to scale NQ in a difference series. Bollinger Bands over that…
This script describes a mean-reversion strategy for two related futures contracts. It collects daily closes over a rolling window, standardizes each contract’s prices separately, and defines the spread as the difference between those standardized series. It…
This alpha model forms every eligible pair from the selected securities and tracks the ratio of the first asset’s price to the second’s. It smooths that ratio with an exponential moving average and sets upper and lower bands using a configurable percentage…
This multi-coin futures strategy compares each altcoin’s price relative to Bitcoin with a benchmark index of those relative prices. It shorts coins trading above the index and buys those below it, scaling target exposure with the size of each deviation. A…
The document introduces pair trading as a long-short approach that seeks to profit when two related assets’ prices move back toward their usual relationship. It discusses selecting correlated assets, using moving averages or other indicators to identify…
This strategy forms a spread from two instruments using hedge weights estimated with the Johansen cointegration procedure on a rolling lookback. It recalculates those weights daily, then measures the spread against its rolling mean and standard deviation. A…
This framework trades the relative price of the PAXG and XAUT gold-linked tokens. It expresses their difference as a percentage, then estimates a rolling mean and standard deviation from minute closes. A spread beyond two standard deviations prompts a…
This framework example wires a Pearson correlation pairs alpha model into a complete algorithm workflow. The model extends a base pairs model and ranks candidate pairs using Pearson correlation, then selects the top candidate to trade. The example uses a…
This Python strategy constructs a spread from two instrument prices weighted by configurable leg ratios. It updates the spread periodically and, after collecting enough observations, calculates a rolling mean and standard deviation over a 20-observation…
This demonstration explores monitoring the relative price of Bitcoin and Ether as a possible cross-asset hedge or arbitrage signal. It computes a fee-adjusted ratio from the two markets’ mid-prices, aggregates observations into hourly values, and plots the…
This example trades a soybean crush spread using soybean, soybean meal, and soybean oil futures. It estimates a weighted spread from the component prices and contract multipliers, using a 10:8:2 ratio to approximate processing yields. A rolling history…
This document provides a trading implementation for two crypto futures instruments on OKX, with an explicit requirement for one-way position mode. It calculates an average historical price ratio from hourly candles, then compares the live ratio with that…
This strategy models the relationship between Brent crude and the Norwegian krone with a rolling ordinary least squares regression. It fits the model on a recent window, accepts it only when its R-squared exceeds a chosen threshold, then estimates the…
This script outlines a long-side statistical arbitrage approach for a pair of instruments. It retrieves the second instrument’s price series, standardizes each instrument’s price against its own rolling mean and standard deviation, and subtracts the…
This example builds a relative-value spread from live hog futures and the estimated feed inputs of corn and soymeal. It scales each contract’s price by its contract multiplier and a production ratio, then defines the feeding margin as hog value minus feed…
This charting tool compares two selected swap markets against a chosen base market. For each bar, it divides each instrument’s close by the base close, then divides those two normalized values to form a relative spread series. It plots that series alongside…
This intraday pairs strategy trades the spread between the front-month and next-month futures contracts. It builds separate buy-side and sell-side spread prices using the relevant bid and ask quotes, then calculates rolling Bollinger Bands over a 60-minute…
This document describes a two-asset crypto pairs strategy that compares each instrument’s price change over the current candle. When the difference exceeds a threshold, it opens a position in one direction on the second asset, aiming to profit as the…
This Binance perpetual-futures strategy maintains short exposure across a selected altcoin basket and offsets it with long exposure in Bitcoin or other chosen assets. It repeatedly checks account positions and prices, then adjusts contracts when their values…
This crypto pair strategy trades BTC against ETH when BTC has a sufficiently strong intraday move and outperforms or underperforms ETH. It takes the stronger leg in the direction of BTC’s move and the weaker leg in the opposite direction, aiming to capture…
The visible source describes a two-asset strategy framework that compares one instrument with a user-selected pair. It retrieves closing prices on a selected timeframe, fits a rolling linear regression, and calculates correlation and residual error. The code…