#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