This client code illustrates order handling for coin-margined futures. It configures position mode, margin mode, and leverage, submits buy and sell orders, checks order status, and exposes account, position, contract, depth, and funding-rate queries. Limit…
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
65 documents
This implementation models a spread as a collection of instrument legs, with separate multipliers for calculating its quoted price and translating spread quantities into leg quantities. It combines leg bid and ask prices, reversing which side is used for…
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 describes an order-routing adapter that connects algorithmic parent orders and exchange-facing child orders through FIX messages. It maps exchanges, order types, directions, and statuses between two systems. A parent order carries the…
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 strategy uses a fast and a slow moving average to trade a cryptocurrency futures contract. A bullish crossover opens a long position or reverses a short position; a bearish crossover opens short or reverses long. Signals use earlier completed bars…
This strategy enters long or short positions when price reaches the rolling high or low over an entry window. It adds up to four fixed-size units at progressively spaced price levels, with spacing tied to the average true range (ATR). When a position is…
This document implements a directional crossover strategy using fast and slow exponential moving averages on hourly bars. It calculates the averages from closing prices, discards the latest bar if it has not yet closed, and signals a long position when the…
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 document explains how to build a multi-contract strategy using synchronized bar data, per-leg targets, and order management. Its example computes the spread between two weighted contract prices, updates a rolling window, and uses Bollinger Bands to…
The document describes a two-leg spread strategy built around Bollinger Bands. It calculates a weighted price difference between two contracts, samples the spread on a five-minute schedule, and compares it with a rolling mean and standard deviation. A move…
This document explains a workflow for collecting live market data for selected instruments. After connecting to a market interface and starting the recorder, a user adds tick or bar recording tasks. The recorder subscribes to the required instruments, stores…
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…
This strategy seeks directional breakouts on one-hour bars. A long entry requires positive CCI and an intraday bid above the upper Bollinger Band and the previous bar’s high; a short entry requires negative CCI and an ask below the lower band and previous…
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…
This strategy forms a spread from two instruments’ bar closes, weighted by configurable leg ratios. It updates the spread at five-minute intervals, keeps a rolling history, and calculates a moving average with upper and lower bands based on the spread’s…
The document describes a graphical workflow for downloading historical bars, configuring a CTA strategy backtest, reviewing performance statistics, and inspecting trades on a candlestick chart. Data can come from a domestic market data service, an…
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 explains a local simulator that routes orders and cancellations to a paper-trading engine instead of sending them to an external trading server. It supports limit, market, and stop orders, and uses quote-triggered matching: for example, a buy…
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 builds Keltner-style bands from a simple moving average of closing prices and a simple moving average of true range. On five-minute bars, when flat, it places linked stop orders above and below the bands so that a move beyond either boundary…