123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240 |
- #ifndef _CFUNC_H_
- #define _CFUNC_H_
- #include "FixValue.h"
- #include "FixValueNumber.h"
- #ifdef _cplusplus
- extern "C" {
- #endif
- typedef unsigned int uint;
- typedef signed char schar;
- typedef unsigned char uchar;
- typedef unsigned short ushort;
- typedef long long int64;
- typedef unsigned long long uint64;
- typedef struct SessionID SessionID;
- typedef struct SessionSettings SessionSettings;
- typedef struct Dictionary Dictionary;
- typedef struct Message Message;
- typedef struct AppTradeClient AppTradeClient;
- typedef struct IApplication {
- /// Notification of a session begin created
- void (*onCreate)(AppTradeClient *, SessionID *);
- /// Notification of a session successfully logging on
- void (*onLogon)(AppTradeClient *, SessionID *);
- /// Notification of a session logging off or disconnecting
- void (*onLogout)(AppTradeClient *, SessionID *);
- /// Notification of admin message being sent to target
- void (*toAdmin)(AppTradeClient *, Message *, SessionID *);
- /// Notification of app message being sent to target
- void (*toApp)(AppTradeClient *, Message *, SessionID *);
- /// Notification of admin message being received from target
- void (*fromAdmin)(AppTradeClient *, const Message *, SessionID *);
- /// Notification of app message being received from target
- void (*fromApp)(AppTradeClient *, const Message *, SessionID *);
- //为了go的调用方便,封装了这样的一个接口
- void (*defaultCallBack) (void *pfunc, AppTradeClient *, const Message *, SessionID *);
- void *onCreateCB;
- void *onLogonCB;
- void *onLogoutCB;
- void *toAdminCB;
- void *fromAdminCB;
- void *fromAppCB;
- void *toAppCB;
- } IApplication;
- //预留一点空间,现在测试的情况是最大20
- #define MAX_BID_ASK_COUNT 25
- typedef struct TickFull
- {
- double AskPrice[MAX_BID_ASK_COUNT];
- double BidPrice[MAX_BID_ASK_COUNT];
- double AskVolume[MAX_BID_ASK_COUNT];
- double BidVolume[MAX_BID_ASK_COUNT];
- char Symbol[8];
- int Time;
- int Millisecond;
- int AskCount;
- int BidCount;
- } TickFull;
- typedef struct StockInfo
- {
- char Symbol[15];
- int Position ;
- char SecurityExchange[10];
- }StockInfo;
- typedef struct OrderInfo
- {
- char OrderID[32];//Unique identifier for Order as assigned by exchange
- char SecondaryExecID[32];
- char ClOrdID[32] ;//Client side order identifier
- char OrigClOrdID[32];
- char OrdStatusReqID[32];
- char ExecID[32] ; //Execution ID for this fill.
- char Account[16];//Account ID of the current logged in LMAX member
- char SecurityID[8];
- double AvgPx ;//Calculated average price of all fills on this order.
- double CumQty;//Contains the cumulated traded quantity for the order through its life.
- double LastPx ;//Price of this fill
- double LastQty;//
- double OrderQty ;//Number of contracts submitted by the client
- double LeavesQty ;//成交手数
- double Price ;//Price per contract
- char *Text;
- int OrdRejReason;
- int TransactTime ;//Time of execution/order creation
- int Millisecond ;
- char SecurityIDSource[2];
- char TimeInForce ;//Specifies how long the order remains in effect. 0=Good for Day (GFD) 3=Immediate or Cancel (IOC) 4=Fill or Kill (FOK)Limit Orders support TimeInForce values of IOC, FOK, and GFD. Market Orders support TimeInForce values of IOC, FOK.
- char OrdType;
- char OrdStatus ;
- char Side ;//1=BUY ,2=SELL
- char ExecType ;//Describes the type of execution report. Same possible values as Order Status. 0=NEW 1=PARTIALLY FILL 2=FILL 4=CANCELED 5=REPLACE 8=REJECTED
- } OrderInfo;
- //SessionSettings api
- SessionSettings * NewSessionSettings(const char *file);
- void FreeSessionSettings(SessionSettings *obj);
- Dictionary* SessionSettingsGet(SessionSettings *ss, SessionID *sid);
- //Dictionary api
- int DictionaryHas(Dictionary *obj, const char *find);
- const char * DictionaryGetString(Dictionary *obj, const char *find);
- void FreeDictionary(Dictionary *dict);
- //message api
- Message * WarpMessage(void *msg);
- void MessageSetField(Message *msg, int field, const char *value);
- int MessageSend(Message *msg);
- char * MessageToStr(const Message *msg);
- void Free(void *);
- const Message * WarpConstMessage(const void *msg);
- void PrintHello(char *data[], int n);
- //SessionID api
- SessionID * WarpSessionID(const void *sid);
- IApplication * NewDefaultIApplication();
- void IApplicationSetCB(void *);
- IApplication * NewCBIApplication(void *cb, void *onCreate, void *onLogon, void *onLogout, void *toAdmin, void *toApp, void *fromAdmin, void *fromApp);
- IApplication * NewIApplication(void *onCreate, void *onLogon, void *onLogout, void *toAdmin, void *toApp, void *fromAdmin, void *fromApp);
- void FreeIApplication(IApplication *app);
- //application api
- AppTradeClient * NewAppTradeClient(IApplication *app, SessionSettings *setting);
- void FreeAppTradeClient(AppTradeClient * app);
- void AppTradeClientStart(AppTradeClient * app);
- void AppTradeClientStop(AppTradeClient * app);
- int AppTradeClientRun(AppTradeClient * app);
- SessionID *AppTradeClientSessionID(AppTradeClient * app);
- const char *AppTradeClientSenderCompID(AppTradeClient * app);
- const char *AppTradeClientTargetCompID(AppTradeClient * app);
- const char *AppTradeClientClOrdID(AppTradeClient * app);
- int GetMarketData(const Message *msg, TickFull *tick);
- int GetOrderInfo(const Message * msg, OrderInfo * orderinfo);
- int GetAccountStockInfo(const Message * msg, StockInfo * stockinfo ,int *bLastRptRequested);
- int GetMsgType(const Message * msg ,char * cTypeValue);
- const char * AppTradeClientOrigClOrdID(AppTradeClient * app, const Message *msg);
- int AppTradeClientSendOrder(AppTradeClient * trade, const char * aSymbol,const char *clordid, const char aHandlInst ,const char side, const char orderType,
- double qty, double price, const char *account,const char * securitytype,const char * securityexchange,const char * currency);
- int AppTradeClientTradeCaptureReportRequest(AppTradeClient * trade, const char *reqId, int reqType, char subReqType);
- int AppTradeClientOrderStatus(AppTradeClient * trade,
- const char *aSymbol,
- const char *clordId,
- //const char *ordStatusReqId,
- const char side,
- const char * account,
- const char * securitytype,
- const char * orderid
- );
- int AppTradeClientCancelOrder(AppTradeClient * trade,
- const char *aSymbol,
- const char *origClOrdID,
- const char *clordid,
- const char side,
- double qty,
- const char * account,
- const char * securitytype,
- const char * orderid );
- int AppTradeCilentOrderCancelReplace(AppTradeClient * trade,
- const char *aSymbol,
- const char * origclordid ,
- const char *clordid,
- const char aHandlInst,
- const char side,
- const char orderType,
- double price,
- double qty ,
- const char * account,
- const char * securitytype,
- const char * orderid
- );
- int AppTradeClientCollectiveOrder(AppTradeClient * trade ,
- const char *clordId,
- const char aHandlInst,
- const char ordertype,
- const char *sideStr,
- const char *symbolStr,
- const char *orderQtyStr,
- const char *priceStr,
- const char *securityExchangeStr,
- const char *currencyStr,
- const char *account,
- const char *securityTypeStr,
- const char *accountStr,
- int entrustNum
- );
- int AppTradeClientCollectiveOrderCancel(AppTradeClient * trade,
- const char *clordId,
- int entrustNum ,
- const char *entrustNoStr,
- const char *securityExchangeStr,
- const char *currencyStr,
- const char *account
- );
- int AppTradeClientCollectiveOrderStatus(AppTradeClient * trade,
- int entrustNum ,
- const char *entrustNoStr,
- const char *account
- );
- int AppTradeClientBatchOrder(AppTradeClient * trade,
- const char *clordId,
- const char aHandlInst,
- const char ordertype,
- const char **symbolStr,
- const char **sideStr,
- const char **orderQtyStr,
- const char **priceStr,
- const char **securityExchangeStr,
- const char **currencyStr,
- const char **securityTypeStr,
- const char *account,
- int num
- );
- int AppTradeClientRequestForPositions(AppTradeClient * trade,
- const char *posReqID,
- int posReqType,
- const char *account,
- int accountType
- );
- int AppTradeClientMarketData(AppTradeClient * trade, const char *bookId,const char * securityExchange);
- #ifdef _cplusplus
- }
- #endif
- #endif
|