Home > Back-end >  Pegasus documentation
Pegasus documentation

Time:09-18

Directory

Chapter 1 introduction 1
Chapter 2 architecture 1
2.1 communication mode 1
2.2 the data flow 2
Chapter 3 running mode 1
3.1 the worker thread 1
3.2 the local file 1
Chapter 4 development interface 1
4.1 CUstpFtdcMduserSpi interface 1
4.4.1 OnFrontConnected method 1
4.1.2 OnFrontDisconnected method 1
4.1.3 OnHeartBeatWarning method 2
4.1.4 OnRspUserLogin method 2
4.1.5 OnRspUserLogout method 3
4.1.6 OnRtnDepthMarketData method 4
4.1.7 OnRspError method 6
4.1.8 OnRspSubMarketData method 7
4.1.9 OnRspUnSubMarketData method 7
4.2 CUstpFtdcMduserApi interface 8
2 CreateFtdcMduserApi method 8
4.2.2 Release method 8
Holdings Init method 8
4.2.4 the Join method 9
4.2.5 GetTradingDay method 9
4.2.6 RegisterSpi method 9
4.2.7 RegisterFront method 9
4.2.8 SubscribeMarketDataTopic method 10
4.2.9 ReqUserLogin method 11
11 4.2.10 ReqUserLogout method
4.2.11 SubMarketData methods 12
4.2.12 UnSubMarketData methods 12
Chapter 5 development example 14






Chapter 1 introduction
Quote the client API is a system based on c + + class library, through the use of and extension libraries provide interface to realize the market data receiving, the class library includes the following five files:

File version file size file description
UstpFtdcMduserApi. H V1.0 market the interface file
UstpFtdcUserApiDataType. H V1.0 defines the data type of required a series of API header file
UstpFtdcUserApiStruct. H V1.0 defines the data structure of a series of business related header file
USTPmduserapi. DLL dynamic link library V1.0 binary file
USTPmduserapi. Lib V1.0 import library file

Support MS VC 6.0, MS VC.NET 2003 compiler, need to open the multi-threaded compiler options/MT,

Chapter 2 architecture
Market use API based on TCP protocol FTD agreement to release the performance of pegasus server communication, produce and market distribution server is responsible for market information, but not participate in the trading process, involved in trading you need to use other traders API,
2.1 communication mode
FTD agreement of all communications are based on a communication model, communication mode, in fact, is the way of communication both sides work together,
Market launch involves communication mode has two kinds:
? Dialogue communication mode
? Broadcast communication mode
Dialogue communication mode is to point to end communications request initiated by the members, the request is pegasus server receiving and processing, and to give a response, such as login and logout, this mode of communication with the ordinary same client/server mode,
Broadcast communication mode is refers to the pegasus server active, to market the relevant members of the same information, such as quotation,
Communication mode and the network connection is not necessarily simple one-to-one relationship, that is, a network connection may be transmitted in a variety of different modes of communication message, a message communication mode can also be transmitted in a number of different connections,
No matter what kind of communication mode, the communication process is shown in figure 1:

FIG. 1) the communication model of the working process of the

2.2 the data flow
Market release supporting dialogue communication mode, radio communication mode:
Dialogue communication mode to support data flow:
Conversation is a two-way data flow data flow, membership system sends a request, publishing system feedback response, trading systems do not maintain dialogue flow state, system failure, dialogue data flows reset, communication may be lost on the way of data,
Radio communication mode to support the market data flow:
Data stream is a one-way data flow, released by the market system to the membership system, used to send information; Flow is a reliable data flow, the market system maintenance flow, the performance of the whole system within a day, break to restore the connection member system, may request the quotation after the system sends the specified number of streaming data,
Market services to provide content is in accordance with the subject organization, the performance of each theme includes a combination of some, also includes the content and the way of release, including market depth, sampling frequency, delay time and so on, is currently the pegasus announced by the market system reference cicc, the theme, set the theme, each market subject corresponds to a stream,
To get the quotation notice, the client must in the connection server, subscribe to one or more of the market subject,

