The document describes a software framework for executing spread trades across multiple instruments. It tracks each leg’s orders, fills, costs, and positions, then estimates the spread’s completed volume and average fill price. For inverse contracts, it…
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
59 documents
The document introduces a position calculator for a grid strategy that tracks net quantity, average price, and accumulated profit as fully filled orders arrive. Its example illustrates that after buying at several nearby levels and selling part of the…
This strategy combines Bollinger bands with an average true range stop on fifteen-minute bars. When flat, it places stop-entry orders at the upper and lower bands, aiming to enter on a move beyond the recent range. The band window, band deviation, ATR…
The document describes a data model for parsing a futures account response into account-level totals, per-asset records, and per-position records. Account-level fields include trading permissions, wallet and margin balances, initial and maintenance margin,…
This document compares crypto spot, leveraged spot, and futures trading. It explains that spot positions are not subject to liquidation in the described framework, while borrowed margin positions and futures can be forcibly closed. It outlines long and short…
This document outlines a per-contract result tracker and a portfolio-level PnL container. The contract tracker stores an opening position, observed trades, position changes, and cumulative long and short traded volumes and costs. It filters duplicate trade…
This strategy starts by placing buy and sell limit orders around the best bid, then follows whichever side fills. After a fill, it cancels opposing and profit-taking orders and adds another same-direction order at a wider, position-dependent grid interval.…
The material explains how an order-management component adapts close orders to futures position rules. It maintains separate long and short holdings, splitting each into positions opened today and positions carried from earlier sessions. Incoming position…
This code provides a client wrapper for trading and querying USDT margined perpetual futures. It configures position mode, margin mode, and leverage, then supports buy and sell orders with limit, market, or other order types. After submission, it checks…
The document shows a simple workflow for evaluating two futures strategies together. It runs separate historical simulations for an ATR-RSI strategy on an equity index contract and a Bollinger channel strategy on a metal contract. Each run specifies its own…
This guide explains execution algorithms that divide large orders, react to market prices, and adjust positions on a grid or across a spread. It describes time-weighted execution, iceberg orders, a tick-driven sniper approach, conditional orders, and…
This strategy uses a fast and a slow moving average to trade long and short. It detects a bullish crossover when the fast average moves above the slow average, and a bearish crossover when it moves below. When a signal opposes an open position, the code…
The document describes an options volatility trading module built around live pricing, portfolio risk tracking, and execution. It outlines three pricing models for different exercise styles and underlyings, with routines to calculate theoretical prices and…
This document explains the structure of a historical trading strategy backtester. It loads bar or tick records over a selected date range, initializes a strategy with a warm-up period, then replays the remaining data. The engine tracks simulated orders and…
This multi-instrument strategy updates bars from incoming ticks and calculates ATR and RSI for each instrument. It only considers new entries when the latest ATR is above its recent average. RSI levels set around the midpoint then determine direction: a high…
This code tracks long and short holdings, separating each side into today’s and prior-day positions. It updates those amounts from position snapshots and trades, and it keeps active orders so that quantities committed to closing positions are treated as…
The document walks through preparing a Python environment, installing a trading framework, and launching its graphical interface. The example registers exchange gateways and applications for strategy execution, historical data recording, risk controls,…
The document describes two portfolio analytics displays. The volatility chart plots call and put mid-implied volatilities against strike, alongside a pricing implied-volatility curve, and allows individual option chains to be shown or hidden. Curve data is…
This document describes a position reconciliation process that compares a strategy’s intended direction and size with the account’s actual holdings. The intended position is read from stored records, while the account position and current market price are…
This guide explains a workflow for researching CTA strategies with historical market data. It covers obtaining and storing data, configuring a backtest with a strategy, date range, slippage, fees, contract multiplier, tick size, and starting capital, then…
This strategy combines Bollinger Bands with MACD to enter long or short positions when price crosses an outer band and MACD points in the same direction. It calculates bands from closing prices, uses a rolling standard deviation to size positions against a…
The document presents a workflow for evaluating individual trades from a Turtle-style strategy backtest on an hourly Bitcoin instrument. It configures a backtest with a historical date range, fees, slippage, contract size, tick size, and starting capital,…
This strategy combines Bollinger-style price bands with the Commodity Channel Index (CCI) to generate directional entries on 15-minute bars. It calculates a simple moving average and standard deviation over a configurable lookback, then places a stop entry…
This spot strategy generates signals from a fast and a slow moving average. It identifies a bullish crossover using completed bar values rather than the current bar, which is intended to avoid signals that flicker while a bar is forming. A bullish cross…