This documentation explains how to run a TqSdk strategy over historical data without changing its core logic, and how to retrieve trade logs and account statistics when the simulation ends. It describes catching a backtest-finished event, accessing summary…
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
42 documents
This reference explains advanced order instructions for futures and options trading through TqSDK. It compares ordinary limit orders, FAK orders that cancel any unfilled remainder, and FOK orders that cancel unless the full quantity can execute immediately.…
This TqSdk guide explains how to run timed actions inside the main loop driven by wait_update, rather than pausing the program with a separate sleep loop. For actions tied to the trading session, it recommends checking the market timestamp in quote.datetime,…
This comparison explains differences between TqSdk and vn.py that matter when adapting existing trading strategies. vn.py is presented as an integrated package with market data, trading connections, storage, and interface components. TqSdk instead uses…
This reference distinguishes local simulation accounts from remote Quick simulated accounts for futures and stocks. It describes TqSim as a local futures simulation option for development and backtests, TqKq as a Quick linked futures account, and…
The document argues that trading systems should be written so that changes to strategy logic require only localized code edits. It illustrates this with an R-Breaker example: if backtesting suggests that holding positions overnight adds risk without enough…
This reference organizes common TqSdk problems by symptom and suggests likely causes and corrective checks. It covers empty or stale market data, queued order requests that have not been sent through an update cycle, target-position tasks that fail to act,…
This example describes a futures strategy using the Volume Price Trend (VPT) indicator on daily bars. It updates VPT by adding volume multiplied by the latest percentage price change, then compares the current value with a moving average. A trade is…
This documentation explains design choices behind TqSdk, a Python trading software development kit. It aims to avoid imposing a strategy model: users can fetch data and issue orders freely, while examples demonstrate possible applications instead of…
This example demonstrates an iceberg-style execution workflow for a futures contract. The trader chooses a symbol, a total volume, minimum and maximum order sizes, and a buy or sell direction. A target-position task manages orders toward the desired net…
This framework overview explains TqSdk’s component layout and message flow. It describes TqChan as a one-way queue between components and outlines how order messages travel from user code through TqApi and TqAccount to a trading gateway. In the reverse…
The document explains a terminal feature that replays an entire historical trading day. A user chooses a date when launching the replay version of the terminal, then uses the software and its extensions as though operating during that session. Playback can…
This TqSdk reference explains how to authenticate with a platform account and select a live futures account, a shared platform simulation account, or a local simulation account when creating the API object. It describes live-account binding limits and common…
This reference explains common market-data workflows in the TqSdk Python interface. It covers subscribing to real-time quotes, monitoring updates to quote fields, and requesting K-line bars or tick series as data frames that update in place. It also…
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 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…
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 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…
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 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.…