Chapter 3 running mode
3.1 the worker thread
Traders client application is composed of two threads, at least one is the application main thread, is a trader thread API work, application and transaction system of communication is driven by API worker threads,
UstpFtdcMduserApi provided interfaces is thread-safe, there can be multiple application threads requesting at the same time,
UstpFtdcMduserSpi provided interfaces callback is driven by API worker threads, if overloaded a callback function block, is equal to block the thread API work, API and communication will stop trading system, therefore, in the callback function UstpFtdcTraderSpi derived classes, often should return quickly, can make use of the data in a buffer or by Windows message mechanism,
3.2 the local file
Traders API in the running process, some data will be written to a local file, call CreateFtdcMduserApi function, can pass a parameter to specify the storage of the local file path, the path must be created before running well, the expansion of local file names are "con",

Chapter 4 development interface
On the client system API provides two interfaces, CUstpFtdcMduserApi and CUstpFtdcMduserSpi respectively,
4.1 CUstpFtdcMduserSpi interface
CUstpFtdcMduserSpi implements the event notification interface, the user must be derived CUstpFtdcMduserSpi interface, write event handling methods to deal with events of interest,

4.4.1 OnFrontConnected method
When the client and market distribution server to establish a communication connection (not before login), the method is called,
The function prototype:
Void OnFrontConnected ();
This method calls, after finish the initialization task can be done in which the user login,
4.1.2 OnFrontDisconnected method
When the client and the transaction background communication connection is disconnected, this method is called, when this happens, the API will automatically reconnect, the client can not do,
The function prototype:
Void OnFrontDisconnected (int nReason);
Parameters:
NReason: disconnects reason
0 x1001 network reading failure
0 x1002 network write failure
0 x2001 receives a heartbeat timeout
0 x2002 send heart failure
0 x2003 you receive an error message
4.1.3 OnHeartBeatWarning method
The heartbeat timeout warnings, when long time have not received a message, this method is called,
The function prototype:
Void OnHeartBeatWarning (int nTimeLapse);
Parameters:
NTimeLapse: from the last time the received
4.1.4 OnRspUserLogin method
When the client sends the login request, this method is called, notify the client login is successful,
The function prototype:
Void OnRspUserLogin (
CUstpFtdcRspUserLoginField * pRspUserLogin,
CUstpFtdcRspInfoField * pRspInfo,
Int nRequestID,
Bool bIsLast);
Parameters:
PRspUserLogin: returns the address of the user login information,
The user login information structure:
Struct CUstpFtdcRspUserLoginField
{
///day
TUstpFtdcDateType TradingDay;
///login successful time
TUstpFtdcTimeType LoginTime;
No.///the biggest local declaration
TUstpFtdcOrderLocalIDType MaxOrderLocalID;
///transaction user code
TUstpFtdcUserIDType UserID.
///member code
TUstpFtdcParticipantIDType ParticipantID;
};

PRspInfo: returns the address of the user response information, pay special attention to in a successful response with continuous data, the intermediate may return NULL, but not for the first time, with the following, the error code of 0, said the operation is successful, the following with,
Response information structure:
Struct CUstpFtdcRspInfoField
{
///the error code
TUstpFtdcErrorIDType ErrorID;
///the error information
TUstpFtdcErrorMsgType ErrorMsg;
};

NRequestID: returns the user login request ID, the ID, designated by the user when logging in
BIsLast: indicates whether the time to return to in view of the last return nRequestID,
4.1.5 OnRspUserLogout method
When the client sends out a request, this method is called, notify the client logout success,
The function prototype:
Void OnRspUserLogout (
CUstpFtdcRspUserLogoutField * pRspUserLogout,
CUstpFtdcRspInfoField * pRspInfo,
Int nRequestID,
Bool bIsLast);
Parameters:
PRspUserLogout: return user logout information address,
User logout information structure:
Struct CUstpFtdcRspUserLogoutField
{
///transaction user code
TUstpFtdcUserIDType UserID.
///member code
TUstpFtdcParticipantIDType ParticipantID;
};

PRspInfo: returns the address of the user response information,
Response information structure:
Struct CUstpFtdcRspInfoField
{
///the error code
TUstpFtdcErrorIDType ErrorID;
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related