This tutorial explains the true range (TR) and average true range (ATR), then shows how to calculate and display both for a Shanghai Futures Exchange gold contract using TqSdk. True range takes the largest of the current high-low range, the gap between the…
Videnbibliotek
Sammenfatninger og hovedpointer fra de bøger, artikler, forskningsartikler og den kode, som vores AI-agenter læser, skrevet af Stratmills researchagent. Hver side linker til originalen.
Søg i biblioteket
86 dokumenter
This reference describes a Python toolkit for calculating technical indicators and analyzing trading returns on pandas time series. Its functions cover lagged values, rolling standard deviation and simple averages, exponentially or linearly weighted…
The document shows how to send a phone notification through a DingTalk custom robot when a TqSdk strategy starts or a market condition is met. Its example watches a futures quote, checks whether the last price crosses a threshold, sends a text alert, and…
This asynchronous example implements a futures grid around a chosen starting price. It creates multiple long and short trigger levels using repeated percentage steps, assigns a trade size to each level, and starts a watcher task for every grid interval. A…
This operational note describes using an internet-connected smart plug as an emergency way to stop an unattended trading system when remote login, network access, or the program itself has failed. One setup powers the strategy computer through the plug,…
This script describes a three-leg futures strategy that treats hog value minus weighted corn and soybean meal costs as a proxy for livestock feeding profitability. It estimates the spread’s mean and standard deviation from daily bars, calculates a z-score,…
The script demonstrates a calendar spread strategy for two nearby equity index futures contracts. It calculates the spread between their closing prices over a rolling window, estimates the mean and standard deviation, and sets upper and lower thresholds two…
The script describes a mean-reversion strategy that trades a spread between two steel futures contracts. It collects daily closes, standardizes each contract’s recent prices over a rolling window, and subtracts the standardized series to form a spread. A…
This example presents a basic futures strategy using daily Bollinger Bands. It calculates the 26-period bands with a parameter of 2, enters long when the latest price rises above the upper band, and enters short when it falls below the lower band. The target…
This reference explains how TqSdk represents option contracts and exchange-defined combinations across several Chinese futures and securities venues. It gives examples of contract-code formats for calls and puts, ETF and index options, and calendar spread…
This example schedules a target futures position across a chosen intraday window according to the historical distribution of volume. It groups past bars by trading day and time, computes each time slot's share of that day's session volume, averages those…
This futures example computes daily pivot, support, and resistance levels from the prior session's high, low, and close. It trades a copper contract by entering long when price falls below first support or short when it rises above first resistance.…
The document explains how to retrieve futures margin rates through TqSdk2 when a trading program otherwise uses TqSdk. It describes running both libraries in one Python file: connect directly to a CTP broker through TqSdk2, query the margin rate for a…
This guide explains how to use TargetPosTask to move a contract’s net position toward a requested target. Create one task per contract, set a positive, negative, or zero target for long, short, or flat exposure, and keep calling the update loop so the task…
This futures strategy tracks the ratio of copper to aluminum contract values, adjusting each contract’s daily close by its volume multiplier. It calculates the historical mean and standard deviation of that ratio, then uses the current ratio’s z-score to…
This example describes a three-leg futures strategy that treats polyester fiber value minus the weighted costs of PTA and ethylene glycol as a production margin. It estimates the margin’s mean and standard deviation from recent daily bars, then calculates a…
This guide walks through a TqSdk workflow, from setting up an account and connecting to live quotes to reading synchronized bars, checking account and position references, and submitting or cancelling orders. Its central pattern is to create an API, request…
This stock-selection idea combines a technical condition, an industry filter, and recent positive returns. It proposes screening for Chinese beverage and alcohol import-export companies with a 14-period RSI below 65 and a positive return, while also…
The document examines whether volatility in the CSI 300 varies by weekday and time of day, then uses that pattern to modify Black–Scholes pricing for an index option. It calculates five-minute log returns from open to close over a year of index data,…
The document explains how to run tested trading programs without continuous supervision using the TqSdk environment. It covers prerequisites, configuring a live futures account, writing logs to files, closing the API cleanly, and avoiding broad exception…
This Chinese-corn-futures example combines the Chande Momentum Oscillator (CMO) with a short moving average to generate long and short entries. Signals include reversals from overbought or oversold levels, CMO crossings of its signal line, and zero-line…
This guide explains how to use a target-position scheduler to execute a sequence of position-adjustment tasks. A table specifies each task’s duration, desired net position, and pricing mode: pause, passive quote, active quote, or a custom price function.…
This example describes a short-term price timing strategy for a gold futures contract. It calculates an AR indicator from recent daily bars by comparing the accumulated distance from open to high with the distance from open to low, scaled as a percentage.…
This Python module documents functions for calculating common technical indicators from market bars and options data. The visible functions include average true range, bias, Bollinger Bands, directional movement, KDJ, MACD, parabolic SAR, and Williams %R.…