void* __stdcall XRequest(char type, void* pApi1, void* pApi2, double double1, double double2, void* ptr1, int size1, void* ptr2, int size2, void* ptr3, int size3) { RequestType rt = (RequestType)type; switch (rt) { case RequestType_GetApiTypes: return (void*)(ApiType::ApiType_Trade | ApiType::ApiType_MarketData | ApiType::ApiType_Query); case RequestType_GetApiVersion: return (void*)"0.4.0.20161026"; case RequestType_GetApiName: return (void*)"Tdx"; case RequestType_Create: return new CTraderApi(); default: break; } if (pApi1 == nullptr) { return nullptr; } CTraderApi* pApi = GetApi(pApi1); switch (rt) { case RequestType_Release: delete pApi; return nullptr; case RequestType_Register: pApi->Register(ptr1, ptr2); break; case RequestType_Connect: pApi->Connect((const char*)ptr3, (ServerInfoField*)ptr1, (UserInfoField*)ptr2,size2); break; case RequestType_Disconnect: pApi->Disconnect(); break; case QueryType_ReqQryOrder: case QueryType_ReqQryTrade: case QueryType_ReqQryInvestorPosition: case QueryType_ReqQryTradingAccount: case QueryType_ReqQryInvestor: // 由外部调用的查询 pApi->ReqQuery((QueryType)type, (ReqQueryField*)ptr1); break; case RequestType_ReqOrderInsert: return (void*)pApi->ReqOrderInsert((OrderField*)ptr1, size1, (char*)ptr2); case RequestType_ReqOrderAction: return (void*)pApi->ReqOrderAction((OrderIDType*)ptr1, size1, (char*)ptr2); case RequestType_Subscribe: pApi->Subscribe((const char*)ptr1, (const char*)ptr2); break; default: break; } return pApi1; }
void* __stdcall XRequest(char type, void* pApi1, void* pApi2, double double1, double double2, void* ptr1, int size1, void* ptr2, int size2, void* ptr3, int size3) { RequestType rt = (RequestType)type; switch (rt) { case GetApiType: return (void*)(ApiType::ApiType_Trade | ApiType::ApiType_Instrument | ApiType::ApiType_Query); case GetApiVersion: return (void*)"0.4.0.20151124"; case GetApiName: return (void*)"CTP"; case Create: return new CTraderApi(); default: break; } if (pApi1 == nullptr) { return nullptr; } CTraderApi* pApi = GetApi(pApi1); switch (rt) { case Release: delete pApi; return nullptr; case Register: pApi->Register(ptr1, ptr2); break; case Connect: pApi->Connect((const char*)ptr3, (ServerInfoField*)ptr1, (UserInfoField*)ptr2,size2); break; case Disconnect: pApi->Disconnect(); break; case ReqQryInstrument: case ReqQryInvestorPosition: case ReqQryTradingAccount: case ReqQrySettlementInfo: pApi->ReqQuery((QueryType)type, (ReqQueryField*)ptr1); break; case ReqOrderInsert: if (double2 == 0) { return (void*)pApi->ReqOrderInsert((OrderField*)ptr1, size1, (OrderIDType*)ptr2); } //else //{ // return pApi->ReqParkedOrderInsert((int)double1, (OrderField*)ptr1, (OrderField*)ptr2); //} case ReqQuoteInsert: return pApi->ReqQuoteInsert((QuoteField*)ptr1, (OrderIDType*)ptr2, (OrderIDType*)ptr3); case ReqOrderAction: return (void*)pApi->ReqOrderAction((OrderIDType*)ptr1, size1, (OrderIDType*)ptr2); case ReqQuoteAction: return (void*)pApi->ReqQuoteAction((const char*)ptr1, (OrderIDType*)ptr2); default: break; } return pApi1; }