The topic is relatively small, first introduce CTP.
Integrated trading Platform CTP (comprehensive Transaction Platform) is a futures trading platform developed by Shanghai Futures Information Technology Co., Ltd. (a wholly owned subsidiary of Shanghai Futures Exchange), based on the core technology of "Next Generation Exchange System", which is stable and High-speed, open interface, suitable for programmatic trading software and short-term fried single customer use.
Yes, it is a special futures trading, the risk of futures trading, refer to the following:
The risk of futures trading is considerable, and significant losses may occur, and the total amount of losses may exceed all initial deposits and margin calls you have deposited with the futures brokerage company. Therefore, you must seriously consider whether your economic ability is suitable for futures trading.
Because of the futures margin system and the drastic changes in price fluctuations, it is easy for investors to lose all their money, the risk is greater than the stock market, novice cautious into.
Nonsense on so much, here's the introduction to technology.
CTP is based on multithreading, at least two threads are working, one is the main thread of the program, and the other is the API worker thread.
The API layer encapsulates TCP traffic and uses the API interface through function callbacks. One of the documentation manuals. So, to develop the CTP program, we should first thoroughly understand the various callback functions of the API,
The CTP API package is divided into two parts, one is Traderapi (Thosttraderapi.dll) is responsible for the trading part, the other is Mduserapi (Thostmduserapi.dll) responsible for
For example, how to create a Traderapi object, and register a processing object. The following code and flowchart is one by one corresponding, see the article to carefully oh.
cthostftdctraderapi* Puserapi =Cthostftdctraderapi::createftdctraderapi (); Ctptraderspi* Puserspi =NewCTPTRADERSPI (PUSERAPI);//creating an API objectPuserapi->registerspi ((cthostftdctraderspi*) PUSERSPI);//registers an event class that encapsulates a function callbackPuserapi->subscribepublictopic (Thost_tert_restart);//subscribe to public flowPuserapi->subscribeprivatetopic (Thost_tert_restart);//subscribing to private streamsPuserapi->registerfront (Tradefront);//Register a pre-trading machinePuserapi->init ();//Initialize API
Detailed answers to Ctptraderspi, he is a class that inherits from Cthostftdctraderspi, which encapsulates a function callback. CTHOSTFTDCTRADERSPI is the CTP package good, leaving the interface allows us to overload, it is so simple.
As for what functions can be overloaded in Ctptraderspi, you download the API SDK to see for yourself, too much to fully understand, and a lot of functions are useless ...
Let us introduce the structure of trading class and market class and its naming characteristics.
Last Edition API download home
Finally, now stocks, warrants actually have the automatic trading API.
Introduction of CTP API Development futures automatic trading platform