This page looks best with JavaScript enabled

Program Trading - CTP

 ·  ☕ 4 min read

1. Introduction to the Comprehensive Trading Platform (CTP)

The Comprehensive Trading Platform is a futures brokerage business management system developed by Shanghai Futures Information Technology Co., Ltd. for futures brokerage firms, based on the trading system of the Shanghai Futures Exchange. The whole system consists of three major subsystems: trading, risk control (abbreviated as risk control) and settlement. The system can connect to the four domestic futures exchanges at the same time, supports the trading and settlement business of domestic commodity futures and financial futures, and can automatically generate and submit files for the Anti-Money Laundering Monitoring and Analysis Center and the Margin Monitoring Center.

  • Trading system. Mainly responsible for order processing, market data forwarding, and bank-futures transfer;
  • Settlement system. Responsible for account management, broker management, margin settings, trade management, fund management, fee rate settings, end-of-day settlement, information query, and so on;
  • Risk control system. Mainly performs high-speed real-time trial calculations during trading hours, so as to promptly reveal and control risk;

2. Introduction to the CTP API

The CTP API is provided by Shanghai Futures Information Technology Co., Ltd. specifically for third-party integration and development. It is a C++-based class library; by using and extending the interfaces provided by the class library, you can implement trading-related functions, including trading day retrieval, investor information query, contract query, order entry, order cancellation, order suspension, trade query, and so on.
The latest documentation can be downloaded from the Shanghai Futures Information Technology official website.

3. Introduction to Program Trading

Program trading, also called systematic trading, refers to the use of market software and computer programs, with the help of market technical indicators, where buy and sell points are calculated by a pre-set program, and the computer automatically calculates and executes buy or sell actions based on its signals, rather than operating according to the operator’s own views.

More influential commercial systems include Wenhua Finance, TradeBlazer, Pyramid, MC, and so on.

Advantages of program trading: maintaining objectivity, a speed advantage, quantitative analysis of returns and risk, diversification, and the advantage of continuous attention to the market.

Disadvantages of program trading: unavoidable small-probability events, large capital drawdowns, the trading system lagging behind price changes, lack of flexibility, and requiring users to have great patience and discipline.

Trade initialization sequence diagram:

Market data initialization sequence diagram:

4. A Complete Program Trading System

The steps that make up a complete program trading system:

  • Proposing a trading strategy,
  • Screening of trading targets,
  • Formulating the trading strategy,
  • Statistical testing of the trading system,
    Live testing of the trading system (including an earlier real-time market simulation and live testing with small capital and low positions),
  • Monitoring and maintenance of the trading system

In simple terms, it is taking some investment experience and strategy methods, first turning them through quantification and formulation into a computer language that a computer can recognize, testing them with historical data for statistics and success rate, and then testing them across different instruments and markets and historical data of different periods before putting them into live trading, and finally continuously adjusting and improving them through the test of practice. The aspects involved are market selection, position size, entry, stop loss, exit, and buy/sell techniques.

Generally, trading Shanghai Futures Exchange and CFFEX instruments through CTP is very fast, reaching around 10-15 ms, while trading Dalian Commodity Exchange and Zhengzhou Commodity Exchange instruments is relatively slower, about 90 ms, sometimes even higher. The futures market as a whole is dominated by investors participating in metal futures on the Shanghai Futures Exchange and financial futures on CFFEX, so a CTP-based program trading system has even more room to show its worth.

5. Strategy Development Lifecycle

  • Modeling; a financial engineer or an individual program trading system developer constructs a trading idea based on certain specific mathematical models and market regularity phenomena, and then organizes it into a strategy.
  • Strategy development; the strategy is written into computer-recognizable code through a computer language, and then the strategy code is compiled with a programming tool to generate an automated trading program.
  • Backtesting and review; based on historical data (Tick and K-line), the strategy is driven to run, producing buy and sell signals. Based on virtual trade records, strategy evaluation metrics such as the equity curve, maximum drawdown, and Sharpe ratio are calculated, and parameters are further optimized for the effect of the best parameters.
  • Live trading; a real-time market data source drives the strategy, integrating the live order channel and connecting to the futures brokerage firm’s CTP counter system, using a small amount of real capital to trade in order to test the live effect.


WeChat Official Account
WRITTEN BY
WeChat Official Account