DWORD WINAPI SendThread(LPVOID lpParam) { CTraderApi* pTrade = reinterpret_cast<CTraderApi *>(lpParam); if (pTrade) pTrade->RunInThread(); return 0; }
void* __stdcall Query(char type, void* pApi1, void* pApi2, double double1, double double2, void* ptr1, int size1, void* ptr2, int size2, void* ptr3, int size3) { // 由内部调用,不用检查是否为空 CTraderApi* pApi = (CTraderApi*)pApi2; pApi->QueryInThread(type, pApi1, pApi2, double1, double2, ptr1, size1, ptr2, size2, ptr3, size3); return nullptr; }
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; if (rt == RequestType::Create) { return new CTraderApi(); } if (pApi1 == nullptr) { return nullptr; } CTraderApi* pApi = GetApi(pApi1); switch (rt) { case Release: delete pApi; return nullptr; case Register: pApi->Register(ptr1); break; case Connect: pApi->Connect((const char*)ptr3, (ServerInfoField*)ptr1, (UserInfoField*)ptr2); break; case Disconnect: pApi->Disconnect(); break; case ReqQryInstrument: pApi->ReqQryInstrument((const char*)ptr1, (const char*)ptr2); break; case ReqQryTradingAccount: pApi->ReqQryInvestorAccount(); break; case ReqOrderInsert: return pApi->ReqOrderInsert((int)double1, (OrderField*)ptr1); //case ReqQuoteInsert: // return pApi->ReqQuoteInsert((int)double1, (OrderField*)ptr1, (OrderField*)ptr2); case ReqOrderAction: return (void*)pApi->ReqOrderAction((const char*)ptr1); break; //case RequestType::SubscribeQuote: // pApi->ReqQuoteSubscribe((const char*)ptr2, DFITC_OPT_TYPE); // break; //case RequestType::UnsubscribeQuote: // pApi->ReqQuoteUnSubscribe((const char*)ptr2, DFITC_OPT_TYPE); // 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::Trade | ApiType::QuoteRequest | ApiType::Instrument); case GetApiVersion: return (void*)"0.3.0.20150407"; case GetApiName: return (void*)"XSpeedStock"; 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); break; case Disconnect: pApi->Disconnect(); break; case ReqQryInstrument: //pApi->ReqQryInstrument((const char*)ptr1, (const char*)ptr2); break; case ReqQryTradingAccount: //pApi->ReqQryCustomerCapital(); break; //case ReqQrySettlementInfo: // pApi->ReqQrySettlementInfo((const char*)ptr1); // break; case ReqOrderInsert: return (void*)pApi->ReqOrderInsert((OrderField*)ptr1, size1, (OrderIDType*)ptr2); //case ReqQuoteInsert: // return (void*)pApi->ReqQuoteInsert((int)double1, (OrderField*)ptr1, (OrderField*)ptr2); //case ReqOrderAction: // return (void*)pApi->ReqCancelOrder((const char*)ptr1); // break; case SubscribeQuote: //pApi->ReqQuoteSubscribe((const char*)ptr2, DFITC_OPT_TYPE); break; case UnsubscribeQuote: //pApi->ReqQuoteUnSubscribe((const char*)ptr2, DFITC_OPT_TYPE); 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::Trade | ApiType::Instrument); case GetApiVersion: return (void*)"0.3.0.20150407"; case GetApiName: return (void*)"KingstarStock"; 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: pApi->ReqQryInstrument((const char*)ptr1, (const char*)ptr2); break; case ReqQryInvestorPosition: pApi->ReqQryInvestorPosition((const char*)ptr1, (const char*)ptr2); break; case ReqQryTradingAccount: pApi->ReqQryTradingAccount(); break; case ReqQrySettlementInfo: pApi->ReqQrySettlementInfo((const char*)ptr1); break;*/ case ReqOrderInsert: return (void*)pApi->ReqOrderInsert((OrderField*)ptr1, size1, (OrderIDType*)ptr2); case ReqOrderAction: return (void*)pApi->ReqOrderAction((OrderIDType*)ptr1, size1, (OrderIDType*)ptr2); /* case ReqQuoteInsert: return pApi->ReqQuoteInsert((int)double1, (QuoteField*)ptr1); case ReqOrderAction: return (void*)pApi->ReqOrderAction((const char*)ptr1); case ReqQuoteAction: return (void*)pApi->ReqQuoteAction((const char*)ptr1);*/ 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; }