diff --git a/vnpy/api/ctp/generator/generate_api_functions.py b/vnpy/api/ctp/generator/generate_api_functions.py index d9dbe612..17fa7e26 100644 --- a/vnpy/api/ctp/generator/generate_api_functions.py +++ b/vnpy/api/ctp/generator/generate_api_functions.py @@ -122,6 +122,8 @@ class ApiGenerator: args_list.append("int reqid") elif type_ == "bool": args_list.append("bool last") + elif type_ == "char*": + args_list.append("string data") elif type_ == "CThostFtdcRspInfoField": args_list.append("const dict &error") else: diff --git a/vnpy/api/da/generator/da_future_header_function.h b/vnpy/api/da/generator/da_future_header_function.h new file mode 100644 index 00000000..f7da8bc4 --- /dev/null +++ b/vnpy/api/da/generator/da_future_header_function.h @@ -0,0 +1,48 @@ +int reqUserLogin(const dict &req, int reqid); + +int reqUserLogout(const dict &req, int reqid); + +int reqSafeVerify(const dict &req, int reqid); + +int reqVerifyCode(const dict &req, int reqid); + +int reqSetVerifyQA(const dict &req, int reqid); + +int reqGetQuestion(const dict &req, int reqid); + +int reqOrderInsert(const dict &req, int reqid); + +int reqOrderModify(const dict &req, int reqid); + +int reqOrderCancel(const dict &req, int reqid); + +int reqPasswordUpdate(const dict &req, int reqid); + +int reqQryOrder(const dict &req, int reqid); + +int reqQryTrade(const dict &req, int reqid); + +int reqQryCapital(const dict &req, int reqid); + +int reqQryVersion(const dict &req, int reqid); + +int reqQryCurrency(const dict &req, int reqid); + +int reqQryExchange(const dict &req, int reqid); + +int reqQryPosition(const dict &req, int reqid); + +int reqQryStrategy(const dict &req, int reqid); + +int reqQryCommodity(const dict &req, int reqid); + +int reqQryInstrument(const dict &req, int reqid); + +int reqQryExchangeTime(const dict &req, int reqid); + +int reqQryCommodityTime(const dict &req, int reqid); + +int reqQryTotalPosition(const dict &req, int reqid); + +int reqQryStrategyDetail(const dict &req, int reqid); + diff --git a/vnpy/api/da/generator/da_future_header_on.h b/vnpy/api/da/generator/da_future_header_on.h new file mode 100644 index 00000000..ca7f64c3 --- /dev/null +++ b/vnpy/api/da/generator/da_future_header_on.h @@ -0,0 +1,66 @@ +virtual void onFrontConnected() {}; + +virtual void onFrontDisconnected(int reqid) {}; + +virtual void onHeartBeatWarning(int reqid) {}; + +virtual void onRspNeedVerify(bool last, bool last) {}; + +virtual void onRspUserLogin(const dict &data, int reqid, bool last) {}; + +virtual void onRspUserLogout(const dict &data, int reqid, bool last) {}; + +virtual void onRspVerifyCode(const dict &data, int reqid, bool last) {}; + +virtual void onRspSafeVerify(const dict &data, int reqid, bool last) {}; + +virtual void onRspSetVerifyQA(const dict &data, int reqid, bool last) {}; + +virtual void onRspAccount(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRspQuestion(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRspOrderInsert(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRspOrderModify(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRspOrderCancel(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRspPasswordUpdate(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRtnTrade(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRtnOrder(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRtnCapital(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRtnPosition(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRspQryOrder(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRspQryTrade(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRspQryCapital(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRspQryVersion(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRspQryPosition(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRspQryCurrency(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRspQryExchange(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRspQryStrategy(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRspQryCommodity(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRspQryInstrument(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRspQryExchangeTime(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRspQryCommodityTime(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRspQryTotalPosition(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRspQryStrategyDetail(const dict &data, const dict &data, int reqid, bool last) {}; + diff --git a/vnpy/api/da/generator/da_future_source_function.cpp b/vnpy/api/da/generator/da_future_source_function.cpp new file mode 100644 index 00000000..58d39a63 --- /dev/null +++ b/vnpy/api/da/generator/da_future_source_function.cpp @@ -0,0 +1,340 @@ +int FutureApi::reqUserLogin(const dict &req, int reqid) +{ + CFutureReqUserLoginField myreq = CFutureReqUserLoginField(); + memset(&myreq, 0, sizeof(myreq)); + getString(req, "UserId", myreq.UserId); + getString(req, "UserPwd", myreq.UserPwd); + getString(req, "UserType", myreq.UserType); + getString(req, "MacAddress", myreq.MacAddress); + getString(req, "ComputerName", myreq.ComputerName); + getString(req, "SoftwareName", myreq.SoftwareName); + getString(req, "SoftwareVersion", myreq.SoftwareVersion); + getString(req, "AuthorCode", myreq.AuthorCode); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqUserLogin(&myreq, reqid); + return i; +}; + +int FutureApi::reqUserLogout(const dict &req, int reqid) +{ + CFutureReqUserLogoutField myreq = CFutureReqUserLogoutField(); + memset(&myreq, 0, sizeof(myreq)); + getString(req, "UserId", myreq.UserId); + getString(req, "AccountNo", myreq.AccountNo); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqUserLogout(&myreq, reqid); + return i; +}; + +int FutureApi::reqSafeVerify(const dict &req, int reqid) +{ + CFutureReqSafeVerifyField myreq = CFutureReqSafeVerifyField(); + memset(&myreq, 0, sizeof(myreq)); + getString(req, "UserId", myreq.UserId); + getString(req, "UserPwd", myreq.UserPwd); + getString(req, "Type", myreq.Type); + getString(req, "Question", myreq.Question); + getString(req, "Answer", myreq.Answer); + getString(req, "MobileNumber", myreq.MobileNumber); + getString(req, "VerifyCode", myreq.VerifyCode); + getString(req, "SaveMac", myreq.SaveMac); + getString(req, "MacAddress", myreq.MacAddress); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqSafeVerify(&myreq, reqid); + return i; +}; + +int FutureApi::reqVerifyCode(const dict &req, int reqid) +{ + CFutureReqVerifyCodeField myreq = CFutureReqVerifyCodeField(); + memset(&myreq, 0, sizeof(myreq)); + getString(req, "UserId", myreq.UserId); + getString(req, "UserPwd", myreq.UserPwd); + getString(req, "Type", myreq.Type); + getString(req, "Question", myreq.Question); + getString(req, "Answer", myreq.Answer); + getString(req, "MobileNumber", myreq.MobileNumber); + getString(req, "VerifyCode", myreq.VerifyCode); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqVerifyCode(&myreq, reqid); + return i; +}; + +int FutureApi::reqSetVerifyQA(const dict &req, int reqid) +{ + CFutureReqSetVerifyQAField myreq = CFutureReqSetVerifyQAField(); + memset(&myreq, 0, sizeof(myreq)); + getString(req, "UserId", myreq.UserId); + getString(req, "UserPwd", myreq.UserPwd); + getString(req, "Type", myreq.Type); + getString(req, "Question", myreq.Question); + getString(req, "Answer", myreq.Answer); + getString(req, "MobileNumber", myreq.MobileNumber); + getString(req, "VerifyCode", myreq.VerifyCode); + getString(req, "SaveMac", myreq.SaveMac); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqSetVerifyQA(&myreq, reqid); + return i; +}; + +int FutureApi::reqGetQuestion(const dict &req, int reqid) +{ + CFutureReqGetQuestionField myreq = CFutureReqGetQuestionField(); + memset(&myreq, 0, sizeof(myreq)); + getInt(req, "Unused", &myreq.Unused); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqGetQuestion(&myreq, reqid); + return i; +}; + +int FutureApi::reqOrderInsert(const dict &req, int reqid) +{ + CFutureReqOrderInsertField myreq = CFutureReqOrderInsertField(); + memset(&myreq, 0, sizeof(myreq)); + getString(req, "UserId", myreq.UserId); + getString(req, "UserType", myreq.UserType); + getString(req, "AccountNo", myreq.AccountNo); + getString(req, "LocalNo", myreq.LocalNo); + getString(req, "TradePwd", myreq.TradePwd); + getString(req, "IsRiskOrder", myreq.IsRiskOrder); + getString(req, "ExchangeCode", myreq.ExchangeCode); + getString(req, "TreatyCode", myreq.TreatyCode); + getString(req, "BuySale", myreq.BuySale); + getString(req, "AddReduce", myreq.AddReduce); + getString(req, "OrderNumber", myreq.OrderNumber); + getString(req, "OrderPrice", myreq.OrderPrice); + getString(req, "TradeType", myreq.TradeType); + getString(req, "PriceType", myreq.PriceType); + getString(req, "HtsType", myreq.HtsType); + getString(req, "ForceID", myreq.ForceID); + getString(req, "TriggerPrice", myreq.TriggerPrice); + getString(req, "ValidDate", myreq.ValidDate); + getString(req, "StrategyId", myreq.StrategyId); + getString(req, "MaxShow", myreq.MaxShow); + getString(req, "MinQty", myreq.MinQty); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqOrderInsert(&myreq, reqid); + return i; +}; + +int FutureApi::reqOrderModify(const dict &req, int reqid) +{ + CFutureReqOrderModifyField myreq = CFutureReqOrderModifyField(); + memset(&myreq, 0, sizeof(myreq)); + getString(req, "SystemNo", myreq.SystemNo); + getString(req, "UserId", myreq.UserId); + getString(req, "UserType", myreq.UserType); + getString(req, "LocalNo", myreq.LocalNo); + getString(req, "AccountNo", myreq.AccountNo); + getString(req, "TradePwd", myreq.TradePwd); + getString(req, "OrderNo", myreq.OrderNo); + getString(req, "ExchangeCode", myreq.ExchangeCode); + getString(req, "TreatyCode", myreq.TreatyCode); + getString(req, "BuySale", myreq.BuySale); + getString(req, "OrderNumber", myreq.OrderNumber); + getString(req, "OrderPrice", myreq.OrderPrice); + getString(req, "FilledNumber", myreq.FilledNumber); + getString(req, "ModifyNumber", myreq.ModifyNumber); + getString(req, "ModifyPrice", myreq.ModifyPrice); + getString(req, "TradeType", myreq.TradeType); + getString(req, "PriceType", myreq.PriceType); + getString(req, "IsRiskOrder", myreq.IsRiskOrder); + getString(req, "TriggerPrice", myreq.TriggerPrice); + getString(req, "ModifyTriggerPrice", myreq.ModifyTriggerPrice); + getString(req, "ValidDate", myreq.ValidDate); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqOrderModify(&myreq, reqid); + return i; +}; + +int FutureApi::reqOrderCancel(const dict &req, int reqid) +{ + CFutureReqOrderCancelField myreq = CFutureReqOrderCancelField(); + memset(&myreq, 0, sizeof(myreq)); + getString(req, "UserId", myreq.UserId); + getString(req, "UserType", myreq.UserType); + getString(req, "LocalNo", myreq.LocalNo); + getString(req, "AccountNo", myreq.AccountNo); + getString(req, "TradePwd", myreq.TradePwd); + getString(req, "IsSimulation", myreq.IsSimulation); + getString(req, "SystemNo", myreq.SystemNo); + getString(req, "OrderNo", myreq.OrderNo); + getString(req, "ExchangeCode", myreq.ExchangeCode); + getString(req, "TreatyCode", myreq.TreatyCode); + getString(req, "BuySale", myreq.BuySale); + getString(req, "OrderNumber", myreq.OrderNumber); + getString(req, "OrderPrice", myreq.OrderPrice); + getString(req, "FilledNumber", myreq.FilledNumber); + getString(req, "TradeType", myreq.TradeType); + getString(req, "PriceType", myreq.PriceType); + getString(req, "HtsType", myreq.HtsType); + getString(req, "IsRiskOrder", myreq.IsRiskOrder); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqOrderCancel(&myreq, reqid); + return i; +}; + +int FutureApi::reqPasswordUpdate(const dict &req, int reqid) +{ + CFutureReqPasswordUpdateField myreq = CFutureReqPasswordUpdateField(); + memset(&myreq, 0, sizeof(myreq)); + getString(req, "UserId", myreq.UserId); + getString(req, "OldPassword", myreq.OldPassword); + getString(req, "NewPassword", myreq.NewPassword); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqPasswordUpdate(&myreq, reqid); + return i; +}; + +int FutureApi::reqQryOrder(const dict &req, int reqid) +{ + CFutureQryOrderField myreq = CFutureQryOrderField(); + memset(&myreq, 0, sizeof(myreq)); + getString(req, "UserId", myreq.UserId); + getString(req, "UserType", myreq.UserType); + getString(req, "AccountNo", myreq.AccountNo); + getString(req, "TradePwd", myreq.TradePwd); + getString(req, "IsSimulation", myreq.IsSimulation); + getString(req, "OrderNo", myreq.OrderNo); + getString(req, "OrderDateTime", myreq.OrderDateTime); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqQryOrder(&myreq, reqid); + return i; +}; + +int FutureApi::reqQryTrade(const dict &req, int reqid) +{ + CFutureQryTradeField myreq = CFutureQryTradeField(); + memset(&myreq, 0, sizeof(myreq)); + getString(req, "UserId", myreq.UserId); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqQryTrade(&myreq, reqid); + return i; +}; + +int FutureApi::reqQryCapital(const dict &req, int reqid) +{ + CFutureQryCapitalField myreq = CFutureQryCapitalField(); + memset(&myreq, 0, sizeof(myreq)); + getChar(req, "Unused", &myreq.Unused); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqQryCapital(&myreq, reqid); + return i; +}; + +int FutureApi::reqQryVersion(const dict &req, int reqid) +{ + CFutureQryVersionField myreq = CFutureQryVersionField(); + memset(&myreq, 0, sizeof(myreq)); + getString(req, "UserId", myreq.UserId); + getString(req, "UserPwd", myreq.UserPwd); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqQryVersion(&myreq, reqid); + return i; +}; + +int FutureApi::reqQryCurrency(const dict &req, int reqid) +{ + CFutureQryCurrencyField myreq = CFutureQryCurrencyField(); + memset(&myreq, 0, sizeof(myreq)); + getChar(req, "Unused", &myreq.Unused); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqQryCurrency(&myreq, reqid); + return i; +}; + +int FutureApi::reqQryExchange(const dict &req, int reqid) +{ + CFutureQryExchangeField myreq = CFutureQryExchangeField(); + memset(&myreq, 0, sizeof(myreq)); + getString(req, "ProductGroupID", myreq.ProductGroupID); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqQryExchange(&myreq, reqid); + return i; +}; + +int FutureApi::reqQryPosition(const dict &req, int reqid) +{ + CFutureQryPositionField myreq = CFutureQryPositionField(); + memset(&myreq, 0, sizeof(myreq)); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqQryPosition(&myreq, reqid); + return i; +}; + +int FutureApi::reqQryStrategy(const dict &req, int reqid) +{ + CFutureQryStrategyField myreq = CFutureQryStrategyField(); + memset(&myreq, 0, sizeof(myreq)); + getString(req, "ExchangeNo", myreq.ExchangeNo); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqQryStrategy(&myreq, reqid); + return i; +}; + +int FutureApi::reqQryCommodity(const dict &req, int reqid) +{ + CFutureQryCommodityField myreq = CFutureQryCommodityField(); + memset(&myreq, 0, sizeof(myreq)); + getString(req, "UpdateDate", myreq.UpdateDate); + getString(req, "ExchangeNo", myreq.ExchangeNo); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqQryCommodity(&myreq, reqid); + return i; +}; + +int FutureApi::reqQryInstrument(const dict &req, int reqid) +{ + CFutureQryInstrumentField myreq = CFutureQryInstrumentField(); + memset(&myreq, 0, sizeof(myreq)); + getInt(req, "PageIndex", &myreq.PageIndex); + getString(req, "ExchangeNo", myreq.ExchangeNo); + getString(req, "CommodityNo", myreq.CommodityNo); + getString(req, "CommodityType", myreq.CommodityType); + getString(req, "ContractNo", myreq.ContractNo); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqQryInstrument(&myreq, reqid); + return i; +}; + +int FutureApi::reqQryExchangeTime(const dict &req, int reqid) +{ + CFutureQryExchangeTimeField myreq = CFutureQryExchangeTimeField(); + memset(&myreq, 0, sizeof(myreq)); + getChar(req, "Unused", &myreq.Unused); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqQryExchangeTime(&myreq, reqid); + return i; +}; + +int FutureApi::reqQryCommodityTime(const dict &req, int reqid) +{ + CFutureQryCommodityTimeField myreq = CFutureQryCommodityTimeField(); + memset(&myreq, 0, sizeof(myreq)); + getString(req, "ExchangeNo", myreq.ExchangeNo); + getString(req, "CommodityNo", myreq.CommodityNo); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqQryCommodityTime(&myreq, reqid); + return i; +}; + +int FutureApi::reqQryTotalPosition(const dict &req, int reqid) +{ + CFutureQryTotalPositionField myreq = CFutureQryTotalPositionField(); + memset(&myreq, 0, sizeof(myreq)); + getString(req, "AccountNo", myreq.AccountNo); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqQryTotalPosition(&myreq, reqid); + return i; +}; + +int FutureApi::reqQryStrategyDetail(const dict &req, int reqid) +{ + CFutureQryStrategyDetailField myreq = CFutureQryStrategyDetailField(); + memset(&myreq, 0, sizeof(myreq)); + getString(req, "StartegyCommodityNo", myreq.StartegyCommodityNo); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqQryStrategyDetail(&myreq, reqid); + return i; +}; + diff --git a/vnpy/api/da/generator/da_future_source_module.cpp b/vnpy/api/da/generator/da_future_source_module.cpp new file mode 100644 index 00000000..fea5fa0a --- /dev/null +++ b/vnpy/api/da/generator/da_future_source_module.cpp @@ -0,0 +1,59 @@ +.def("reqUserLogin", &FutureApi::reqUserLogin) +.def("reqUserLogout", &FutureApi::reqUserLogout) +.def("reqSafeVerify", &FutureApi::reqSafeVerify) +.def("reqVerifyCode", &FutureApi::reqVerifyCode) +.def("reqSetVerifyQA", &FutureApi::reqSetVerifyQA) +.def("reqGetQuestion", &FutureApi::reqGetQuestion) +.def("reqOrderInsert", &FutureApi::reqOrderInsert) +.def("reqOrderModify", &FutureApi::reqOrderModify) +.def("reqOrderCancel", &FutureApi::reqOrderCancel) +.def("reqPasswordUpdate", &FutureApi::reqPasswordUpdate) +.def("reqQryOrder", &FutureApi::reqQryOrder) +.def("reqQryTrade", &FutureApi::reqQryTrade) +.def("reqQryCapital", &FutureApi::reqQryCapital) +.def("reqQryVersion", &FutureApi::reqQryVersion) +.def("reqQryCurrency", &FutureApi::reqQryCurrency) +.def("reqQryExchange", &FutureApi::reqQryExchange) +.def("reqQryPosition", &FutureApi::reqQryPosition) +.def("reqQryStrategy", &FutureApi::reqQryStrategy) +.def("reqQryCommodity", &FutureApi::reqQryCommodity) +.def("reqQryInstrument", &FutureApi::reqQryInstrument) +.def("reqQryExchangeTime", &FutureApi::reqQryExchangeTime) +.def("reqQryCommodityTime", &FutureApi::reqQryCommodityTime) +.def("reqQryTotalPosition", &FutureApi::reqQryTotalPosition) +.def("reqQryStrategyDetail", &FutureApi::reqQryStrategyDetail) + +.def("onFrontConnected", &FutureApi::onFrontConnected) +.def("onFrontDisconnected", &FutureApi::onFrontDisconnected) +.def("onHeartBeatWarning", &FutureApi::onHeartBeatWarning) +.def("onRspNeedVerify", &FutureApi::onRspNeedVerify) +.def("onRspUserLogin", &FutureApi::onRspUserLogin) +.def("onRspUserLogout", &FutureApi::onRspUserLogout) +.def("onRspVerifyCode", &FutureApi::onRspVerifyCode) +.def("onRspSafeVerify", &FutureApi::onRspSafeVerify) +.def("onRspSetVerifyQA", &FutureApi::onRspSetVerifyQA) +.def("onRspAccount", &FutureApi::onRspAccount) +.def("onRspQuestion", &FutureApi::onRspQuestion) +.def("onRspOrderInsert", &FutureApi::onRspOrderInsert) +.def("onRspOrderModify", &FutureApi::onRspOrderModify) +.def("onRspOrderCancel", &FutureApi::onRspOrderCancel) +.def("onRspPasswordUpdate", &FutureApi::onRspPasswordUpdate) +.def("onRtnTrade", &FutureApi::onRtnTrade) +.def("onRtnOrder", &FutureApi::onRtnOrder) +.def("onRtnCapital", &FutureApi::onRtnCapital) +.def("onRtnPosition", &FutureApi::onRtnPosition) +.def("onRspQryOrder", &FutureApi::onRspQryOrder) +.def("onRspQryTrade", &FutureApi::onRspQryTrade) +.def("onRspQryCapital", &FutureApi::onRspQryCapital) +.def("onRspQryVersion", &FutureApi::onRspQryVersion) +.def("onRspQryPosition", &FutureApi::onRspQryPosition) +.def("onRspQryCurrency", &FutureApi::onRspQryCurrency) +.def("onRspQryExchange", &FutureApi::onRspQryExchange) +.def("onRspQryStrategy", &FutureApi::onRspQryStrategy) +.def("onRspQryCommodity", &FutureApi::onRspQryCommodity) +.def("onRspQryInstrument", &FutureApi::onRspQryInstrument) +.def("onRspQryExchangeTime", &FutureApi::onRspQryExchangeTime) +.def("onRspQryCommodityTime", &FutureApi::onRspQryCommodityTime) +.def("onRspQryTotalPosition", &FutureApi::onRspQryTotalPosition) +.def("onRspQryStrategyDetail", &FutureApi::onRspQryStrategyDetail) +; diff --git a/vnpy/api/da/generator/da_future_source_on.cpp b/vnpy/api/da/generator/da_future_source_on.cpp new file mode 100644 index 00000000..fe02fbcf --- /dev/null +++ b/vnpy/api/da/generator/da_future_source_on.cpp @@ -0,0 +1,396 @@ +void onFrontConnected() override +{ + try + { + PYBIND11_OVERLOAD(void, FutureApi, onFrontConnected); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onFrontDisconnected(int reqid) override +{ + try + { + PYBIND11_OVERLOAD(void, FutureApi, onFrontDisconnected, reqid); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onHeartBeatWarning(int reqid) override +{ + try + { + PYBIND11_OVERLOAD(void, FutureApi, onHeartBeatWarning, reqid); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspNeedVerify(bool last, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, FutureApi, onRspNeedVerify, last, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspUserLogin(const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, FutureApi, onRspUserLogin, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspUserLogout(const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, FutureApi, onRspUserLogout, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspVerifyCode(const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, FutureApi, onRspVerifyCode, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspSafeVerify(const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, FutureApi, onRspSafeVerify, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspSetVerifyQA(const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, FutureApi, onRspSetVerifyQA, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspAccount(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, FutureApi, onRspAccount, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspQuestion(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, FutureApi, onRspQuestion, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspOrderInsert(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, FutureApi, onRspOrderInsert, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspOrderModify(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, FutureApi, onRspOrderModify, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspOrderCancel(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, FutureApi, onRspOrderCancel, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspPasswordUpdate(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, FutureApi, onRspPasswordUpdate, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRtnTrade(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, FutureApi, onRtnTrade, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRtnOrder(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, FutureApi, onRtnOrder, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRtnCapital(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, FutureApi, onRtnCapital, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRtnPosition(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, FutureApi, onRtnPosition, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspQryOrder(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, FutureApi, onRspQryOrder, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspQryTrade(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, FutureApi, onRspQryTrade, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspQryCapital(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, FutureApi, onRspQryCapital, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspQryVersion(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, FutureApi, onRspQryVersion, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspQryPosition(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, FutureApi, onRspQryPosition, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspQryCurrency(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, FutureApi, onRspQryCurrency, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspQryExchange(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, FutureApi, onRspQryExchange, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspQryStrategy(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, FutureApi, onRspQryStrategy, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspQryCommodity(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, FutureApi, onRspQryCommodity, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspQryInstrument(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, FutureApi, onRspQryInstrument, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspQryExchangeTime(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, FutureApi, onRspQryExchangeTime, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspQryCommodityTime(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, FutureApi, onRspQryCommodityTime, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspQryTotalPosition(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, FutureApi, onRspQryTotalPosition, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspQryStrategyDetail(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, FutureApi, onRspQryStrategyDetail, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + diff --git a/vnpy/api/da/generator/da_future_source_task.cpp b/vnpy/api/da/generator/da_future_source_task.cpp new file mode 100644 index 00000000..19e3d6b0 --- /dev/null +++ b/vnpy/api/da/generator/da_future_source_task.cpp @@ -0,0 +1,992 @@ +void FutureApi::OnFrontConnected() +{ + gil_scoped_acquire acquire; + this->onFrontConnected(); +}; + +void FutureApi::OnFrontDisconnected(int iReason) +{ + gil_scoped_acquire acquire; + this->onFrontDisconnected(iReason); +}; + +void FutureApi::OnHeartBeatWarning(int iTimeLapse) +{ + gil_scoped_acquire acquire; + this->onHeartBeatWarning(iTimeLapse); +}; + +void FutureApi::OnRspNeedVerify(bool bFirstLogin, bool bHasSetQA) +{ + gil_scoped_acquire acquire; + this->onRspNeedVerify(bFirstLogin, bHasSetQA); +}; + +void FutureApi::OnRspUserLogin(CFutureRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspUserLogin(data, iRequestID, bIsLast); +}; + +void FutureApi::OnRspUserLogout(CFutureRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspUserLogout(data, iRequestID, bIsLast); +}; + +void FutureApi::OnRspVerifyCode(CFutureRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspVerifyCode(data, iRequestID, bIsLast); +}; + +void FutureApi::OnRspSafeVerify(CFutureRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspSafeVerify(data, iRequestID, bIsLast); +}; + +void FutureApi::OnRspSetVerifyQA(CFutureRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspSetVerifyQA(data, iRequestID, bIsLast); +}; + +void FutureApi::OnRspAccount(CFutureRspAccountField *pRspAccount, CFutureRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspAccount) + { + data["UserId"] = toUtf(pRspAccount->UserId); + data["UserName"] = toUtf(pRspAccount->UserName); + data["UserType"] = toUtf(pRspAccount->UserType); + data["LoginPwd"] = toUtf(pRspAccount->LoginPwd); + data["AccountNo"] = toUtf(pRspAccount->AccountNo); + data["TradePwd"] = toUtf(pRspAccount->TradePwd); + data["IsSimulation"] = toUtf(pRspAccount->IsSimulation); + data["FrontendIp"] = toUtf(pRspAccount->FrontendIp); + data["FrontendPort"] = toUtf(pRspAccount->FrontendPort); + data["CurrencyNo"] = toUtf(pRspAccount->CurrencyNo); + data["UserState"] = toUtf(pRspAccount->UserState); + data["SelAll"] = toUtf(pRspAccount->SelAll); + data["Strategy"] = toUtf(pRspAccount->Strategy); + data["Inner"] = toUtf(pRspAccount->Inner); + data["YingSun"] = toUtf(pRspAccount->YingSun); + data["ChaoDan"] = toUtf(pRspAccount->ChaoDan); + data["Option"] = toUtf(pRspAccount->Option); + data["CmeMarket"] = toUtf(pRspAccount->CmeMarket); + data["CmeCOMEXMarket"] = toUtf(pRspAccount->CmeCOMEXMarket); + data["CmeNYMEXMarket"] = toUtf(pRspAccount->CmeNYMEXMarket); + data["CmeCBTMarket"] = toUtf(pRspAccount->CmeCBTMarket); + data["IceUSMarket"] = toUtf(pRspAccount->IceUSMarket); + data["IceECMarket"] = toUtf(pRspAccount->IceECMarket); + data["IceEFMarket"] = toUtf(pRspAccount->IceEFMarket); + data["CanTradeStockHK"] = toUtf(pRspAccount->CanTradeStockHK); + data["CanTradeStockAM"] = toUtf(pRspAccount->CanTradeStockAM); + data["MultiLogin"] = toUtf(pRspAccount->MultiLogin); + data["SellStockHK"] = toUtf(pRspAccount->SellStockHK); + data["SellStockAM"] = toUtf(pRspAccount->SellStockAM); + data["CanTradeStockKRX"] = toUtf(pRspAccount->CanTradeStockKRX); + data["HkexMarket"] = toUtf(pRspAccount->HkexMarket); + data["IdNumber"] = toUtf(pRspAccount->IdNumber); + data["HkexMarketFee"] = toUtf(pRspAccount->HkexMarketFee); + data["IsProfessional"] = toUtf(pRspAccount->IsProfessional); + data["IsOverSea"] = toUtf(pRspAccount->IsOverSea); + data["IsFirstLogin"] = toUtf(pRspAccount->IsFirstLogin); + data["UserMobile"] = toUtf(pRspAccount->UserMobile); + data["HasSetQA"] = toUtf(pRspAccount->HasSetQA); + data["CanTradeStockSGXQ"] = toUtf(pRspAccount->CanTradeStockSGXQ); + data["ExistMac"] = toUtf(pRspAccount->ExistMac); + data["RatioINE"] = toUtf(pRspAccount->RatioINE); + data["EurexMarket"] = toUtf(pRspAccount->EurexMarket); + data["HkexIsOverMaxTerminal"] = toUtf(pRspAccount->HkexIsOverMaxTerminal); + data["HkexOverMoney"] = toUtf(pRspAccount->HkexOverMoney); + data["CanTradeStockAU"] = toUtf(pRspAccount->CanTradeStockAU); + data["NyFlag"] = toUtf(pRspAccount->NyFlag); + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspAccount(data, data, iRequestID, bIsLast); +}; + +void FutureApi::OnRspQuestion(CFutureRspQuestionField *pRspVersion, CFutureRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspVersion) + { + data["QuestionType"] = toUtf(pRspVersion->QuestionType); + data["QuestionId"] = toUtf(pRspVersion->QuestionId); + data["QuestionCN"] = toUtf(pRspVersion->QuestionCN); + data["QuestionEN"] = toUtf(pRspVersion->QuestionEN); + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspQuestion(data, data, iRequestID, bIsLast); +}; + +void FutureApi::OnRspOrderInsert(CFutureRspOrderInsertField *pRspOrderInsert, CFutureRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspOrderInsert) + { + data["UserId"] = toUtf(pRspOrderInsert->UserId); + data["AccountNo"] = toUtf(pRspOrderInsert->AccountNo); + data["SystemNo"] = toUtf(pRspOrderInsert->SystemNo); + data["LocalNo"] = toUtf(pRspOrderInsert->LocalNo); + data["OrderNo"] = toUtf(pRspOrderInsert->OrderNo); + data["OrigOrderNo"] = toUtf(pRspOrderInsert->OrigOrderNo); + data["OrderMethod"] = toUtf(pRspOrderInsert->OrderMethod); + data["AcceptType"] = toUtf(pRspOrderInsert->AcceptType); + data["ExchangeCode"] = toUtf(pRspOrderInsert->ExchangeCode); + data["TreatyCode"] = toUtf(pRspOrderInsert->TreatyCode); + data["BuySale"] = toUtf(pRspOrderInsert->BuySale); + data["OrderNumber"] = toUtf(pRspOrderInsert->OrderNumber); + data["OrderPrice"] = toUtf(pRspOrderInsert->OrderPrice); + data["FilledNumber"] = toUtf(pRspOrderInsert->FilledNumber); + data["FilledPrice"] = toUtf(pRspOrderInsert->FilledPrice); + data["TradeType"] = toUtf(pRspOrderInsert->TradeType); + data["PriceType"] = toUtf(pRspOrderInsert->PriceType); + data["HtsType"] = toUtf(pRspOrderInsert->HtsType); + data["OrderDate"] = toUtf(pRspOrderInsert->OrderDate); + data["OrderTime"] = toUtf(pRspOrderInsert->OrderTime); + data["ErrorCode"] = toUtf(pRspOrderInsert->ErrorCode); + data["OrderState"] = toUtf(pRspOrderInsert->OrderState); + data["IsRiskOrder"] = toUtf(pRspOrderInsert->IsRiskOrder); + data["CancelUserId"] = toUtf(pRspOrderInsert->CancelUserId); + data["TriggerPrice"] = toUtf(pRspOrderInsert->TriggerPrice); + data["ValidDate"] = toUtf(pRspOrderInsert->ValidDate); + data["AddReduce"] = toUtf(pRspOrderInsert->AddReduce); + data["StrategyId"] = toUtf(pRspOrderInsert->StrategyId); + data["MaxShow"] = toUtf(pRspOrderInsert->MaxShow); + data["MinQty"] = toUtf(pRspOrderInsert->MinQty); + data["ExchangeTime"] = toUtf(pRspOrderInsert->ExchangeTime); + data["CancelTime"] = toUtf(pRspOrderInsert->CancelTime); + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspOrderInsert(data, data, iRequestID, bIsLast); +}; + +void FutureApi::OnRspOrderModify(CFutureRspOrderModifyField *pRspOrderModify, CFutureRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspOrderModify) + { + data["UserId"] = toUtf(pRspOrderModify->UserId); + data["AccountNo"] = toUtf(pRspOrderModify->AccountNo); + data["SystemNo"] = toUtf(pRspOrderModify->SystemNo); + data["LocalNo"] = toUtf(pRspOrderModify->LocalNo); + data["OrderNo"] = toUtf(pRspOrderModify->OrderNo); + data["OrigOrderNo"] = toUtf(pRspOrderModify->OrigOrderNo); + data["OrderMethod"] = toUtf(pRspOrderModify->OrderMethod); + data["AcceptType"] = toUtf(pRspOrderModify->AcceptType); + data["ExchangeCode"] = toUtf(pRspOrderModify->ExchangeCode); + data["TreatyCode"] = toUtf(pRspOrderModify->TreatyCode); + data["BuySale"] = toUtf(pRspOrderModify->BuySale); + data["OrderNumber"] = toUtf(pRspOrderModify->OrderNumber); + data["OrderPrice"] = toUtf(pRspOrderModify->OrderPrice); + data["FilledNumber"] = toUtf(pRspOrderModify->FilledNumber); + data["FilledPrice"] = toUtf(pRspOrderModify->FilledPrice); + data["TradeType"] = toUtf(pRspOrderModify->TradeType); + data["PriceType"] = toUtf(pRspOrderModify->PriceType); + data["HtsType"] = toUtf(pRspOrderModify->HtsType); + data["OrderDate"] = toUtf(pRspOrderModify->OrderDate); + data["OrderTime"] = toUtf(pRspOrderModify->OrderTime); + data["ErrorCode"] = toUtf(pRspOrderModify->ErrorCode); + data["OrderState"] = toUtf(pRspOrderModify->OrderState); + data["IsRiskOrder"] = toUtf(pRspOrderModify->IsRiskOrder); + data["CancelUserId"] = toUtf(pRspOrderModify->CancelUserId); + data["TriggerPrice"] = toUtf(pRspOrderModify->TriggerPrice); + data["ValidDate"] = toUtf(pRspOrderModify->ValidDate); + data["AddReduce"] = toUtf(pRspOrderModify->AddReduce); + data["StrategyId"] = toUtf(pRspOrderModify->StrategyId); + data["MaxShow"] = toUtf(pRspOrderModify->MaxShow); + data["MinQty"] = toUtf(pRspOrderModify->MinQty); + data["ExchangeTime"] = toUtf(pRspOrderModify->ExchangeTime); + data["CancelTime"] = toUtf(pRspOrderModify->CancelTime); + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspOrderModify(data, data, iRequestID, bIsLast); +}; + +void FutureApi::OnRspOrderCancel(CFutureRspOrderCancelField *pRspOrderCancel, CFutureRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspOrderCancel) + { + data["UserId"] = toUtf(pRspOrderCancel->UserId); + data["AccountNo"] = toUtf(pRspOrderCancel->AccountNo); + data["SystemNo"] = toUtf(pRspOrderCancel->SystemNo); + data["LocalNo"] = toUtf(pRspOrderCancel->LocalNo); + data["OrderNo"] = toUtf(pRspOrderCancel->OrderNo); + data["CancelNo"] = toUtf(pRspOrderCancel->CancelNo); + data["ExchangeCode"] = toUtf(pRspOrderCancel->ExchangeCode); + data["TreatyCode"] = toUtf(pRspOrderCancel->TreatyCode); + data["BuySale"] = toUtf(pRspOrderCancel->BuySale); + data["OrderNumber"] = toUtf(pRspOrderCancel->OrderNumber); + data["OrderPrice"] = toUtf(pRspOrderCancel->OrderPrice); + data["FilledNumber"] = toUtf(pRspOrderCancel->FilledNumber); + data["CancelNumber"] = toUtf(pRspOrderCancel->CancelNumber); + data["TradeType"] = toUtf(pRspOrderCancel->TradeType); + data["PriceType"] = toUtf(pRspOrderCancel->PriceType); + data["HtsType"] = toUtf(pRspOrderCancel->HtsType); + data["CancelDate"] = toUtf(pRspOrderCancel->CancelDate); + data["CancelTime"] = toUtf(pRspOrderCancel->CancelTime); + data["ErrorCode"] = toUtf(pRspOrderCancel->ErrorCode); + data["IsRiskOrder"] = toUtf(pRspOrderCancel->IsRiskOrder); + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspOrderCancel(data, data, iRequestID, bIsLast); +}; + +void FutureApi::OnRspPasswordUpdate(CFutureRspPasswordUpdateField *pRspPasswordUpdate, CFutureRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspPasswordUpdate) + { + data["UserId"] = toUtf(pRspPasswordUpdate->UserId); + data["OldPassword"] = toUtf(pRspPasswordUpdate->OldPassword); + data["NewPassword"] = toUtf(pRspPasswordUpdate->NewPassword); + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspPasswordUpdate(data, data, iRequestID, bIsLast); +}; + +void FutureApi::OnRtnTrade(CFutureRtnTradeField *pRtnTrade, CFutureRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRtnTrade) + { + data["UserId"] = toUtf(pRtnTrade->UserId); + data["AccountNo"] = toUtf(pRtnTrade->AccountNo); + data["FilledNo"] = toUtf(pRtnTrade->FilledNo); + data["OrderNo"] = toUtf(pRtnTrade->OrderNo); + data["SystemNo"] = toUtf(pRtnTrade->SystemNo); + data["LocalNo"] = toUtf(pRtnTrade->LocalNo); + data["ExchangeCode"] = toUtf(pRtnTrade->ExchangeCode); + data["TreatyCode"] = toUtf(pRtnTrade->TreatyCode); + data["BuySale"] = toUtf(pRtnTrade->BuySale); + data["FilledNumber"] = toUtf(pRtnTrade->FilledNumber); + data["FilledPrice"] = toUtf(pRtnTrade->FilledPrice); + data["FilledDate"] = toUtf(pRtnTrade->FilledDate); + data["FilledTime"] = toUtf(pRtnTrade->FilledTime); + data["Commsion"] = toUtf(pRtnTrade->Commsion); + data["OrderNumber"] = toUtf(pRtnTrade->OrderNumber); + data["OrderPrice"] = toUtf(pRtnTrade->OrderPrice); + data["DeliveryDate"] = toUtf(pRtnTrade->DeliveryDate); + data["FilledType"] = toUtf(pRtnTrade->FilledType); + data["OrderType"] = toUtf(pRtnTrade->OrderType); + data["ValidDate"] = toUtf(pRtnTrade->ValidDate); + data["AddReduce"] = toUtf(pRtnTrade->AddReduce); + data["ErrorDescription"] = toUtf(pRtnTrade->ErrorDescription); + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRtnTrade(data, data, iRequestID, bIsLast); +}; + +void FutureApi::OnRtnOrder(CFutureRtnOrderField *pRtnOrder, CFutureRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRtnOrder) + { + data["LocalOrderNo"] = toUtf(pRtnOrder->LocalOrderNo); + data["ExchangeNo"] = toUtf(pRtnOrder->ExchangeNo); + data["TreatyCode"] = toUtf(pRtnOrder->TreatyCode); + data["OrderNo"] = toUtf(pRtnOrder->OrderNo); + data["OrderNumber"] = pRtnOrder->OrderNumber; + data["FilledNumber"] = pRtnOrder->FilledNumber; + data["FilledAdvPrice"] = pRtnOrder->FilledAdvPrice; + data["BuyHoldNumber"] = pRtnOrder->BuyHoldNumber; + data["BuyHoldOpenPrice"] = pRtnOrder->BuyHoldOpenPrice; + data["BuyHoldPrice"] = pRtnOrder->BuyHoldPrice; + data["SaleHoldNumber"] = pRtnOrder->SaleHoldNumber; + data["SaleHoldOpenPrice"] = pRtnOrder->SaleHoldOpenPrice; + data["SaleHoldPrice"] = pRtnOrder->SaleHoldPrice; + data["IsCanceled"] = toUtf(pRtnOrder->IsCanceled); + data["FilledTotalFee"] = pRtnOrder->FilledTotalFee; + data["Status"] = pRtnOrder->Status; + data["AccountNo"] = toUtf(pRtnOrder->AccountNo); + data["HoldType"] = toUtf(pRtnOrder->HoldType); + data["HoldMarginBuy"] = pRtnOrder->HoldMarginBuy; + data["HoldMarginSale"] = pRtnOrder->HoldMarginSale; + data["CurrPrice"] = pRtnOrder->CurrPrice; + data["FloatProfit"] = pRtnOrder->FloatProfit; + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRtnOrder(data, data, iRequestID, bIsLast); +}; + +void FutureApi::OnRtnCapital(CFutureRtnCapitalField *pRtnCapital, CFutureRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRtnCapital) + { + data["ClientNo"] = toUtf(pRtnCapital->ClientNo); + data["AccountNo"] = toUtf(pRtnCapital->AccountNo); + data["CurrencyNo"] = toUtf(pRtnCapital->CurrencyNo); + data["Available"] = pRtnCapital->Available; + data["YAvailable"] = pRtnCapital->YAvailable; + data["CanCashOut"] = pRtnCapital->CanCashOut; + data["Money"] = pRtnCapital->Money; + data["ExpiredProfit"] = pRtnCapital->ExpiredProfit; + data["FrozenDeposit"] = pRtnCapital->FrozenDeposit; + data["Fee"] = pRtnCapital->Fee; + data["Deposit"] = pRtnCapital->Deposit; + data["KeepDeposit"] = pRtnCapital->KeepDeposit; + data["Status"] = pRtnCapital->Status; + data["InMoney"] = pRtnCapital->InMoney; + data["OutMoney"] = pRtnCapital->OutMoney; + data["UnexpiredProfit"] = pRtnCapital->UnexpiredProfit; + data["TodayTotal"] = pRtnCapital->TodayTotal; + data["UnaccountProfit"] = pRtnCapital->UnaccountProfit; + data["Royalty"] = pRtnCapital->Royalty; + data["ExchangeNo"] = toUtf(pRtnCapital->ExchangeNo); + data["TreatyCode"] = toUtf(pRtnCapital->TreatyCode); + data["OrderNo"] = toUtf(pRtnCapital->OrderNo); + data["OrderNumber"] = pRtnCapital->OrderNumber; + data["FilledNumber"] = pRtnCapital->FilledNumber; + data["FilledAdvPrice"] = pRtnCapital->FilledAdvPrice; + data["BuyHoldNumber"] = pRtnCapital->BuyHoldNumber; + data["BuyHoldOpenPrice"] = pRtnCapital->BuyHoldOpenPrice; + data["BuyHoldPrice"] = pRtnCapital->BuyHoldPrice; + data["SaleHoldNumber"] = pRtnCapital->SaleHoldNumber; + data["SaleHoldOpenPrice"] = pRtnCapital->SaleHoldOpenPrice; + data["SaleHoldPrice"] = pRtnCapital->SaleHoldPrice; + data["IsCanceled"] = toUtf(pRtnCapital->IsCanceled); + data["FilledTotalFee"] = pRtnCapital->FilledTotalFee; + data["Credit"] = pRtnCapital->Credit; + data["MarginLimit"] = pRtnCapital->MarginLimit; + data["BorrowValue"] = pRtnCapital->BorrowValue; + data["MortgageMoney"] = pRtnCapital->MortgageMoney; + data["T1"] = pRtnCapital->T1; + data["T2"] = pRtnCapital->T2; + data["T3"] = pRtnCapital->T3; + data["TN"] = pRtnCapital->TN; + data["TradeLimit"] = pRtnCapital->TradeLimit; + data["FCrossMax"] = pRtnCapital->FCrossMax; + data["SellFreezenMoney"] = pRtnCapital->SellFreezenMoney; + data["SellInterest"] = pRtnCapital->SellInterest; + data["SellNeedAddMargin"] = pRtnCapital->SellNeedAddMargin; + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRtnCapital(data, data, iRequestID, bIsLast); +}; + +void FutureApi::OnRtnPosition(CFutureRtnPositionField *pRtnPosition, CFutureRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRtnPosition) + { + data["LocalOrderNo"] = toUtf(pRtnPosition->LocalOrderNo); + data["ExchangeNo"] = toUtf(pRtnPosition->ExchangeNo); + data["TreatyCode"] = toUtf(pRtnPosition->TreatyCode); + data["OrderNo"] = toUtf(pRtnPosition->OrderNo); + data["OrderNumber"] = pRtnPosition->OrderNumber; + data["FilledNumber"] = pRtnPosition->FilledNumber; + data["FilledAdvPrice"] = pRtnPosition->FilledAdvPrice; + data["BuyHoldNumber"] = pRtnPosition->BuyHoldNumber; + data["BuyHoldOpenPrice"] = pRtnPosition->BuyHoldOpenPrice; + data["BuyHoldPrice"] = pRtnPosition->BuyHoldPrice; + data["SaleHoldNumber"] = pRtnPosition->SaleHoldNumber; + data["SaleHoldOpenPrice"] = pRtnPosition->SaleHoldOpenPrice; + data["SaleHoldPrice"] = pRtnPosition->SaleHoldPrice; + data["IsCanceled"] = toUtf(pRtnPosition->IsCanceled); + data["FilledTotalFee"] = pRtnPosition->FilledTotalFee; + data["Status"] = pRtnPosition->Status; + data["AccountNo"] = toUtf(pRtnPosition->AccountNo); + data["HoldType"] = toUtf(pRtnPosition->HoldType); + data["HoldMarginBuy"] = pRtnPosition->HoldMarginBuy; + data["HoldMarginSale"] = pRtnPosition->HoldMarginSale; + data["CurrPrice"] = pRtnPosition->CurrPrice; + data["FloatProfit"] = pRtnPosition->FloatProfit; + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRtnPosition(data, data, iRequestID, bIsLast); +}; + +void FutureApi::OnRspQryOrder(CFutureRspOrderField *pRspOrder, CFutureRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspOrder) + { + data["UserId"] = toUtf(pRspOrder->UserId); + data["AccountNo"] = toUtf(pRspOrder->AccountNo); + data["SystemNo"] = toUtf(pRspOrder->SystemNo); + data["LocalNo"] = toUtf(pRspOrder->LocalNo); + data["OrderNo"] = toUtf(pRspOrder->OrderNo); + data["OrigOrderNo"] = toUtf(pRspOrder->OrigOrderNo); + data["OrderMethod"] = toUtf(pRspOrder->OrderMethod); + data["AcceptType"] = toUtf(pRspOrder->AcceptType); + data["ExchangeCode"] = toUtf(pRspOrder->ExchangeCode); + data["TreatyCode"] = toUtf(pRspOrder->TreatyCode); + data["BuySale"] = toUtf(pRspOrder->BuySale); + data["OrderNumber"] = toUtf(pRspOrder->OrderNumber); + data["OrderPrice"] = toUtf(pRspOrder->OrderPrice); + data["FilledNumber"] = toUtf(pRspOrder->FilledNumber); + data["FilledPrice"] = toUtf(pRspOrder->FilledPrice); + data["TradeType"] = toUtf(pRspOrder->TradeType); + data["PriceType"] = toUtf(pRspOrder->PriceType); + data["HtsType"] = toUtf(pRspOrder->HtsType); + data["OrderDate"] = toUtf(pRspOrder->OrderDate); + data["OrderTime"] = toUtf(pRspOrder->OrderTime); + data["ErrorCode"] = toUtf(pRspOrder->ErrorCode); + data["OrderState"] = toUtf(pRspOrder->OrderState); + data["IsRiskOrder"] = toUtf(pRspOrder->IsRiskOrder); + data["CancelUserId"] = toUtf(pRspOrder->CancelUserId); + data["TriggerPrice"] = toUtf(pRspOrder->TriggerPrice); + data["ValidDate"] = toUtf(pRspOrder->ValidDate); + data["AddReduce"] = toUtf(pRspOrder->AddReduce); + data["StrategyId"] = toUtf(pRspOrder->StrategyId); + data["MaxShow"] = toUtf(pRspOrder->MaxShow); + data["MinQty"] = toUtf(pRspOrder->MinQty); + data["ExchangeTime"] = toUtf(pRspOrder->ExchangeTime); + data["CancelTime"] = toUtf(pRspOrder->CancelTime); + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspQryOrder(data, data, iRequestID, bIsLast); +}; + +void FutureApi::OnRspQryTrade(CFutureRspTradeField *pRspTrade, CFutureRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspTrade) + { + data["UserId"] = toUtf(pRspTrade->UserId); + data["AccountNo"] = toUtf(pRspTrade->AccountNo); + data["FilledNo"] = toUtf(pRspTrade->FilledNo); + data["OrderNo"] = toUtf(pRspTrade->OrderNo); + data["SystemNo"] = toUtf(pRspTrade->SystemNo); + data["LocalNo"] = toUtf(pRspTrade->LocalNo); + data["ExchangeCode"] = toUtf(pRspTrade->ExchangeCode); + data["TreatyCode"] = toUtf(pRspTrade->TreatyCode); + data["BuySale"] = toUtf(pRspTrade->BuySale); + data["FilledNumber"] = toUtf(pRspTrade->FilledNumber); + data["FilledPrice"] = toUtf(pRspTrade->FilledPrice); + data["FilledDate"] = toUtf(pRspTrade->FilledDate); + data["FilledTime"] = toUtf(pRspTrade->FilledTime); + data["Commsion"] = toUtf(pRspTrade->Commsion); + data["OrderNumber"] = toUtf(pRspTrade->OrderNumber); + data["OrderPrice"] = toUtf(pRspTrade->OrderPrice); + data["DeliveryDate"] = toUtf(pRspTrade->DeliveryDate); + data["FilledType"] = toUtf(pRspTrade->FilledType); + data["OrderType"] = toUtf(pRspTrade->OrderType); + data["ValidDate"] = toUtf(pRspTrade->ValidDate); + data["AddReduce"] = toUtf(pRspTrade->AddReduce); + data["ErrorDescription"] = toUtf(pRspTrade->ErrorDescription); + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspQryTrade(data, data, iRequestID, bIsLast); +}; + +void FutureApi::OnRspQryCapital(CFutureRspCapitalField *pRspCapital, CFutureRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspCapital) + { + data["UserId"] = toUtf(pRspCapital->UserId); + data["InMoney"] = toUtf(pRspCapital->InMoney); + data["OutMoney"] = toUtf(pRspCapital->OutMoney); + data["TodayCanUse"] = toUtf(pRspCapital->TodayCanUse); + data["TodayAmount"] = toUtf(pRspCapital->TodayAmount); + data["TodayBalance"] = toUtf(pRspCapital->TodayBalance); + data["FreezenMoney"] = toUtf(pRspCapital->FreezenMoney); + data["Commission"] = toUtf(pRspCapital->Commission); + data["Margin"] = toUtf(pRspCapital->Margin); + data["OldCanUse"] = toUtf(pRspCapital->OldCanUse); + data["OldAmount"] = toUtf(pRspCapital->OldAmount); + data["OldBalance"] = toUtf(pRspCapital->OldBalance); + data["FloatingProfit"] = toUtf(pRspCapital->FloatingProfit); + data["CurrencyNo"] = toUtf(pRspCapital->CurrencyNo); + data["CurrencyRate"] = pRspCapital->CurrencyRate; + data["UnexpiredProfit"] = pRspCapital->UnexpiredProfit; + data["UnaccountProfit"] = pRspCapital->UnaccountProfit; + data["KeepDeposit"] = pRspCapital->KeepDeposit; + data["Royalty"] = pRspCapital->Royalty; + data["Credit"] = pRspCapital->Credit; + data["AddCapital"] = pRspCapital->AddCapital; + data["IniEquity"] = pRspCapital->IniEquity; + data["AccountNo"] = toUtf(pRspCapital->AccountNo); + data["MortgageMoney"] = pRspCapital->MortgageMoney; + data["MarginLimit"] = pRspCapital->MarginLimit; + data["BorrowValue"] = pRspCapital->BorrowValue; + data["T1"] = pRspCapital->T1; + data["T2"] = pRspCapital->T2; + data["T3"] = pRspCapital->T3; + data["TN"] = pRspCapital->TN; + data["TradeLimit"] = pRspCapital->TradeLimit; + data["CanCashOut"] = pRspCapital->CanCashOut; + data["AccruedCrInt"] = pRspCapital->AccruedCrInt; + data["AccruedDrInt"] = pRspCapital->AccruedDrInt; + data["CrossMax"] = pRspCapital->CrossMax; + data["SellFreezenMoney"] = pRspCapital->SellFreezenMoney; + data["SellInterest"] = pRspCapital->SellInterest; + data["SellNeedAddMargin"] = pRspCapital->SellNeedAddMargin; + data["NetProfit"] = toUtf(pRspCapital->NetProfit); + data["ProfitRate"] = toUtf(pRspCapital->ProfitRate); + data["RiskRate"] = toUtf(pRspCapital->RiskRate); + data["ErrorDescription"] = toUtf(pRspCapital->ErrorDescription); + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspQryCapital(data, data, iRequestID, bIsLast); +}; + +void FutureApi::OnRspQryVersion(CFutureRspVersionField *pRspVersion, CFutureRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspVersion) + { + data["Version"] = toUtf(pRspVersion->Version); + data["MustUpdate"] = toUtf(pRspVersion->MustUpdate); + data["MustVersion"] = toUtf(pRspVersion->MustVersion); + data["VersionContent_CN"] = toUtf(pRspVersion->VersionContent_CN); + data["VersionContent_US"] = toUtf(pRspVersion->VersionContent_US); + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspQryVersion(data, data, iRequestID, bIsLast); +}; + +void FutureApi::OnRspQryPosition(CFutureRspPositionField *pRspPosition, CFutureRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspPosition) + { + data["MatchDate"] = toUtf(pRspPosition->MatchDate); + data["MatchNo"] = toUtf(pRspPosition->MatchNo); + data["ClientNo"] = toUtf(pRspPosition->ClientNo); + data["ExchangeNo"] = toUtf(pRspPosition->ExchangeNo); + data["CommodityNo"] = toUtf(pRspPosition->CommodityNo); + data["ContractNo"] = toUtf(pRspPosition->ContractNo); + data["Direct"] = toUtf(pRspPosition->Direct); + data["HoldVol"] = pRspPosition->HoldVol; + data["HoldPrice"] = pRspPosition->HoldPrice; + data["CurrencyNo"] = toUtf(pRspPosition->CurrencyNo); + data["ForciblyPrice"] = pRspPosition->ForciblyPrice; + data["Account"] = toUtf(pRspPosition->Account); + data["HoldType"] = toUtf(pRspPosition->HoldType); + data["DeliveryDate"] = toUtf(pRspPosition->DeliveryDate); + data["ExchangeName"] = toUtf(pRspPosition->ExchangeName); + data["CurrencyName"] = toUtf(pRspPosition->CurrencyName); + data["ContCode"] = toUtf(pRspPosition->ContCode); + data["HoldMargin"] = pRspPosition->HoldMargin; + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspQryPosition(data, data, iRequestID, bIsLast); +}; + +void FutureApi::OnRspQryCurrency(CFutureRspCurrencyField *pRspCurrency, CFutureRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspCurrency) + { + data["CurrencyNo"] = toUtf(pRspCurrency->CurrencyNo); + data["IsBase"] = pRspCurrency->IsBase; + data["ChangeRate"] = pRspCurrency->ChangeRate; + data["CurrencyName"] = toUtf(pRspCurrency->CurrencyName); + data["CurrencyNameEN"] = toUtf(pRspCurrency->CurrencyNameEN); + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspQryCurrency(data, data, iRequestID, bIsLast); +}; + +void FutureApi::OnRspQryExchange(CFutureRspExchangeField *pRspExchange, CFutureRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspExchange) + { + data["ExchangeNo"] = toUtf(pRspExchange->ExchangeNo); + data["ExchangeName"] = toUtf(pRspExchange->ExchangeName); + data["SettleType"] = toUtf(pRspExchange->SettleType); + data["NameEN"] = toUtf(pRspExchange->NameEN); + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspQryExchange(data, data, iRequestID, bIsLast); +}; + +void FutureApi::OnRspQryStrategy(CFutureRspStrategyField *pRspStrategy, CFutureRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspStrategy) + { + data["UserId"] = toUtf(pRspStrategy->UserId); + data["KeyId"] = toUtf(pRspStrategy->KeyId); + data["Name"] = toUtf(pRspStrategy->Name); + data["Code"] = toUtf(pRspStrategy->Code); + data["PriceType"] = pRspStrategy->PriceType; + data["PriceTypeDetailType"] = pRspStrategy->PriceTypeDetailType; + data["PriceFormula"] = toUtf(pRspStrategy->PriceFormula); + data["TriggerMethod"] = pRspStrategy->TriggerMethod; + data["InnerProtect"] = pRspStrategy->InnerProtect; + data["PassiveFailCloseMainLeg"] = pRspStrategy->PassiveFailCloseMainLeg; + data["SlipPoint"] = pRspStrategy->SlipPoint; + data["RecoverPriceMethod"] = pRspStrategy->RecoverPriceMethod; + data["RecoverPriceSeconds"] = pRspStrategy->RecoverPriceSeconds; + data["SetType"] = toUtf(pRspStrategy->SetType); + data["MinChangePrice"] = pRspStrategy->MinChangePrice; + data["MaxNum"] = pRspStrategy->MaxNum; + data["SuportQuantity"] = pRspStrategy->SuportQuantity; + data["SafeDeep"] = pRspStrategy->SafeDeep; + data["MainRange"] = pRspStrategy->MainRange; + data["ManualZhuiDanBeyondNum"] = toUtf(pRspStrategy->ManualZhuiDanBeyondNum); + data["ManualPingZhuDongBeyondNum"] = toUtf(pRspStrategy->ManualPingZhuDongBeyondNum); + data["AutoGuaDanSeconds"] = pRspStrategy->AutoGuaDanSeconds; + data["AutoZhuiBeiDongDots"] = pRspStrategy->AutoZhuiBeiDongDots; + data["AutoPingZhuDongDots"] = pRspStrategy->AutoPingZhuDongDots; + data["AutoZhiSunDot"] = pRspStrategy->AutoZhiSunDot; + data["AutoZhiSunZhuiBeiDongDots"] = pRspStrategy->AutoZhiSunZhuiBeiDongDots; + data["AutoZhiSunPingZhuDongDots"] = pRspStrategy->AutoZhiSunPingZhuDongDots; + data["DotLen"] = pRspStrategy->DotLen; + data["TradeTime"] = toUtf(pRspStrategy->TradeTime); + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspQryStrategy(data, data, iRequestID, bIsLast); +}; + +void FutureApi::OnRspQryCommodity(CFutureRspCommodityField *pRspCommodity, CFutureRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspCommodity) + { + data["CommodityNo"] = toUtf(pRspCommodity->CommodityNo); + data["ExchangeNo"] = toUtf(pRspCommodity->ExchangeNo); + data["CommodityType"] = toUtf(pRspCommodity->CommodityType); + data["Name"] = toUtf(pRspCommodity->Name); + data["Enabled"] = toUtf(pRspCommodity->Enabled); + data["RegDate"] = toUtf(pRspCommodity->RegDate); + data["CurrencyNo"] = toUtf(pRspCommodity->CurrencyNo); + data["ProductDot"] = pRspCommodity->ProductDot; + data["LowerTick"] = pRspCommodity->LowerTick; + data["UpperTick"] = pRspCommodity->UpperTick; + data["DotNum"] = pRspCommodity->DotNum; + data["StrikeCommodityId"] = pRspCommodity->StrikeCommodityId; + data["OptionStyle"] = toUtf(pRspCommodity->OptionStyle); + data["ExchangeNo2"] = toUtf(pRspCommodity->ExchangeNo2); + data["IsSFuture"] = toUtf(pRspCommodity->IsSFuture); + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspQryCommodity(data, data, iRequestID, bIsLast); +}; + +void FutureApi::OnRspQryInstrument(CFutureRspInstrumentField *pRspInstrument, CFutureRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspInstrument) + { + data["CommodityCode"] = toUtf(pRspInstrument->CommodityCode); + data["ExchangeNo"] = toUtf(pRspInstrument->ExchangeNo); + data["ContractNo"] = toUtf(pRspInstrument->ContractNo); + data["ContractFName"] = toUtf(pRspInstrument->ContractFName); + data["CommodityNo"] = toUtf(pRspInstrument->CommodityNo); + data["CommodityFName"] = toUtf(pRspInstrument->CommodityFName); + data["CommodityType"] = toUtf(pRspInstrument->CommodityType); + data["CommodityFCurrencyNo"] = toUtf(pRspInstrument->CommodityFCurrencyNo); + data["CurrencyFName"] = toUtf(pRspInstrument->CurrencyFName); + data["ProductDot"] = pRspInstrument->ProductDot; + data["UpperTick"] = pRspInstrument->UpperTick; + data["ExchangeName"] = toUtf(pRspInstrument->ExchangeName); + data["LastSettlePrice"] = pRspInstrument->LastSettlePrice; + data["TradeMonth"] = toUtf(pRspInstrument->TradeMonth); + data["DotNum"] = pRspInstrument->DotNum; + data["LowerTick"] = pRspInstrument->LowerTick; + data["DotNumCarry"] = pRspInstrument->DotNumCarry; + data["UpperTickCarry"] = pRspInstrument->UpperTickCarry; + data["FirstNoticeDay"] = toUtf(pRspInstrument->FirstNoticeDay); + data["FreezenPercent"] = pRspInstrument->FreezenPercent; + data["FreezenMoney"] = pRspInstrument->FreezenMoney; + data["FeeMoney"] = pRspInstrument->FeeMoney; + data["FeePercent"] = pRspInstrument->FeePercent; + data["PriceStrike"] = pRspInstrument->PriceStrike; + data["ProductDotStrike"] = pRspInstrument->ProductDotStrike; + data["UpperTickStrike"] = pRspInstrument->UpperTickStrike; + data["LastTradeDay"] = toUtf(pRspInstrument->LastTradeDay); + data["LastUpdateDay"] = toUtf(pRspInstrument->LastUpdateDay); + data["CriticalPrice"] = pRspInstrument->CriticalPrice; + data["CriticalMinChangedPrice"] = pRspInstrument->CriticalMinChangedPrice; + data["ExchangeSub"] = toUtf(pRspInstrument->ExchangeSub); + data["OptionType"] = toUtf(pRspInstrument->OptionType); + data["OptionMonth"] = toUtf(pRspInstrument->OptionMonth); + data["OptionStrikePrice"] = toUtf(pRspInstrument->OptionStrikePrice); + data["OptionCommodityNo"] = toUtf(pRspInstrument->OptionCommodityNo); + data["OptionContractNo"] = toUtf(pRspInstrument->OptionContractNo); + data["ContractFNameEN"] = toUtf(pRspInstrument->ContractFNameEN); + data["CommodityFNameEN"] = toUtf(pRspInstrument->CommodityFNameEN); + data["OptionStyle"] = toUtf(pRspInstrument->OptionStyle); + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspQryInstrument(data, data, iRequestID, bIsLast); +}; + +void FutureApi::OnRspQryExchangeTime(CFutureRspExchangeTimeField *pRspExchangeTime, CFutureRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspExchangeTime) + { + data["Year"] = toUtf(pRspExchangeTime->Year); + data["SummerBegin"] = toUtf(pRspExchangeTime->SummerBegin); + data["WinterBegin"] = toUtf(pRspExchangeTime->WinterBegin); + data["ExchangeNo"] = toUtf(pRspExchangeTime->ExchangeNo); + data["Name"] = toUtf(pRspExchangeTime->Name); + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspQryExchangeTime(data, data, iRequestID, bIsLast); +}; + +void FutureApi::OnRspQryCommodityTime(CFutureRspCommodityTimeField *pRspCommodityTime, CFutureRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspCommodityTime) + { + data["CrossTrade"] = toUtf(pRspCommodityTime->CrossTrade); + data["Stage"] = toUtf(pRspCommodityTime->Stage); + data["Summer"] = toUtf(pRspCommodityTime->Summer); + data["Opendate"] = toUtf(pRspCommodityTime->Opendate); + data["Closingdate"] = toUtf(pRspCommodityTime->Closingdate); + data["CommodityNo"] = toUtf(pRspCommodityTime->CommodityNo); + data["ComName"] = toUtf(pRspCommodityTime->ComName); + data["ExchangeNo"] = toUtf(pRspCommodityTime->ExchangeNo); + data["ExName"] = toUtf(pRspCommodityTime->ExName); + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspQryCommodityTime(data, data, iRequestID, bIsLast); +}; + +void FutureApi::OnRspQryTotalPosition(CFutureRspTotalPositionField *pRspTotalPosition, CFutureRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspTotalPosition) + { + data["LocalOrderNo"] = toUtf(pRspTotalPosition->LocalOrderNo); + data["ExchangeNo"] = toUtf(pRspTotalPosition->ExchangeNo); + data["TreatyCode"] = toUtf(pRspTotalPosition->TreatyCode); + data["OrderNo"] = toUtf(pRspTotalPosition->OrderNo); + data["OrderNumber"] = pRspTotalPosition->OrderNumber; + data["FilledNumber"] = pRspTotalPosition->FilledNumber; + data["FilledAdvPrice"] = pRspTotalPosition->FilledAdvPrice; + data["BuyHoldNumber"] = pRspTotalPosition->BuyHoldNumber; + data["BuyHoldOpenPrice"] = pRspTotalPosition->BuyHoldOpenPrice; + data["BuyHoldPrice"] = pRspTotalPosition->BuyHoldPrice; + data["SaleHoldNumber"] = pRspTotalPosition->SaleHoldNumber; + data["SaleHoldOpenPrice"] = pRspTotalPosition->SaleHoldOpenPrice; + data["SaleHoldPrice"] = pRspTotalPosition->SaleHoldPrice; + data["IsCanceled"] = toUtf(pRspTotalPosition->IsCanceled); + data["FilledTotalFee"] = pRspTotalPosition->FilledTotalFee; + data["Status"] = pRspTotalPosition->Status; + data["AccountNo"] = toUtf(pRspTotalPosition->AccountNo); + data["HoldType"] = toUtf(pRspTotalPosition->HoldType); + data["HoldMarginBuy"] = pRspTotalPosition->HoldMarginBuy; + data["HoldMarginSale"] = pRspTotalPosition->HoldMarginSale; + data["CurrPrice"] = pRspTotalPosition->CurrPrice; + data["FloatProfit"] = pRspTotalPosition->FloatProfit; + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspQryTotalPosition(data, data, iRequestID, bIsLast); +}; + +void FutureApi::OnRspQryStrategyDetail(CFutureRspStrategyDetailField *pRspStrategyDetail, CFutureRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspStrategyDetail) + { + data["StartegyCommodityNo"] = toUtf(pRspStrategyDetail->StartegyCommodityNo); + data["StartegyContractNo"] = toUtf(pRspStrategyDetail->StartegyContractNo); + data["Price"] = toUtf(pRspStrategyDetail->Price); + data["LegNum"] = pRspStrategyDetail->LegNum; + data["LastTradeDate"] = toUtf(pRspStrategyDetail->LastTradeDate); + data["SeqId"] = pRspStrategyDetail->SeqId; + data["CommodityNo"] = toUtf(pRspStrategyDetail->CommodityNo); + data["ContractNo"] = toUtf(pRspStrategyDetail->ContractNo); + data["Direct"] = toUtf(pRspStrategyDetail->Direct); + data["Quantity"] = pRspStrategyDetail->Quantity; + data["Model"] = toUtf(pRspStrategyDetail->Model); + data["ModifyDate"] = toUtf(pRspStrategyDetail->ModifyDate); + data["OrderMethod"] = toUtf(pRspStrategyDetail->OrderMethod); + data["PriceTolerance"] = pRspStrategyDetail->PriceTolerance; + data["PriceParam"] = pRspStrategyDetail->PriceParam; + data["SuportQuantity"] = pRspStrategyDetail->SuportQuantity; + data["MinMove"] = pRspStrategyDetail->MinMove; + data["TimerOrder"] = pRspStrategyDetail->TimerOrder; + data["TimerOrderBeyondNum"] = toUtf(pRspStrategyDetail->TimerOrderBeyondNum); + data["TimerOrderPrice"] = pRspStrategyDetail->TimerOrderPrice; + data["TimerOrderPriceBeyondNum"] = toUtf(pRspStrategyDetail->TimerOrderPriceBeyondNum); + data["TimerOrderPriceTriggerNum"] = toUtf(pRspStrategyDetail->TimerOrderPriceTriggerNum); + data["ZhiSunOrder"] = pRspStrategyDetail->ZhiSunOrder; + data["ZhiSunOrderBeyondNum"] = toUtf(pRspStrategyDetail->ZhiSunOrderBeyondNum); + data["TimerPingCang"] = pRspStrategyDetail->TimerPingCang; + data["TimerPingCangBeyondNum"] = toUtf(pRspStrategyDetail->TimerPingCangBeyondNum); + data["SafeDeep"] = pRspStrategyDetail->SafeDeep; + data["MainRange"] = pRspStrategyDetail->MainRange; + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspQryStrategyDetail(data, data, iRequestID, bIsLast); +}; + diff --git a/vnpy/api/da/generator/da_future_struct.py b/vnpy/api/da/generator/da_future_struct.py index 67c95f21..5095bf52 100644 --- a/vnpy/api/da/generator/da_future_struct.py +++ b/vnpy/api/da/generator/da_future_struct.py @@ -155,7 +155,7 @@ CFutureReqOrderModifyField = { "ErrorDescription": "string", } -CFutureRspOrderInsertField = CFutureRspOrderModifyField +CFutureRspOrderModifyField = CFutureRspOrderInsertField CFutureReqOrderCancelField = { "UserId": "string", @@ -599,9 +599,9 @@ CFutureRtnCapitalField = { "SellNeedAddMargin": "double", } -CFutureRtnOrderField = CFutureRtnPositionField +CFutureRtnPositionField = CFutureRtnOrderField -CFutureRspTradeField = CFutureRtnTradeField +CFutureRtnTradeField = CFutureRspTradeField CFutureReqGetQuestionField = { "Unused": "int", @@ -656,7 +656,7 @@ CFutureQryTotalPositionField = { "ErrorDescription": "string", } -CFutureRtnOrderField = CFutureRspTotalPositionField +CFutureRspTotalPositionField = CFutureRtnOrderField CFutureQryStrategyField = { "ExchangeNo": "string", diff --git a/vnpy/api/da/generator/da_market_header_function.h b/vnpy/api/da/generator/da_market_header_function.h new file mode 100644 index 00000000..d81b3dca --- /dev/null +++ b/vnpy/api/da/generator/da_market_header_function.h @@ -0,0 +1,6 @@ +int reqUserLogin(const dict &req, int reqid); + +int reqBrokerData(const dict &req, int reqid); + +int reqMarketData(const dict &req, int reqid); + diff --git a/vnpy/api/da/generator/da_market_header_on.h b/vnpy/api/da/generator/da_market_header_on.h new file mode 100644 index 00000000..199960bd --- /dev/null +++ b/vnpy/api/da/generator/da_market_header_on.h @@ -0,0 +1,16 @@ +virtual void onFrontConnected() {}; + +virtual void onFrontDisconnected(int reqid) {}; + +virtual void onHeartBeatWarning(int reqid) {}; + +virtual void onRspRawData(const dict &data) {}; + +virtual void onRspUserLogin(const dict &error, int reqid, bool last) {}; + +virtual void onRspTradeDate(const dict &data, const dict &error, int reqid, bool last) {}; + +virtual void onRspBrokerData(const dict &data, const dict &error, int reqid, bool last) {}; + +virtual void onRspMarketData(const dict &data, const dict &error, int reqid, bool last) {}; + diff --git a/vnpy/api/da/generator/da_market_source_function.cpp b/vnpy/api/da/generator/da_market_source_function.cpp new file mode 100644 index 00000000..f9276fdb --- /dev/null +++ b/vnpy/api/da/generator/da_market_source_function.cpp @@ -0,0 +1,40 @@ +int MarketApi::reqUserLogin(const dict &req, int reqid) +{ + CMarketReqUserLoginField myreq = CMarketReqUserLoginField(); + memset(&myreq, 0, sizeof(myreq)); + getString(req, "UserId", myreq.UserId); + getString(req, "UserPwd", myreq.UserPwd); + getString(req, "UserType", myreq.UserType); + getString(req, "MacAddress", myreq.MacAddress); + getString(req, "ComputerName", myreq.ComputerName); + getString(req, "SoftwareName", myreq.SoftwareName); + getString(req, "SoftwareVersion", myreq.SoftwareVersion); + getString(req, "AuthorCode", myreq.AuthorCode); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqUserLogin(&myreq, reqid); + return i; +}; + +int MarketApi::reqBrokerData(const dict &req, int reqid) +{ + CMarketReqBrokerDataField myreq = CMarketReqBrokerDataField(); + memset(&myreq, 0, sizeof(myreq)); + getString(req, "ContCode", myreq.ContCode); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqBrokerData(&myreq, reqid); + return i; +}; + +int MarketApi::reqMarketData(const dict &req, int reqid) +{ + CMarketReqMarketDataField myreq = CMarketReqMarketDataField(); + memset(&myreq, 0, sizeof(myreq)); + getChar(req, "MarketType", &myreq.MarketType); + getChar(req, "SubscMode", &myreq.SubscMode); + getInt(req, "MarketCount", &myreq.MarketCount); + getString(req, "MarketTrcode[MAX_SUB_COUNT]", myreq.MarketTrcode[MAX_SUB_COUNT]); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqMarketData(&myreq, reqid); + return i; +}; + diff --git a/vnpy/api/da/generator/da_market_source_module.cpp b/vnpy/api/da/generator/da_market_source_module.cpp new file mode 100644 index 00000000..078cd2ad --- /dev/null +++ b/vnpy/api/da/generator/da_market_source_module.cpp @@ -0,0 +1,13 @@ +.def("reqUserLogin", &MarketApi::reqUserLogin) +.def("reqBrokerData", &MarketApi::reqBrokerData) +.def("reqMarketData", &MarketApi::reqMarketData) + +.def("onFrontConnected", &MarketApi::onFrontConnected) +.def("onFrontDisconnected", &MarketApi::onFrontDisconnected) +.def("onHeartBeatWarning", &MarketApi::onHeartBeatWarning) +.def("onRspRawData", &MarketApi::onRspRawData) +.def("onRspUserLogin", &MarketApi::onRspUserLogin) +.def("onRspTradeDate", &MarketApi::onRspTradeDate) +.def("onRspBrokerData", &MarketApi::onRspBrokerData) +.def("onRspMarketData", &MarketApi::onRspMarketData) +; diff --git a/vnpy/api/da/generator/da_market_source_on.cpp b/vnpy/api/da/generator/da_market_source_on.cpp new file mode 100644 index 00000000..e21c0ada --- /dev/null +++ b/vnpy/api/da/generator/da_market_source_on.cpp @@ -0,0 +1,96 @@ +void onFrontConnected() override +{ + try + { + PYBIND11_OVERLOAD(void, MarketApi, onFrontConnected); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onFrontDisconnected(int reqid) override +{ + try + { + PYBIND11_OVERLOAD(void, MarketApi, onFrontDisconnected, reqid); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onHeartBeatWarning(int reqid) override +{ + try + { + PYBIND11_OVERLOAD(void, MarketApi, onHeartBeatWarning, reqid); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspRawData(const dict &data) override +{ + try + { + PYBIND11_OVERLOAD(void, MarketApi, onRspRawData, data); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspUserLogin(const dict &error, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, MarketApi, onRspUserLogin, error, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspTradeDate(const dict &data, const dict &error, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, MarketApi, onRspTradeDate, data, error, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspBrokerData(const dict &data, const dict &error, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, MarketApi, onRspBrokerData, data, error, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspMarketData(const dict &data, const dict &error, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, MarketApi, onRspMarketData, data, error, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + diff --git a/vnpy/api/da/generator/da_market_source_task.cpp b/vnpy/api/da/generator/da_market_source_task.cpp new file mode 100644 index 00000000..6a8b8e1a --- /dev/null +++ b/vnpy/api/da/generator/da_market_source_task.cpp @@ -0,0 +1,153 @@ +void MarketApi::OnFrontConnected() +{ + gil_scoped_acquire acquire; + this->onFrontConnected(); +}; + +void MarketApi::OnFrontDisconnected(int iReason) +{ + gil_scoped_acquire acquire; + this->onFrontDisconnected(iReason); +}; + +void MarketApi::OnHeartBeatWarning(int iTimeLapse) +{ + gil_scoped_acquire acquire; + this->onHeartBeatWarning(iTimeLapse); +}; + +void MarketApi::OnRspRawData(const char* rawData) +{ + gil_scoped_acquire acquire; + this->onRspRawData(string(rawData)); +}; + +void MarketApi::OnRspUserLogin(CMarketRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict error; + if (pRspInfo) + { + error["ErrorID"] = pRspInfo->ErrorID; + error["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspUserLogin(error, iRequestID, bIsLast); +}; + +void MarketApi::OnRspTradeDate(CMarketRspTradeDateField *pRspTradeDate, CMarketRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspTradeDate) + { + data["TradeDate"] = toUtf(pRspTradeDate->TradeDate); + data["TradeProduct"] = toUtf(pRspTradeDate->TradeProduct); + } + dict error; + if (pRspInfo) + { + error["ErrorID"] = pRspInfo->ErrorID; + error["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspTradeDate(data, error, iRequestID, bIsLast); +}; + +void MarketApi::OnRspBrokerData(CMarketRspBrokerDataField *pRspBrokerData, CMarketRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspBrokerData) + { + data["BrokerData"] = toUtf(pRspBrokerData->BrokerData); + } + dict error; + if (pRspInfo) + { + error["ErrorID"] = pRspInfo->ErrorID; + error["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspBrokerData(data, error, iRequestID, bIsLast); +}; + +void MarketApi::OnRspMarketData(CMarketRspMarketDataField *pRspMarketData, CMarketRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspMarketData) + { + data["ExchangeCode"] = toUtf(pRspMarketData->ExchangeCode); + data["TreatyCode"] = toUtf(pRspMarketData->TreatyCode); + data["BuyPrice"] = toUtf(pRspMarketData->BuyPrice); + data["BuyNumber"] = toUtf(pRspMarketData->BuyNumber); + data["SalePrice"] = toUtf(pRspMarketData->SalePrice); + data["SaleNumber"] = toUtf(pRspMarketData->SaleNumber); + data["CurrPrice"] = toUtf(pRspMarketData->CurrPrice); + data["CurrNumber"] = toUtf(pRspMarketData->CurrNumber); + data["High"] = toUtf(pRspMarketData->High); + data["Low"] = toUtf(pRspMarketData->Low); + data["Open"] = toUtf(pRspMarketData->Open); + data["IntradaySettlePrice"] = toUtf(pRspMarketData->IntradaySettlePrice); + data["Close"] = toUtf(pRspMarketData->Close); + data["Time"] = toUtf(pRspMarketData->Time); + data["FilledNum"] = toUtf(pRspMarketData->FilledNum); + data["HoldNum"] = toUtf(pRspMarketData->HoldNum); + data["BuyPrice2"] = toUtf(pRspMarketData->BuyPrice2); + data["BuyPrice3"] = toUtf(pRspMarketData->BuyPrice3); + data["BuyPrice4"] = toUtf(pRspMarketData->BuyPrice4); + data["BuyPrice5"] = toUtf(pRspMarketData->BuyPrice5); + data["BuyNumber2"] = toUtf(pRspMarketData->BuyNumber2); + data["BuyNumber3"] = toUtf(pRspMarketData->BuyNumber3); + data["BuyNumber4"] = toUtf(pRspMarketData->BuyNumber4); + data["BuyNumber5"] = toUtf(pRspMarketData->BuyNumber5); + data["SalePrice2"] = toUtf(pRspMarketData->SalePrice2); + data["SalePrice3"] = toUtf(pRspMarketData->SalePrice3); + data["SalePrice4"] = toUtf(pRspMarketData->SalePrice4); + data["SalePrice5"] = toUtf(pRspMarketData->SalePrice5); + data["SaleNumber2"] = toUtf(pRspMarketData->SaleNumber2); + data["SaleNumber3"] = toUtf(pRspMarketData->SaleNumber3); + data["SaleNumber4"] = toUtf(pRspMarketData->SaleNumber4); + data["SaleNumber5"] = toUtf(pRspMarketData->SaleNumber5); + data["HideBuyPrice"] = toUtf(pRspMarketData->HideBuyPrice); + data["HideBuyNumber"] = toUtf(pRspMarketData->HideBuyNumber); + data["HideSalePrice"] = toUtf(pRspMarketData->HideSalePrice); + data["HideSaleNumber"] = toUtf(pRspMarketData->HideSaleNumber); + data["LimitDownPrice"] = toUtf(pRspMarketData->LimitDownPrice); + data["LimitUpPrice"] = toUtf(pRspMarketData->LimitUpPrice); + data["TradeDay"] = toUtf(pRspMarketData->TradeDay); + data["BuyPrice6"] = toUtf(pRspMarketData->BuyPrice6); + data["BuyPrice7"] = toUtf(pRspMarketData->BuyPrice7); + data["BuyPrice8"] = toUtf(pRspMarketData->BuyPrice8); + data["BuyPrice9"] = toUtf(pRspMarketData->BuyPrice9); + data["BuyPrice10"] = toUtf(pRspMarketData->BuyPrice10); + data["BuyNumber6"] = toUtf(pRspMarketData->BuyNumber6); + data["BuyNumber7"] = toUtf(pRspMarketData->BuyNumber7); + data["BuyNumber8"] = toUtf(pRspMarketData->BuyNumber8); + data["BuyNumber9"] = toUtf(pRspMarketData->BuyNumber9); + data["BuyNumber10"] = toUtf(pRspMarketData->BuyNumber10); + data["SalePrice6"] = toUtf(pRspMarketData->SalePrice6); + data["SalePrice7"] = toUtf(pRspMarketData->SalePrice7); + data["SalePrice8"] = toUtf(pRspMarketData->SalePrice8); + data["SalePrice9"] = toUtf(pRspMarketData->SalePrice9); + data["SalePrice10"] = toUtf(pRspMarketData->SalePrice10); + data["SaleNumber6"] = toUtf(pRspMarketData->SaleNumber6); + data["SaleNumber7"] = toUtf(pRspMarketData->SaleNumber7); + data["SaleNumber8"] = toUtf(pRspMarketData->SaleNumber8); + data["SaleNumber9"] = toUtf(pRspMarketData->SaleNumber9); + data["SaleNumber10"] = toUtf(pRspMarketData->SaleNumber10); + data["TradeFlag"] = toUtf(pRspMarketData->TradeFlag); + data["DataTimestamp"] = toUtf(pRspMarketData->DataTimestamp); + data["DataSourceId"] = toUtf(pRspMarketData->DataSourceId); + data["CanSellVol"] = toUtf(pRspMarketData->CanSellVol); + data["QuoteType"] = toUtf(pRspMarketData->QuoteType); + data["AggressorSide"] = toUtf(pRspMarketData->AggressorSide); + data["PreSettlementPrice"] = toUtf(pRspMarketData->PreSettlementPrice); + } + dict error; + if (pRspInfo) + { + error["ErrorID"] = pRspInfo->ErrorID; + error["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspMarketData(data, error, iRequestID, bIsLast); +}; + diff --git a/vnpy/api/da/generator/da_stock_header_function.h b/vnpy/api/da/generator/da_stock_header_function.h new file mode 100644 index 00000000..45024941 --- /dev/null +++ b/vnpy/api/da/generator/da_stock_header_function.h @@ -0,0 +1,38 @@ +int reqUserLogin(const dict &req, int reqid); + +int reqUserLogout(const dict &req, int reqid); + +int reqSafeVerify(const dict &req, int reqid); + +int reqVerifyCode(const dict &req, int reqid); + +int reqSetVerifyQA(const dict &req, int reqid); + +int reqGetQuestion(const dict &req, int reqid); + +int reqOrderInsert(const dict &req, int reqid); + +int reqOrderModify(const dict &req, int reqid); + +int reqOrderCancel(const dict &req, int reqid); + +int reqPasswordUpdate(const dict &req, int reqid); + +int reqQryTick(const dict &req, int reqid); + +int reqQryOrder(const dict &req, int reqid); + +int reqQryTrade(const dict &req, int reqid); + +int reqQryCapital(const dict &req, int reqid); + +int reqQryVersion(const dict &req, int reqid); + +int reqQryPosition(const dict &req, int reqid); + +int reqQryCurrency(const dict &req, int reqid); + +int reqQryExchange(const dict &req, int reqid); + +int reqQryInstrument(const dict &req, int reqid); + diff --git a/vnpy/api/da/generator/da_stock_header_on.h b/vnpy/api/da/generator/da_stock_header_on.h new file mode 100644 index 00000000..15046b34 --- /dev/null +++ b/vnpy/api/da/generator/da_stock_header_on.h @@ -0,0 +1,56 @@ +virtual void onFrontConnected() {}; + +virtual void onFrontDisconnected(int reqid) {}; + +virtual void onHeartBeatWarning(int reqid) {}; + +virtual void onRspNeedVerify(bool last, bool last) {}; + +virtual void onRspUserLogin(const dict &data, int reqid, bool last) {}; + +virtual void onRspUserLogout(const dict &data, int reqid, bool last) {}; + +virtual void onRspVerifyCode(const dict &data, int reqid, bool last) {}; + +virtual void onRspSafeVerify(const dict &data, int reqid, bool last) {}; + +virtual void onRspSetVerifyQA(const dict &data, int reqid, bool last) {}; + +virtual void onRspAccount(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRspQuestion(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRspOrderInsert(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRspOrderModify(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRspOrderCancel(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRspPasswordUpdate(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRtnTrade(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRtnOrder(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRtnCapital(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRtnPosition(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRspQryTick(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRspQryOrder(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRspQryTrade(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRspQryCapital(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRspQryVersion(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRspQryPosition(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRspQryCurrency(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRspQryExchange(const dict &data, const dict &data, int reqid, bool last) {}; + +virtual void onRspQryInstrument(const dict &data, const dict &data, int reqid, bool last) {}; + diff --git a/vnpy/api/da/generator/da_stock_source_function.cpp b/vnpy/api/da/generator/da_stock_source_function.cpp new file mode 100644 index 00000000..2827b88d --- /dev/null +++ b/vnpy/api/da/generator/da_stock_source_function.cpp @@ -0,0 +1,285 @@ +int StockApi::reqUserLogin(const dict &req, int reqid) +{ + CStockReqUserLoginField myreq = CStockReqUserLoginField(); + memset(&myreq, 0, sizeof(myreq)); + getString(req, "UserId", myreq.UserId); + getString(req, "UserPwd", myreq.UserPwd); + getString(req, "UserType", myreq.UserType); + getString(req, "MacAddress", myreq.MacAddress); + getString(req, "ComputerName", myreq.ComputerName); + getString(req, "SoftwareName", myreq.SoftwareName); + getString(req, "SoftwareVersion", myreq.SoftwareVersion); + getString(req, "AuthorCode", myreq.AuthorCode); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqUserLogin(&myreq, reqid); + return i; +}; + +int StockApi::reqUserLogout(const dict &req, int reqid) +{ + CStockReqUserLogoutField myreq = CStockReqUserLogoutField(); + memset(&myreq, 0, sizeof(myreq)); + getString(req, "UserId", myreq.UserId); + getString(req, "AccountNo", myreq.AccountNo); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqUserLogout(&myreq, reqid); + return i; +}; + +int StockApi::reqSafeVerify(const dict &req, int reqid) +{ + CStockReqSafeVerifyField myreq = CStockReqSafeVerifyField(); + memset(&myreq, 0, sizeof(myreq)); + getString(req, "UserId", myreq.UserId); + getString(req, "UserPwd", myreq.UserPwd); + getString(req, "Type", myreq.Type); + getString(req, "Question", myreq.Question); + getString(req, "Answer", myreq.Answer); + getString(req, "MobileNumber", myreq.MobileNumber); + getString(req, "VerifyCode", myreq.VerifyCode); + getString(req, "SaveMac", myreq.SaveMac); + getString(req, "MacAddress", myreq.MacAddress); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqSafeVerify(&myreq, reqid); + return i; +}; + +int StockApi::reqVerifyCode(const dict &req, int reqid) +{ + CStockReqVerifyCodeField myreq = CStockReqVerifyCodeField(); + memset(&myreq, 0, sizeof(myreq)); + getString(req, "UserId", myreq.UserId); + getString(req, "UserPwd", myreq.UserPwd); + getString(req, "Type", myreq.Type); + getString(req, "Question", myreq.Question); + getString(req, "Answer", myreq.Answer); + getString(req, "MobileNumber", myreq.MobileNumber); + getString(req, "VerifyCode", myreq.VerifyCode); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqVerifyCode(&myreq, reqid); + return i; +}; + +int StockApi::reqSetVerifyQA(const dict &req, int reqid) +{ + CStockReqSetVerifyQAField myreq = CStockReqSetVerifyQAField(); + memset(&myreq, 0, sizeof(myreq)); + getString(req, "UserId", myreq.UserId); + getString(req, "UserPwd", myreq.UserPwd); + getString(req, "Type", myreq.Type); + getString(req, "Question", myreq.Question); + getString(req, "Answer", myreq.Answer); + getString(req, "MobileNumber", myreq.MobileNumber); + getString(req, "VerifyCode", myreq.VerifyCode); + getString(req, "SaveMac", myreq.SaveMac); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqSetVerifyQA(&myreq, reqid); + return i; +}; + +int StockApi::reqGetQuestion(const dict &req, int reqid) +{ + CStockReqGetQuestionField myreq = CStockReqGetQuestionField(); + memset(&myreq, 0, sizeof(myreq)); + getInt(req, "Unused", &myreq.Unused); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqGetQuestion(&myreq, reqid); + return i; +}; + +int StockApi::reqOrderInsert(const dict &req, int reqid) +{ + CStockReqOrderInsertField myreq = CStockReqOrderInsertField(); + memset(&myreq, 0, sizeof(myreq)); + getString(req, "UserId", myreq.UserId); + getString(req, "UserType", myreq.UserType); + getString(req, "AccountNo", myreq.AccountNo); + getString(req, "LocalNo", myreq.LocalNo); + getString(req, "TradePwd", myreq.TradePwd); + getString(req, "IsRiskOrder", myreq.IsRiskOrder); + getString(req, "ExchangeCode", myreq.ExchangeCode); + getString(req, "TreatyCode", myreq.TreatyCode); + getString(req, "BuySale", myreq.BuySale); + getString(req, "AddReduce", myreq.AddReduce); + getString(req, "OrderNumber", myreq.OrderNumber); + getString(req, "OrderPrice", myreq.OrderPrice); + getString(req, "TradeType", myreq.TradeType); + getString(req, "PriceType", myreq.PriceType); + getString(req, "HtsType", myreq.HtsType); + getString(req, "ForceID", myreq.ForceID); + getString(req, "TriggerPrice", myreq.TriggerPrice); + getString(req, "ValidDate", myreq.ValidDate); + getString(req, "StrategyId", myreq.StrategyId); + getString(req, "MaxShow", myreq.MaxShow); + getString(req, "MinQty", myreq.MinQty); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqOrderInsert(&myreq, reqid); + return i; +}; + +int StockApi::reqOrderModify(const dict &req, int reqid) +{ + CStockReqOrderModifyField myreq = CStockReqOrderModifyField(); + memset(&myreq, 0, sizeof(myreq)); + getString(req, "SystemNo", myreq.SystemNo); + getString(req, "UserId", myreq.UserId); + getString(req, "UserType", myreq.UserType); + getString(req, "LocalNo", myreq.LocalNo); + getString(req, "AccountNo", myreq.AccountNo); + getString(req, "TradePwd", myreq.TradePwd); + getString(req, "OrderNo", myreq.OrderNo); + getString(req, "ExchangeCode", myreq.ExchangeCode); + getString(req, "TreatyCode", myreq.TreatyCode); + getString(req, "BuySale", myreq.BuySale); + getString(req, "OrderNumber", myreq.OrderNumber); + getString(req, "OrderPrice", myreq.OrderPrice); + getString(req, "FilledNumber", myreq.FilledNumber); + getString(req, "ModifyNumber", myreq.ModifyNumber); + getString(req, "ModifyPrice", myreq.ModifyPrice); + getString(req, "TradeType", myreq.TradeType); + getString(req, "PriceType", myreq.PriceType); + getString(req, "IsRiskOrder", myreq.IsRiskOrder); + getString(req, "TriggerPrice", myreq.TriggerPrice); + getString(req, "ModifyTriggerPrice", myreq.ModifyTriggerPrice); + getString(req, "ValidDate", myreq.ValidDate); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqOrderModify(&myreq, reqid); + return i; +}; + +int StockApi::reqOrderCancel(const dict &req, int reqid) +{ + CStockReqOrderCancelField myreq = CStockReqOrderCancelField(); + memset(&myreq, 0, sizeof(myreq)); + getString(req, "UserId", myreq.UserId); + getString(req, "UserType", myreq.UserType); + getString(req, "LocalNo", myreq.LocalNo); + getString(req, "AccountNo", myreq.AccountNo); + getString(req, "TradePwd", myreq.TradePwd); + getString(req, "IsSimulation", myreq.IsSimulation); + getString(req, "SystemNo", myreq.SystemNo); + getString(req, "OrderNo", myreq.OrderNo); + getString(req, "ExchangeCode", myreq.ExchangeCode); + getString(req, "TreatyCode", myreq.TreatyCode); + getString(req, "BuySale", myreq.BuySale); + getString(req, "OrderNumber", myreq.OrderNumber); + getString(req, "OrderPrice", myreq.OrderPrice); + getString(req, "FilledNumber", myreq.FilledNumber); + getString(req, "TradeType", myreq.TradeType); + getString(req, "PriceType", myreq.PriceType); + getString(req, "HtsType", myreq.HtsType); + getString(req, "IsRiskOrder", myreq.IsRiskOrder); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqOrderCancel(&myreq, reqid); + return i; +}; + +int StockApi::reqPasswordUpdate(const dict &req, int reqid) +{ + CStockReqPasswordUpdateField myreq = CStockReqPasswordUpdateField(); + memset(&myreq, 0, sizeof(myreq)); + getString(req, "UserId", myreq.UserId); + getString(req, "OldPassword", myreq.OldPassword); + getString(req, "NewPassword", myreq.NewPassword); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqPasswordUpdate(&myreq, reqid); + return i; +}; + +int StockApi::reqQryTick(const dict &req, int reqid) +{ + CStockQryTickField myreq = CStockQryTickField(); + memset(&myreq, 0, sizeof(myreq)); + getChar(req, "Unused", &myreq.Unused); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqQryTick(&myreq, reqid); + return i; +}; + +int StockApi::reqQryOrder(const dict &req, int reqid) +{ + CStockQryOrderField myreq = CStockQryOrderField(); + memset(&myreq, 0, sizeof(myreq)); + getString(req, "UserId", myreq.UserId); + getString(req, "UserType", myreq.UserType); + getString(req, "AccountNo", myreq.AccountNo); + getString(req, "TradePwd", myreq.TradePwd); + getString(req, "IsSimulation", myreq.IsSimulation); + getString(req, "OrderNo", myreq.OrderNo); + getString(req, "OrderDateTime", myreq.OrderDateTime); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqQryOrder(&myreq, reqid); + return i; +}; + +int StockApi::reqQryTrade(const dict &req, int reqid) +{ + CStockQryTradeField myreq = CStockQryTradeField(); + memset(&myreq, 0, sizeof(myreq)); + getString(req, "UserId", myreq.UserId); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqQryTrade(&myreq, reqid); + return i; +}; + +int StockApi::reqQryCapital(const dict &req, int reqid) +{ + CStockQryCapitalField myreq = CStockQryCapitalField(); + memset(&myreq, 0, sizeof(myreq)); + getChar(req, "Unused", &myreq.Unused); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqQryCapital(&myreq, reqid); + return i; +}; + +int StockApi::reqQryVersion(const dict &req, int reqid) +{ + CStockQryVersionField myreq = CStockQryVersionField(); + memset(&myreq, 0, sizeof(myreq)); + getString(req, "UserId", myreq.UserId); + getString(req, "UserPwd", myreq.UserPwd); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqQryVersion(&myreq, reqid); + return i; +}; + +int StockApi::reqQryPosition(const dict &req, int reqid) +{ + CStockQryPositionField myreq = CStockQryPositionField(); + memset(&myreq, 0, sizeof(myreq)); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqQryPosition(&myreq, reqid); + return i; +}; + +int StockApi::reqQryCurrency(const dict &req, int reqid) +{ + CStockQryCurrencyField myreq = CStockQryCurrencyField(); + memset(&myreq, 0, sizeof(myreq)); + getChar(req, "Unused", &myreq.Unused); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqQryCurrency(&myreq, reqid); + return i; +}; + +int StockApi::reqQryExchange(const dict &req, int reqid) +{ + CStockQryExchangeField myreq = CStockQryExchangeField(); + memset(&myreq, 0, sizeof(myreq)); + getString(req, "ProductGroupID", myreq.ProductGroupID); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqQryExchange(&myreq, reqid); + return i; +}; + +int StockApi::reqQryInstrument(const dict &req, int reqid) +{ + CStockQryInstrumentField myreq = CStockQryInstrumentField(); + memset(&myreq, 0, sizeof(myreq)); + getInt(req, "PageIndex", &myreq.PageIndex); + getString(req, "ExchangeNo", myreq.ExchangeNo); + getString(req, "ErrorDescription", myreq.ErrorDescription); + int i = this->api->ReqQryInstrument(&myreq, reqid); + return i; +}; + diff --git a/vnpy/api/da/generator/da_stock_source_module.cpp b/vnpy/api/da/generator/da_stock_source_module.cpp new file mode 100644 index 00000000..76355a34 --- /dev/null +++ b/vnpy/api/da/generator/da_stock_source_module.cpp @@ -0,0 +1,49 @@ +.def("reqUserLogin", &StockApi::reqUserLogin) +.def("reqUserLogout", &StockApi::reqUserLogout) +.def("reqSafeVerify", &StockApi::reqSafeVerify) +.def("reqVerifyCode", &StockApi::reqVerifyCode) +.def("reqSetVerifyQA", &StockApi::reqSetVerifyQA) +.def("reqGetQuestion", &StockApi::reqGetQuestion) +.def("reqOrderInsert", &StockApi::reqOrderInsert) +.def("reqOrderModify", &StockApi::reqOrderModify) +.def("reqOrderCancel", &StockApi::reqOrderCancel) +.def("reqPasswordUpdate", &StockApi::reqPasswordUpdate) +.def("reqQryTick", &StockApi::reqQryTick) +.def("reqQryOrder", &StockApi::reqQryOrder) +.def("reqQryTrade", &StockApi::reqQryTrade) +.def("reqQryCapital", &StockApi::reqQryCapital) +.def("reqQryVersion", &StockApi::reqQryVersion) +.def("reqQryPosition", &StockApi::reqQryPosition) +.def("reqQryCurrency", &StockApi::reqQryCurrency) +.def("reqQryExchange", &StockApi::reqQryExchange) +.def("reqQryInstrument", &StockApi::reqQryInstrument) + +.def("onFrontConnected", &StockApi::onFrontConnected) +.def("onFrontDisconnected", &StockApi::onFrontDisconnected) +.def("onHeartBeatWarning", &StockApi::onHeartBeatWarning) +.def("onRspNeedVerify", &StockApi::onRspNeedVerify) +.def("onRspUserLogin", &StockApi::onRspUserLogin) +.def("onRspUserLogout", &StockApi::onRspUserLogout) +.def("onRspVerifyCode", &StockApi::onRspVerifyCode) +.def("onRspSafeVerify", &StockApi::onRspSafeVerify) +.def("onRspSetVerifyQA", &StockApi::onRspSetVerifyQA) +.def("onRspAccount", &StockApi::onRspAccount) +.def("onRspQuestion", &StockApi::onRspQuestion) +.def("onRspOrderInsert", &StockApi::onRspOrderInsert) +.def("onRspOrderModify", &StockApi::onRspOrderModify) +.def("onRspOrderCancel", &StockApi::onRspOrderCancel) +.def("onRspPasswordUpdate", &StockApi::onRspPasswordUpdate) +.def("onRtnTrade", &StockApi::onRtnTrade) +.def("onRtnOrder", &StockApi::onRtnOrder) +.def("onRtnCapital", &StockApi::onRtnCapital) +.def("onRtnPosition", &StockApi::onRtnPosition) +.def("onRspQryTick", &StockApi::onRspQryTick) +.def("onRspQryOrder", &StockApi::onRspQryOrder) +.def("onRspQryTrade", &StockApi::onRspQryTrade) +.def("onRspQryCapital", &StockApi::onRspQryCapital) +.def("onRspQryVersion", &StockApi::onRspQryVersion) +.def("onRspQryPosition", &StockApi::onRspQryPosition) +.def("onRspQryCurrency", &StockApi::onRspQryCurrency) +.def("onRspQryExchange", &StockApi::onRspQryExchange) +.def("onRspQryInstrument", &StockApi::onRspQryInstrument) +; diff --git a/vnpy/api/da/generator/da_stock_source_on.cpp b/vnpy/api/da/generator/da_stock_source_on.cpp new file mode 100644 index 00000000..64844bb5 --- /dev/null +++ b/vnpy/api/da/generator/da_stock_source_on.cpp @@ -0,0 +1,336 @@ +void onFrontConnected() override +{ + try + { + PYBIND11_OVERLOAD(void, StockApi, onFrontConnected); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onFrontDisconnected(int reqid) override +{ + try + { + PYBIND11_OVERLOAD(void, StockApi, onFrontDisconnected, reqid); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onHeartBeatWarning(int reqid) override +{ + try + { + PYBIND11_OVERLOAD(void, StockApi, onHeartBeatWarning, reqid); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspNeedVerify(bool last, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, StockApi, onRspNeedVerify, last, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspUserLogin(const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, StockApi, onRspUserLogin, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspUserLogout(const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, StockApi, onRspUserLogout, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspVerifyCode(const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, StockApi, onRspVerifyCode, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspSafeVerify(const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, StockApi, onRspSafeVerify, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspSetVerifyQA(const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, StockApi, onRspSetVerifyQA, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspAccount(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, StockApi, onRspAccount, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspQuestion(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, StockApi, onRspQuestion, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspOrderInsert(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, StockApi, onRspOrderInsert, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspOrderModify(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, StockApi, onRspOrderModify, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspOrderCancel(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, StockApi, onRspOrderCancel, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspPasswordUpdate(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, StockApi, onRspPasswordUpdate, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRtnTrade(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, StockApi, onRtnTrade, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRtnOrder(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, StockApi, onRtnOrder, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRtnCapital(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, StockApi, onRtnCapital, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRtnPosition(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, StockApi, onRtnPosition, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspQryTick(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, StockApi, onRspQryTick, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspQryOrder(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, StockApi, onRspQryOrder, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspQryTrade(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, StockApi, onRspQryTrade, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspQryCapital(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, StockApi, onRspQryCapital, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspQryVersion(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, StockApi, onRspQryVersion, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspQryPosition(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, StockApi, onRspQryPosition, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspQryCurrency(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, StockApi, onRspQryCurrency, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspQryExchange(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, StockApi, onRspQryExchange, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + +void onRspQryInstrument(const dict &data, const dict &data, int reqid, bool last) override +{ + try + { + PYBIND11_OVERLOAD(void, StockApi, onRspQryInstrument, data, data, reqid, last); + } + catch (const error_already_set &e) + { + cout << e.what() << endl; + } +}; + diff --git a/vnpy/api/da/generator/da_stock_source_task.cpp b/vnpy/api/da/generator/da_stock_source_task.cpp new file mode 100644 index 00000000..52adcac1 --- /dev/null +++ b/vnpy/api/da/generator/da_stock_source_task.cpp @@ -0,0 +1,826 @@ +void StockApi::OnFrontConnected() +{ + gil_scoped_acquire acquire; + this->onFrontConnected(); +}; + +void StockApi::OnFrontDisconnected(int iReason) +{ + gil_scoped_acquire acquire; + this->onFrontDisconnected(iReason); +}; + +void StockApi::OnHeartBeatWarning(int iTimeLapse) +{ + gil_scoped_acquire acquire; + this->onHeartBeatWarning(iTimeLapse); +}; + +void StockApi::OnRspNeedVerify(bool bFirstLogin, bool bHasSetQA) +{ + gil_scoped_acquire acquire; + this->onRspNeedVerify(bFirstLogin, bHasSetQA); +}; + +void StockApi::OnRspUserLogin(CStockRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspUserLogin(data, iRequestID, bIsLast); +}; + +void StockApi::OnRspUserLogout(CStockRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspUserLogout(data, iRequestID, bIsLast); +}; + +void StockApi::OnRspVerifyCode(CStockRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspVerifyCode(data, iRequestID, bIsLast); +}; + +void StockApi::OnRspSafeVerify(CStockRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspSafeVerify(data, iRequestID, bIsLast); +}; + +void StockApi::OnRspSetVerifyQA(CStockRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspSetVerifyQA(data, iRequestID, bIsLast); +}; + +void StockApi::OnRspAccount(CStockRspAccountField *pRspAccount, CStockRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspAccount) + { + data["UserId"] = toUtf(pRspAccount->UserId); + data["UserName"] = toUtf(pRspAccount->UserName); + data["UserType"] = toUtf(pRspAccount->UserType); + data["LoginPwd"] = toUtf(pRspAccount->LoginPwd); + data["AccountNo"] = toUtf(pRspAccount->AccountNo); + data["TradePwd"] = toUtf(pRspAccount->TradePwd); + data["IsSimulation"] = toUtf(pRspAccount->IsSimulation); + data["FrontendIp"] = toUtf(pRspAccount->FrontendIp); + data["FrontendPort"] = toUtf(pRspAccount->FrontendPort); + data["CurrencyNo"] = toUtf(pRspAccount->CurrencyNo); + data["UserState"] = toUtf(pRspAccount->UserState); + data["SelAll"] = toUtf(pRspAccount->SelAll); + data["Strategy"] = toUtf(pRspAccount->Strategy); + data["Inner"] = toUtf(pRspAccount->Inner); + data["YingSun"] = toUtf(pRspAccount->YingSun); + data["ChaoDan"] = toUtf(pRspAccount->ChaoDan); + data["Option"] = toUtf(pRspAccount->Option); + data["CmeMarket"] = toUtf(pRspAccount->CmeMarket); + data["CmeCOMEXMarket"] = toUtf(pRspAccount->CmeCOMEXMarket); + data["CmeNYMEXMarket"] = toUtf(pRspAccount->CmeNYMEXMarket); + data["CmeCBTMarket"] = toUtf(pRspAccount->CmeCBTMarket); + data["IceUSMarket"] = toUtf(pRspAccount->IceUSMarket); + data["IceECMarket"] = toUtf(pRspAccount->IceECMarket); + data["IceEFMarket"] = toUtf(pRspAccount->IceEFMarket); + data["CanTradeStockHK"] = toUtf(pRspAccount->CanTradeStockHK); + data["CanTradeStockAM"] = toUtf(pRspAccount->CanTradeStockAM); + data["MultiLogin"] = toUtf(pRspAccount->MultiLogin); + data["SellStockHK"] = toUtf(pRspAccount->SellStockHK); + data["SellStockAM"] = toUtf(pRspAccount->SellStockAM); + data["CanTradeStockKRX"] = toUtf(pRspAccount->CanTradeStockKRX); + data["HkexMarket"] = toUtf(pRspAccount->HkexMarket); + data["IdNumber"] = toUtf(pRspAccount->IdNumber); + data["HkexMarketFee"] = toUtf(pRspAccount->HkexMarketFee); + data["IsProfessional"] = toUtf(pRspAccount->IsProfessional); + data["IsOverSea"] = toUtf(pRspAccount->IsOverSea); + data["IsFirstLogin"] = toUtf(pRspAccount->IsFirstLogin); + data["UserMobile"] = toUtf(pRspAccount->UserMobile); + data["HasSetQA"] = toUtf(pRspAccount->HasSetQA); + data["CanTradeStockSGXQ"] = toUtf(pRspAccount->CanTradeStockSGXQ); + data["ExistMac"] = toUtf(pRspAccount->ExistMac); + data["RatioINE"] = toUtf(pRspAccount->RatioINE); + data["EurexMarket"] = toUtf(pRspAccount->EurexMarket); + data["HkexIsOverMaxTerminal"] = toUtf(pRspAccount->HkexIsOverMaxTerminal); + data["HkexOverMoney"] = toUtf(pRspAccount->HkexOverMoney); + data["CanTradeStockAU"] = toUtf(pRspAccount->CanTradeStockAU); + data["NyFlag"] = toUtf(pRspAccount->NyFlag); + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspAccount(data, data, iRequestID, bIsLast); +}; + +void StockApi::OnRspQuestion(CStockRspQuestionField *pRspQuestion, CStockRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspQuestion) + { + data["QuestionType"] = toUtf(pRspQuestion->QuestionType); + data["QuestionId"] = toUtf(pRspQuestion->QuestionId); + data["QuestionCN"] = toUtf(pRspQuestion->QuestionCN); + data["QuestionEN"] = toUtf(pRspQuestion->QuestionEN); + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspQuestion(data, data, iRequestID, bIsLast); +}; + +void StockApi::OnRspOrderInsert(CStockRspOrderInsertField *pRspOrderInsert, CStockRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspOrderInsert) + { + data["UserId"] = toUtf(pRspOrderInsert->UserId); + data["AccountNo"] = toUtf(pRspOrderInsert->AccountNo); + data["SystemNo"] = toUtf(pRspOrderInsert->SystemNo); + data["LocalNo"] = toUtf(pRspOrderInsert->LocalNo); + data["OrderNo"] = toUtf(pRspOrderInsert->OrderNo); + data["OrigOrderNo"] = toUtf(pRspOrderInsert->OrigOrderNo); + data["OrderMethod"] = toUtf(pRspOrderInsert->OrderMethod); + data["AcceptType"] = toUtf(pRspOrderInsert->AcceptType); + data["ExchangeCode"] = toUtf(pRspOrderInsert->ExchangeCode); + data["TreatyCode"] = toUtf(pRspOrderInsert->TreatyCode); + data["BuySale"] = toUtf(pRspOrderInsert->BuySale); + data["OrderNumber"] = toUtf(pRspOrderInsert->OrderNumber); + data["OrderPrice"] = toUtf(pRspOrderInsert->OrderPrice); + data["FilledNumber"] = toUtf(pRspOrderInsert->FilledNumber); + data["FilledPrice"] = toUtf(pRspOrderInsert->FilledPrice); + data["TradeType"] = toUtf(pRspOrderInsert->TradeType); + data["PriceType"] = toUtf(pRspOrderInsert->PriceType); + data["HtsType"] = toUtf(pRspOrderInsert->HtsType); + data["OrderDate"] = toUtf(pRspOrderInsert->OrderDate); + data["OrderTime"] = toUtf(pRspOrderInsert->OrderTime); + data["ErrorCode"] = toUtf(pRspOrderInsert->ErrorCode); + data["OrderState"] = toUtf(pRspOrderInsert->OrderState); + data["IsRiskOrder"] = toUtf(pRspOrderInsert->IsRiskOrder); + data["CancelUserId"] = toUtf(pRspOrderInsert->CancelUserId); + data["TriggerPrice"] = toUtf(pRspOrderInsert->TriggerPrice); + data["ValidDate"] = toUtf(pRspOrderInsert->ValidDate); + data["AddReduce"] = toUtf(pRspOrderInsert->AddReduce); + data["StrategyId"] = toUtf(pRspOrderInsert->StrategyId); + data["MaxShow"] = toUtf(pRspOrderInsert->MaxShow); + data["MinQty"] = toUtf(pRspOrderInsert->MinQty); + data["ExchangeTime"] = toUtf(pRspOrderInsert->ExchangeTime); + data["CancelTime"] = toUtf(pRspOrderInsert->CancelTime); + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspOrderInsert(data, data, iRequestID, bIsLast); +}; + +void StockApi::OnRspOrderModify(CStockRspOrderModifyField *pRspOrderModify, CStockRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspOrderModify) + { + data["UserId"] = toUtf(pRspOrderModify->UserId); + data["AccountNo"] = toUtf(pRspOrderModify->AccountNo); + data["SystemNo"] = toUtf(pRspOrderModify->SystemNo); + data["LocalNo"] = toUtf(pRspOrderModify->LocalNo); + data["OrderNo"] = toUtf(pRspOrderModify->OrderNo); + data["OrigOrderNo"] = toUtf(pRspOrderModify->OrigOrderNo); + data["OrderMethod"] = toUtf(pRspOrderModify->OrderMethod); + data["AcceptType"] = toUtf(pRspOrderModify->AcceptType); + data["ExchangeCode"] = toUtf(pRspOrderModify->ExchangeCode); + data["TreatyCode"] = toUtf(pRspOrderModify->TreatyCode); + data["BuySale"] = toUtf(pRspOrderModify->BuySale); + data["OrderNumber"] = toUtf(pRspOrderModify->OrderNumber); + data["OrderPrice"] = toUtf(pRspOrderModify->OrderPrice); + data["FilledNumber"] = toUtf(pRspOrderModify->FilledNumber); + data["FilledPrice"] = toUtf(pRspOrderModify->FilledPrice); + data["TradeType"] = toUtf(pRspOrderModify->TradeType); + data["PriceType"] = toUtf(pRspOrderModify->PriceType); + data["HtsType"] = toUtf(pRspOrderModify->HtsType); + data["OrderDate"] = toUtf(pRspOrderModify->OrderDate); + data["OrderTime"] = toUtf(pRspOrderModify->OrderTime); + data["ErrorCode"] = toUtf(pRspOrderModify->ErrorCode); + data["OrderState"] = toUtf(pRspOrderModify->OrderState); + data["IsRiskOrder"] = toUtf(pRspOrderModify->IsRiskOrder); + data["CancelUserId"] = toUtf(pRspOrderModify->CancelUserId); + data["TriggerPrice"] = toUtf(pRspOrderModify->TriggerPrice); + data["ValidDate"] = toUtf(pRspOrderModify->ValidDate); + data["AddReduce"] = toUtf(pRspOrderModify->AddReduce); + data["StrategyId"] = toUtf(pRspOrderModify->StrategyId); + data["MaxShow"] = toUtf(pRspOrderModify->MaxShow); + data["MinQty"] = toUtf(pRspOrderModify->MinQty); + data["ExchangeTime"] = toUtf(pRspOrderModify->ExchangeTime); + data["CancelTime"] = toUtf(pRspOrderModify->CancelTime); + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspOrderModify(data, data, iRequestID, bIsLast); +}; + +void StockApi::OnRspOrderCancel(CStockRspOrderCancelField *pRspOrderCancel, CStockRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspOrderCancel) + { + data["UserId"] = toUtf(pRspOrderCancel->UserId); + data["AccountNo"] = toUtf(pRspOrderCancel->AccountNo); + data["SystemNo"] = toUtf(pRspOrderCancel->SystemNo); + data["LocalNo"] = toUtf(pRspOrderCancel->LocalNo); + data["OrderNo"] = toUtf(pRspOrderCancel->OrderNo); + data["CancelNo"] = toUtf(pRspOrderCancel->CancelNo); + data["ExchangeCode"] = toUtf(pRspOrderCancel->ExchangeCode); + data["TreatyCode"] = toUtf(pRspOrderCancel->TreatyCode); + data["BuySale"] = toUtf(pRspOrderCancel->BuySale); + data["OrderNumber"] = toUtf(pRspOrderCancel->OrderNumber); + data["OrderPrice"] = toUtf(pRspOrderCancel->OrderPrice); + data["FilledNumber"] = toUtf(pRspOrderCancel->FilledNumber); + data["CancelNumber"] = toUtf(pRspOrderCancel->CancelNumber); + data["TradeType"] = toUtf(pRspOrderCancel->TradeType); + data["PriceType"] = toUtf(pRspOrderCancel->PriceType); + data["HtsType"] = toUtf(pRspOrderCancel->HtsType); + data["CancelDate"] = toUtf(pRspOrderCancel->CancelDate); + data["CancelTime"] = toUtf(pRspOrderCancel->CancelTime); + data["ErrorCode"] = toUtf(pRspOrderCancel->ErrorCode); + data["IsRiskOrder"] = toUtf(pRspOrderCancel->IsRiskOrder); + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspOrderCancel(data, data, iRequestID, bIsLast); +}; + +void StockApi::OnRspPasswordUpdate(CStockRspPasswordUpdateField *pRspPasswordUpdate, CStockRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspPasswordUpdate) + { + data["UserId"] = toUtf(pRspPasswordUpdate->UserId); + data["OldPassword"] = toUtf(pRspPasswordUpdate->OldPassword); + data["NewPassword"] = toUtf(pRspPasswordUpdate->NewPassword); + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspPasswordUpdate(data, data, iRequestID, bIsLast); +}; + +void StockApi::OnRtnTrade(CStockRtnTradeField *pRtnTrade, CStockRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRtnTrade) + { + data["UserId"] = toUtf(pRtnTrade->UserId); + data["AccountNo"] = toUtf(pRtnTrade->AccountNo); + data["FilledNo"] = toUtf(pRtnTrade->FilledNo); + data["OrderNo"] = toUtf(pRtnTrade->OrderNo); + data["SystemNo"] = toUtf(pRtnTrade->SystemNo); + data["LocalNo"] = toUtf(pRtnTrade->LocalNo); + data["ExchangeCode"] = toUtf(pRtnTrade->ExchangeCode); + data["TreatyCode"] = toUtf(pRtnTrade->TreatyCode); + data["BuySale"] = toUtf(pRtnTrade->BuySale); + data["FilledNumber"] = toUtf(pRtnTrade->FilledNumber); + data["FilledPrice"] = toUtf(pRtnTrade->FilledPrice); + data["FilledDate"] = toUtf(pRtnTrade->FilledDate); + data["FilledTime"] = toUtf(pRtnTrade->FilledTime); + data["Commsion"] = toUtf(pRtnTrade->Commsion); + data["OrderNumber"] = toUtf(pRtnTrade->OrderNumber); + data["OrderPrice"] = toUtf(pRtnTrade->OrderPrice); + data["DeliveryDate"] = toUtf(pRtnTrade->DeliveryDate); + data["FilledType"] = toUtf(pRtnTrade->FilledType); + data["OrderType"] = toUtf(pRtnTrade->OrderType); + data["ValidDate"] = toUtf(pRtnTrade->ValidDate); + data["AddReduce"] = toUtf(pRtnTrade->AddReduce); + data["ErrorDescription"] = toUtf(pRtnTrade->ErrorDescription); + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRtnTrade(data, data, iRequestID, bIsLast); +}; + +void StockApi::OnRtnOrder(CStockRtnOrderField *pRtnOrder, CStockRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRtnOrder) + { + data["LocalOrderNo"] = toUtf(pRtnOrder->LocalOrderNo); + data["ExchangeNo"] = toUtf(pRtnOrder->ExchangeNo); + data["TreatyCode"] = toUtf(pRtnOrder->TreatyCode); + data["OrderNo"] = toUtf(pRtnOrder->OrderNo); + data["OrderNumber"] = pRtnOrder->OrderNumber; + data["FilledNumber"] = pRtnOrder->FilledNumber; + data["FilledAdvPrice"] = pRtnOrder->FilledAdvPrice; + data["BuyHoldNumber"] = pRtnOrder->BuyHoldNumber; + data["BuyHoldOpenPrice"] = pRtnOrder->BuyHoldOpenPrice; + data["BuyHoldPrice"] = pRtnOrder->BuyHoldPrice; + data["SaleHoldNumber"] = pRtnOrder->SaleHoldNumber; + data["SaleHoldOpenPrice"] = pRtnOrder->SaleHoldOpenPrice; + data["SaleHoldPrice"] = pRtnOrder->SaleHoldPrice; + data["IsCanceled"] = toUtf(pRtnOrder->IsCanceled); + data["FilledTotalFee"] = pRtnOrder->FilledTotalFee; + data["Status"] = pRtnOrder->Status; + data["AccountNo"] = toUtf(pRtnOrder->AccountNo); + data["HoldType"] = toUtf(pRtnOrder->HoldType); + data["HoldMarginBuy"] = pRtnOrder->HoldMarginBuy; + data["HoldMarginSale"] = pRtnOrder->HoldMarginSale; + data["CurrPrice"] = pRtnOrder->CurrPrice; + data["FloatProfit"] = pRtnOrder->FloatProfit; + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRtnOrder(data, data, iRequestID, bIsLast); +}; + +void StockApi::OnRtnCapital(CStockRtnCapitalField *pRtnCapital, CStockRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRtnCapital) + { + data["ClientNo"] = toUtf(pRtnCapital->ClientNo); + data["AccountNo"] = toUtf(pRtnCapital->AccountNo); + data["CurrencyNo"] = toUtf(pRtnCapital->CurrencyNo); + data["Available"] = pRtnCapital->Available; + data["YAvailable"] = pRtnCapital->YAvailable; + data["CanCashOut"] = pRtnCapital->CanCashOut; + data["Money"] = pRtnCapital->Money; + data["ExpiredProfit"] = pRtnCapital->ExpiredProfit; + data["FrozenDeposit"] = pRtnCapital->FrozenDeposit; + data["Fee"] = pRtnCapital->Fee; + data["Deposit"] = pRtnCapital->Deposit; + data["KeepDeposit"] = pRtnCapital->KeepDeposit; + data["Status"] = pRtnCapital->Status; + data["InMoney"] = pRtnCapital->InMoney; + data["OutMoney"] = pRtnCapital->OutMoney; + data["UnexpiredProfit"] = pRtnCapital->UnexpiredProfit; + data["TodayTotal"] = pRtnCapital->TodayTotal; + data["UnaccountProfit"] = pRtnCapital->UnaccountProfit; + data["Royalty"] = pRtnCapital->Royalty; + data["ExchangeNo"] = toUtf(pRtnCapital->ExchangeNo); + data["TreatyCode"] = toUtf(pRtnCapital->TreatyCode); + data["OrderNo"] = toUtf(pRtnCapital->OrderNo); + data["OrderNumber"] = pRtnCapital->OrderNumber; + data["FilledNumber"] = pRtnCapital->FilledNumber; + data["FilledAdvPrice"] = pRtnCapital->FilledAdvPrice; + data["BuyHoldNumber"] = pRtnCapital->BuyHoldNumber; + data["BuyHoldOpenPrice"] = pRtnCapital->BuyHoldOpenPrice; + data["BuyHoldPrice"] = pRtnCapital->BuyHoldPrice; + data["SaleHoldNumber"] = pRtnCapital->SaleHoldNumber; + data["SaleHoldOpenPrice"] = pRtnCapital->SaleHoldOpenPrice; + data["SaleHoldPrice"] = pRtnCapital->SaleHoldPrice; + data["IsCanceled"] = toUtf(pRtnCapital->IsCanceled); + data["FilledTotalFee"] = pRtnCapital->FilledTotalFee; + data["Credit"] = pRtnCapital->Credit; + data["MarginLimit"] = pRtnCapital->MarginLimit; + data["BorrowValue"] = pRtnCapital->BorrowValue; + data["MortgageMoney"] = pRtnCapital->MortgageMoney; + data["T1"] = pRtnCapital->T1; + data["T2"] = pRtnCapital->T2; + data["T3"] = pRtnCapital->T3; + data["TN"] = pRtnCapital->TN; + data["TradeLimit"] = pRtnCapital->TradeLimit; + data["FCrossMax"] = pRtnCapital->FCrossMax; + data["SellFreezenMoney"] = pRtnCapital->SellFreezenMoney; + data["SellInterest"] = pRtnCapital->SellInterest; + data["SellNeedAddMargin"] = pRtnCapital->SellNeedAddMargin; + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRtnCapital(data, data, iRequestID, bIsLast); +}; + +void StockApi::OnRtnPosition(CStockRtnPositionField *pRtnPosition, CStockRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRtnPosition) + { + data["ClientNo"] = toUtf(pRtnPosition->ClientNo); + data["ExchangeNo"] = toUtf(pRtnPosition->ExchangeNo); + data["CommodityNo"] = toUtf(pRtnPosition->CommodityNo); + data["Direct"] = toUtf(pRtnPosition->Direct); + data["HoldPrice"] = pRtnPosition->HoldPrice; + data["CanTradeVol"] = pRtnPosition->CanTradeVol; + data["TodayBuyVol"] = pRtnPosition->TodayBuyVol; + data["FrozenVol"] = pRtnPosition->FrozenVol; + data["TotalBuyMoney"] = pRtnPosition->TotalBuyMoney; + data["TotalSellMoney"] = pRtnPosition->TotalSellMoney; + data["TotalBuyVol"] = pRtnPosition->TotalBuyVol; + data["TotalSellVol"] = pRtnPosition->TotalSellVol; + data["OpenDate"] = toUtf(pRtnPosition->OpenDate); + data["FlatProfit"] = pRtnPosition->FlatProfit; + data["HkexT1"] = pRtnPosition->HkexT1; + data["HkexT2"] = pRtnPosition->HkexT2; + data["HkexT3"] = pRtnPosition->HkexT3; + data["UnsettleVol"] = pRtnPosition->UnsettleVol; + data["SettledVol"] = pRtnPosition->SettledVol; + data["HoldVol"] = pRtnPosition->HoldVol; + data["TodaySaleVol"] = pRtnPosition->TodaySaleVol; + data["SellFrozenMoney"] = pRtnPosition->SellFrozenMoney; + data["OpenPrice"] = pRtnPosition->OpenPrice; + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRtnPosition(data, data, iRequestID, bIsLast); +}; + +void StockApi::OnRspQryTick(CStockRspTickField *pRspTick, CStockRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspTick) + { + data["UpperTickCode"] = toUtf(pRspTick->UpperTickCode); + data["PriceFrom"] = toUtf(pRspTick->PriceFrom); + data["UpperTick"] = toUtf(pRspTick->UpperTick); + data["ProductDot"] = toUtf(pRspTick->ProductDot); + data["DotNum"] = toUtf(pRspTick->DotNum); + data["LowerTick"] = toUtf(pRspTick->LowerTick); + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspQryTick(data, data, iRequestID, bIsLast); +}; + +void StockApi::OnRspQryOrder(CStockRspOrderField *pRspOrder, CStockRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspOrder) + { + data["UserId"] = toUtf(pRspOrder->UserId); + data["AccountNo"] = toUtf(pRspOrder->AccountNo); + data["SystemNo"] = toUtf(pRspOrder->SystemNo); + data["LocalNo"] = toUtf(pRspOrder->LocalNo); + data["OrderNo"] = toUtf(pRspOrder->OrderNo); + data["OrigOrderNo"] = toUtf(pRspOrder->OrigOrderNo); + data["OrderMethod"] = toUtf(pRspOrder->OrderMethod); + data["AcceptType"] = toUtf(pRspOrder->AcceptType); + data["ExchangeCode"] = toUtf(pRspOrder->ExchangeCode); + data["TreatyCode"] = toUtf(pRspOrder->TreatyCode); + data["BuySale"] = toUtf(pRspOrder->BuySale); + data["OrderNumber"] = toUtf(pRspOrder->OrderNumber); + data["OrderPrice"] = toUtf(pRspOrder->OrderPrice); + data["FilledNumber"] = toUtf(pRspOrder->FilledNumber); + data["FilledPrice"] = toUtf(pRspOrder->FilledPrice); + data["TradeType"] = toUtf(pRspOrder->TradeType); + data["PriceType"] = toUtf(pRspOrder->PriceType); + data["HtsType"] = toUtf(pRspOrder->HtsType); + data["OrderDate"] = toUtf(pRspOrder->OrderDate); + data["OrderTime"] = toUtf(pRspOrder->OrderTime); + data["ErrorCode"] = toUtf(pRspOrder->ErrorCode); + data["OrderState"] = toUtf(pRspOrder->OrderState); + data["IsRiskOrder"] = toUtf(pRspOrder->IsRiskOrder); + data["CancelUserId"] = toUtf(pRspOrder->CancelUserId); + data["TriggerPrice"] = toUtf(pRspOrder->TriggerPrice); + data["ValidDate"] = toUtf(pRspOrder->ValidDate); + data["AddReduce"] = toUtf(pRspOrder->AddReduce); + data["StrategyId"] = toUtf(pRspOrder->StrategyId); + data["MaxShow"] = toUtf(pRspOrder->MaxShow); + data["MinQty"] = toUtf(pRspOrder->MinQty); + data["ExchangeTime"] = toUtf(pRspOrder->ExchangeTime); + data["CancelTime"] = toUtf(pRspOrder->CancelTime); + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspQryOrder(data, data, iRequestID, bIsLast); +}; + +void StockApi::OnRspQryTrade(CStockRspTradeField *pRspTrade, CStockRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspTrade) + { + data["UserId"] = toUtf(pRspTrade->UserId); + data["AccountNo"] = toUtf(pRspTrade->AccountNo); + data["FilledNo"] = toUtf(pRspTrade->FilledNo); + data["OrderNo"] = toUtf(pRspTrade->OrderNo); + data["SystemNo"] = toUtf(pRspTrade->SystemNo); + data["LocalNo"] = toUtf(pRspTrade->LocalNo); + data["ExchangeCode"] = toUtf(pRspTrade->ExchangeCode); + data["TreatyCode"] = toUtf(pRspTrade->TreatyCode); + data["BuySale"] = toUtf(pRspTrade->BuySale); + data["FilledNumber"] = toUtf(pRspTrade->FilledNumber); + data["FilledPrice"] = toUtf(pRspTrade->FilledPrice); + data["FilledDate"] = toUtf(pRspTrade->FilledDate); + data["FilledTime"] = toUtf(pRspTrade->FilledTime); + data["Commsion"] = toUtf(pRspTrade->Commsion); + data["OrderNumber"] = toUtf(pRspTrade->OrderNumber); + data["OrderPrice"] = toUtf(pRspTrade->OrderPrice); + data["DeliveryDate"] = toUtf(pRspTrade->DeliveryDate); + data["FilledType"] = toUtf(pRspTrade->FilledType); + data["OrderType"] = toUtf(pRspTrade->OrderType); + data["ValidDate"] = toUtf(pRspTrade->ValidDate); + data["AddReduce"] = toUtf(pRspTrade->AddReduce); + data["ErrorDescription"] = toUtf(pRspTrade->ErrorDescription); + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspQryTrade(data, data, iRequestID, bIsLast); +}; + +void StockApi::OnRspQryCapital(CStockRspCapitalField *pRspCapital, CStockRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspCapital) + { + data["UserId"] = toUtf(pRspCapital->UserId); + data["InMoney"] = toUtf(pRspCapital->InMoney); + data["OutMoney"] = toUtf(pRspCapital->OutMoney); + data["TodayCanUse"] = toUtf(pRspCapital->TodayCanUse); + data["TodayAmount"] = toUtf(pRspCapital->TodayAmount); + data["TodayBalance"] = toUtf(pRspCapital->TodayBalance); + data["FreezenMoney"] = toUtf(pRspCapital->FreezenMoney); + data["Commission"] = toUtf(pRspCapital->Commission); + data["Margin"] = toUtf(pRspCapital->Margin); + data["OldCanUse"] = toUtf(pRspCapital->OldCanUse); + data["OldAmount"] = toUtf(pRspCapital->OldAmount); + data["OldBalance"] = toUtf(pRspCapital->OldBalance); + data["FloatingProfit"] = toUtf(pRspCapital->FloatingProfit); + data["CurrencyNo"] = toUtf(pRspCapital->CurrencyNo); + data["CurrencyRate"] = pRspCapital->CurrencyRate; + data["UnexpiredProfit"] = pRspCapital->UnexpiredProfit; + data["UnaccountProfit"] = pRspCapital->UnaccountProfit; + data["KeepDeposit"] = pRspCapital->KeepDeposit; + data["Royalty"] = pRspCapital->Royalty; + data["Credit"] = pRspCapital->Credit; + data["AddCapital"] = pRspCapital->AddCapital; + data["IniEquity"] = pRspCapital->IniEquity; + data["AccountNo"] = toUtf(pRspCapital->AccountNo); + data["MortgageMoney"] = pRspCapital->MortgageMoney; + data["MarginLimit"] = pRspCapital->MarginLimit; + data["BorrowValue"] = pRspCapital->BorrowValue; + data["T1"] = pRspCapital->T1; + data["T2"] = pRspCapital->T2; + data["T3"] = pRspCapital->T3; + data["TN"] = pRspCapital->TN; + data["TradeLimit"] = pRspCapital->TradeLimit; + data["CanCashOut"] = pRspCapital->CanCashOut; + data["AccruedCrInt"] = pRspCapital->AccruedCrInt; + data["AccruedDrInt"] = pRspCapital->AccruedDrInt; + data["CrossMax"] = pRspCapital->CrossMax; + data["SellFreezenMoney"] = pRspCapital->SellFreezenMoney; + data["SellInterest"] = pRspCapital->SellInterest; + data["SellNeedAddMargin"] = pRspCapital->SellNeedAddMargin; + data["NetProfit"] = toUtf(pRspCapital->NetProfit); + data["ProfitRate"] = toUtf(pRspCapital->ProfitRate); + data["RiskRate"] = toUtf(pRspCapital->RiskRate); + data["ErrorDescription"] = toUtf(pRspCapital->ErrorDescription); + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspQryCapital(data, data, iRequestID, bIsLast); +}; + +void StockApi::OnRspQryVersion(CStockRspVersionField *pRspVersion, CStockRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspVersion) + { + data["Version"] = toUtf(pRspVersion->Version); + data["MustUpdate"] = toUtf(pRspVersion->MustUpdate); + data["MustVersion"] = toUtf(pRspVersion->MustVersion); + data["VersionContent_CN"] = toUtf(pRspVersion->VersionContent_CN); + data["VersionContent_US"] = toUtf(pRspVersion->VersionContent_US); + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspQryVersion(data, data, iRequestID, bIsLast); +}; + +void StockApi::OnRspQryPosition(CStockRspPositionField *pRspPosition, CStockRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspPosition) + { + data["ClientNo"] = toUtf(pRspPosition->ClientNo); + data["ExchangeNo"] = toUtf(pRspPosition->ExchangeNo); + data["CommodityNo"] = toUtf(pRspPosition->CommodityNo); + data["Direct"] = toUtf(pRspPosition->Direct); + data["HoldPrice"] = pRspPosition->HoldPrice; + data["CanTradeVol"] = pRspPosition->CanTradeVol; + data["TodayBuyVol"] = pRspPosition->TodayBuyVol; + data["FrozenVol"] = pRspPosition->FrozenVol; + data["TotalBuyMoney"] = pRspPosition->TotalBuyMoney; + data["TotalSellMoney"] = pRspPosition->TotalSellMoney; + data["TotalBuyVol"] = pRspPosition->TotalBuyVol; + data["TotalSellVol"] = pRspPosition->TotalSellVol; + data["OpenDate"] = toUtf(pRspPosition->OpenDate); + data["FlatProfit"] = pRspPosition->FlatProfit; + data["HkexT1"] = pRspPosition->HkexT1; + data["HkexT2"] = pRspPosition->HkexT2; + data["HkexT3"] = pRspPosition->HkexT3; + data["UnsettleVol"] = pRspPosition->UnsettleVol; + data["SettledVol"] = pRspPosition->SettledVol; + data["HoldVol"] = pRspPosition->HoldVol; + data["TodaySaleVol"] = pRspPosition->TodaySaleVol; + data["SellFrozenMoney"] = pRspPosition->SellFrozenMoney; + data["OpenPrice"] = pRspPosition->OpenPrice; + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspQryPosition(data, data, iRequestID, bIsLast); +}; + +void StockApi::OnRspQryCurrency(CStockRspCurrencyField *pRspCurrency, CStockRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspCurrency) + { + data["CurrencyNo"] = toUtf(pRspCurrency->CurrencyNo); + data["IsBase"] = pRspCurrency->IsBase; + data["ChangeRate"] = pRspCurrency->ChangeRate; + data["CurrencyName"] = toUtf(pRspCurrency->CurrencyName); + data["CurrencyNameEN"] = toUtf(pRspCurrency->CurrencyNameEN); + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspQryCurrency(data, data, iRequestID, bIsLast); +}; + +void StockApi::OnRspQryExchange(CStockRspExchangeField *pRspExchange, CStockRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspExchange) + { + data["ExchangeNo"] = toUtf(pRspExchange->ExchangeNo); + data["ExchangeName"] = toUtf(pRspExchange->ExchangeName); + data["SettleType"] = toUtf(pRspExchange->SettleType); + data["NameEN"] = toUtf(pRspExchange->NameEN); + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspQryExchange(data, data, iRequestID, bIsLast); +}; + +void StockApi::OnRspQryInstrument(CStockRspInstrumentField *pRspInstrument, CStockRspInfoField *pRspInfo, int iRequestID, bool bIsLast) +{ + gil_scoped_acquire acquire; + dict data; + if (pRspInstrument) + { + data["ExchangeNo"] = toUtf(pRspInstrument->ExchangeNo); + data["ExchangeName"] = toUtf(pRspInstrument->ExchangeName); + data["CommodityNo"] = toUtf(pRspInstrument->CommodityNo); + data["CommodityName"] = toUtf(pRspInstrument->CommodityName); + data["CommodityType"] = toUtf(pRspInstrument->CommodityType); + data["CurrencyNo"] = toUtf(pRspInstrument->CurrencyNo); + data["CurrencyName"] = toUtf(pRspInstrument->CurrencyName); + data["ProductDot"] = pRspInstrument->ProductDot; + data["UpperTick"] = pRspInstrument->UpperTick; + data["SettlePrice"] = pRspInstrument->SettlePrice; + data["TradeMonth"] = toUtf(pRspInstrument->TradeMonth); + data["DotNum"] = pRspInstrument->DotNum; + data["LowerTick"] = pRspInstrument->LowerTick; + data["DotNumCarry"] = pRspInstrument->DotNumCarry; + data["UpperTickCarry"] = pRspInstrument->UpperTickCarry; + data["FirstNoticeDay"] = toUtf(pRspInstrument->FirstNoticeDay); + data["FreezenPercent"] = pRspInstrument->FreezenPercent; + data["FreezenMoney"] = pRspInstrument->FreezenMoney; + data["FeeMoney"] = pRspInstrument->FeeMoney; + data["FeePercent"] = pRspInstrument->FeePercent; + data["PriceStrike"] = pRspInstrument->PriceStrike; + data["ProductDotStrike"] = pRspInstrument->ProductDotStrike; + data["UpperTickStrike"] = pRspInstrument->UpperTickStrike; + data["LastTradeDay"] = toUtf(pRspInstrument->LastTradeDay); + data["LastUpdateDay"] = toUtf(pRspInstrument->LastUpdateDay); + data["CriticalPrice"] = pRspInstrument->CriticalPrice; + data["CriticalMinChangedPrice"] = pRspInstrument->CriticalMinChangedPrice; + data["ExchangeSub"] = toUtf(pRspInstrument->ExchangeSub); + data["OptionType"] = toUtf(pRspInstrument->OptionType); + data["OptionMonth"] = toUtf(pRspInstrument->OptionMonth); + data["OptionStrikePrice"] = toUtf(pRspInstrument->OptionStrikePrice); + data["OptionCommodityNo"] = toUtf(pRspInstrument->OptionCommodityNo); + data["OptionContractNo"] = toUtf(pRspInstrument->OptionContractNo); + data["MortgagePercent"] = toUtf(pRspInstrument->MortgagePercent); + data["UpperTickCode"] = toUtf(pRspInstrument->UpperTickCode); + data["LotSize"] = toUtf(pRspInstrument->LotSize); + data["FlatTime"] = toUtf(pRspInstrument->FlatTime); + data["CommodityFNameEN"] = toUtf(pRspInstrument->CommodityFNameEN); + data["CanSell"] = toUtf(pRspInstrument->CanSell); + data["SellRate"] = pRspInstrument->SellRate; + data["SellMax"] = pRspInstrument->SellMax; + data["StrikeRate"] = pRspInstrument->StrikeRate; + data["StrikePrice"] = pRspInstrument->StrikePrice; + data["ReceivePrice"] = pRspInstrument->ReceivePrice; + data["ExpireDate"] = toUtf(pRspInstrument->ExpireDate); + data["SellRateKeep"] = pRspInstrument->SellRateKeep; + data["StrikeCommodityNo"] = toUtf(pRspInstrument->StrikeCommodityNo); + data["CallPutFlag"] = toUtf(pRspInstrument->CallPutFlag); + data["Publisher"] = toUtf(pRspInstrument->Publisher); + } + dict data; + if (pRspInfo) + { + data["ErrorID"] = pRspInfo->ErrorID; + data["ErrorMsg"] = toUtf(pRspInfo->ErrorMsg); + } + this->onRspQryInstrument(data, data, iRequestID, bIsLast); +}; + diff --git a/vnpy/api/da/generator/da_stock_struct.py b/vnpy/api/da/generator/da_stock_struct.py index 0d7324aa..896e8e91 100644 --- a/vnpy/api/da/generator/da_stock_struct.py +++ b/vnpy/api/da/generator/da_stock_struct.py @@ -155,7 +155,7 @@ CStockReqOrderModifyField = { "ErrorDescription": "string", } -CStockRspOrderInsertField = CStockRspOrderModifyField +CStockRspOrderModifyField = CStockRspOrderInsertField CStockReqOrderCancelField = { "UserId": "string", @@ -556,9 +556,9 @@ CStockRtnCapitalField = { "SellNeedAddMargin": "double", } -CStockRspPositionField = CStockRtnPositionField +CStockRtnPositionField = CStockRspPositionField -CStockRspTradeField = CStockRtnTradeField +CStockRtnTradeField = CStockRspTradeField CStockReqGetQuestionField = { "Unused": "int", diff --git a/vnpy/api/da/generator/generate_api_functions.py b/vnpy/api/da/generator/generate_api_functions.py index d9dbe612..123b7b92 100644 --- a/vnpy/api/da/generator/generate_api_functions.py +++ b/vnpy/api/da/generator/generate_api_functions.py @@ -21,7 +21,7 @@ class ApiGenerator: def load_struct(self): """鍔犺浇Struct""" - module_name = f"{self.prefix}_struct" + module_name = f"{self.prefix}_{self.name}_struct" module = importlib.import_module(module_name) for name in dir(module): @@ -37,14 +37,10 @@ class ApiGenerator: self.f_cpp.close() - self.generate_header_define() - self.generate_header_process() self.generate_header_on() self.generate_header_function() self.generate_source_task() - self.generate_source_switch() - self.generate_source_process() self.generate_source_function() self.generate_source_on() self.generate_source_module() @@ -57,10 +53,10 @@ class ApiGenerator: line = line.replace("\n", "") line = line.replace("\t", "") line = line.replace("{}", "") - + if "virtual void On" in line: self.process_callback(line) - elif "virtual int Req" in line: + elif "virtual bool Req" in line: self.process_function(line) def process_callback(self, line: str): @@ -87,28 +83,12 @@ class ApiGenerator: d = {} for arg in args: + arg = arg.replace("const ", "") words = arg.split(" ") words = [word for word in words if word] d[words[1].replace("*", "")] = words[0] return d - def generate_header_define(self): - """""" - filename = f"{self.prefix}_{self.name}_header_define.h" - with open(filename, "w") as f: - for n, name in enumerate(self.callbacks.keys()): - line = f"#define {name.upper()} {n}\n" - f.write(line) - - def generate_header_process(self): - """""" - filename = f"{self.prefix}_{self.name}_header_process.h" - with open(filename, "w") as f: - for name in self.callbacks.keys(): - name = name.replace("On", "process") - line = f"void {name}(Task *task);\n\n" - f.write(line) - def generate_header_on(self): """""" filename = f"{self.prefix}_{self.name}_header_on.h" @@ -117,12 +97,13 @@ class ApiGenerator: name = name.replace("On", "on") args_list = [] + for type_ in d.values(): if type_ == "int": args_list.append("int reqid") elif type_ == "bool": args_list.append("bool last") - elif type_ == "CThostFtdcRspInfoField": + elif type_ == "CMarketRspInfoField": args_list.append("const dict &error") else: args_list.append("const dict &data") @@ -147,58 +128,9 @@ class ApiGenerator: with open(filename, "w") as f: for name, d in self.callbacks.items(): line = self.lines[name] - - f.write(line.replace("virtual void ", - f"void {self.class_name}::") + "\n") - f.write("{\n") - f.write("\tTask task = Task();\n") - f.write(f"\ttask.task_name = {name.upper()};\n") - - for field, type_ in d.items(): - if type_ == "int": - f.write(f"\ttask.task_id = {field};\n") - elif type_ == "bool": - f.write(f"\ttask.task_last = {field};\n") - elif type_ == "CThostFtdcRspInfoField": - f.write(f"\tif ({field})\n") - f.write("\t{\n") - f.write(f"\t\t{type_} *task_error = new {type_}();\n") - f.write(f"\t\t*task_error = *{field};\n") - f.write(f"\t\ttask.task_error = task_error;\n") - f.write("\t}\n") - else: - f.write(f"\tif ({field})\n") - f.write("\t{\n") - f.write(f"\t\t{type_} *task_data = new {type_}();\n") - f.write(f"\t\t*task_data = *{field};\n") - f.write(f"\t\ttask.task_data = task_data;\n") - f.write("\t}\n") - - f.write(f"\tthis->task_queue.push(task);\n") - f.write("};\n\n") - - def generate_source_switch(self): - """""" - filename = f"{self.prefix}_{self.name}_source_switch.cpp" - with open(filename, "w") as f: - for name in self.callbacks.keys(): - process_name = name.replace("On", "process") - f.write(f"case {name.upper()}:\n") - f.write("{\n") - f.write(f"\tthis->{process_name}(&task);\n") - f.write(f"\tbreak;\n") - f.write("}\n\n") - - def generate_source_process(self): - """""" - filename = f"{self.prefix}_{self.name}_source_process.cpp" - with open(filename, "w") as f: - for name, d in self.callbacks.items(): - process_name = name.replace("On", "process") on_name = name.replace("On", "on") - f.write( - f"void {self.class_name}::{process_name}(Task *task)\n") + f.write(line.replace("virtual void ", f"void {self.class_name}::") + "\n") f.write("{\n") f.write("\tgil_scoped_acquire acquire;\n") @@ -206,48 +138,40 @@ class ApiGenerator: for field, type_ in d.items(): if type_ == "int": - args.append("task->task_id") + args.append(field) elif type_ == "bool": - args.append("task->task_last") - elif type_ == "CThostFtdcRspInfoField": + args.append(field) + elif type_ == "char*": + args.append(f"string({field})") + elif type_ == "CMarketRspInfoField": args.append("error") f.write("\tdict error;\n") - f.write("\tif (task->task_error)\n") + f.write("\tif (pRspInfo)\n") f.write("\t{\n") - f.write( - f"\t\t{type_} *task_error = ({type_}*)task->task_error;\n") - + struct_fields = self.structs[type_] for struct_field, struct_type in struct_fields.items(): if struct_type == "string": - f.write( - f"\t\terror[\"{struct_field}\"] = toUtf(task_error->{struct_field});\n") + f.write(f"\t\terror[\"{struct_field}\"] = toUtf({field}->{struct_field});\n") else: - f.write( - f"\t\terror[\"{struct_field}\"] = task_error->{struct_field};\n") + f.write(f"\t\terror[\"{struct_field}\"] = {field}->{struct_field};\n") - f.write("\t\tdelete task_error;\n") f.write("\t}\n") else: args.append("data") f.write("\tdict data;\n") - f.write("\tif (task->task_data)\n") + f.write(f"\tif ({field})\n") f.write("\t{\n") - f.write( - f"\t\t{type_} *task_data = ({type_}*)task->task_data;\n") - + struct_fields = self.structs[type_] for struct_field, struct_type in struct_fields.items(): if struct_type == "string": - f.write( - f"\t\tdata[\"{struct_field}\"] = toUtf(task_data->{struct_field});\n") + f.write(f"\t\tdata[\"{struct_field}\"] = toUtf({field}->{struct_field});\n") else: - f.write( - f"\t\tdata[\"{struct_field}\"] = task_data->{struct_field};\n") + f.write(f"\t\tdata[\"{struct_field}\"] = {field}->{struct_field};\n") - f.write("\t\tdelete task_data;\n") f.write("\t}\n") args_str = ", ".join(args) @@ -296,7 +220,7 @@ class ApiGenerator: elif type_ == "bool": args.append("bool last") bind_args.append("last") - elif type_ == "CThostFtdcRspInfoField": + elif type_ == "CMarketRspInfoField": args.append("const dict &error") bind_args.append("error") else: @@ -336,8 +260,11 @@ class ApiGenerator: if __name__ == "__main__": - md_generator = ApiGenerator("../include/ctp/ThostFtdcMdApi.h", "ctp", "md", "MdApi") - md_generator.run() + market_generator = ApiGenerator("../include/da/DAMarketApi.h", "da", "market", "MarketApi") + market_generator.run() - td_generator = ApiGenerator("../include/ctp/ThostFtdcTraderApi.h", "ctp", "td", "TdApi") - td_generator.run() + future_generator = ApiGenerator("../include/da/DAFutureApi.h", "da", "future", "FutureApi") + future_generator.run() + + stock_generator = ApiGenerator("../include/da/DAStockApi.h", "da", "stock", "StockApi") + stock_generator.run() diff --git a/vnpy/api/da/generator/generate_struct.py b/vnpy/api/da/generator/generate_struct.py index 530ad53b..dc2a79e0 100644 --- a/vnpy/api/da/generator/generate_struct.py +++ b/vnpy/api/da/generator/generate_struct.py @@ -58,7 +58,7 @@ class StructGenerator: words = line.split(" ") name = words[1] value = words[2] - new_line = f"{name} = {value}\n\n" + new_line = f"{value} = {name}\n\n" self.f_struct.write(new_line) def process_declare(self, line: str): diff --git a/vnpy/api/da/include/da/DAFutureApi.h b/vnpy/api/da/include/da/DAFutureApi.h index 035161bf..42c6bdad 100644 --- a/vnpy/api/da/include/da/DAFutureApi.h +++ b/vnpy/api/da/include/da/DAFutureApi.h @@ -14,9 +14,9 @@ class IFutureEvent { //状态函数 public: - virtual void OnFrontConnected() {}; - virtual void OnFrontDisconnected(int iReason) {}; - virtual void OnHeartBeatWarning(int iTimeLapse) {}; + virtual void OnFrontConnected(){}; + virtual void OnFrontDisconnected(int iReason){}; + virtual void OnHeartBeatWarning(int iTimeLapse){}; //请求函数 public: @@ -54,8 +54,8 @@ public: virtual void OnRspQryInstrument(CFutureRspInstrumentField *pRspInstrument, CFutureRspInfoField *pRspInfo, int iRequestID, bool bIsLast) {} virtual void OnRspQryExchangeTime(CFutureRspExchangeTimeField *pRspExchangeTime, CFutureRspInfoField *pRspInfo, int iRequestID, bool bIsLast) {} virtual void OnRspQryCommodityTime(CFutureRspCommodityTimeField *pRspCommodityTime, CFutureRspInfoField *pRspInfo, int iRequestID, bool bIsLast) {} - virtual void OnRspQryTotalPosition(CFutureRspTotalPositionField* pRspTotalPosition, CFutureRspInfoField *pRspInfo, int iRequestID, bool bIsLast) {} - virtual void OnRspQryStrategyDetail(CFutureRspStrategyDetailField* pRspStrategyDetail, CFutureRspInfoField *pRspInfo, int iRequestID, bool bIsLast) {} + virtual void OnRspQryTotalPosition(CFutureRspTotalPositionField *pRspTotalPosition, CFutureRspInfoField *pRspInfo, int iRequestID, bool bIsLast) {} + virtual void OnRspQryStrategyDetail(CFutureRspStrategyDetailField *pRspStrategyDetail, CFutureRspInfoField *pRspInfo, int iRequestID, bool bIsLast) {} }; class DA_API_EXPORT CFutureApi @@ -63,12 +63,12 @@ class DA_API_EXPORT CFutureApi // 静态函数 public: static const char *GetVersion(); - static CFutureApi *CreateFutureApi(bool bRecordLog, const char* lpszLogFileName = "Future.log"); + static CFutureApi *CreateFutureApi(bool bRecordLog, const char *lpszLogFileName = "Future.log"); // 构造函数 public: - CFutureApi() {}; - virtual ~CFutureApi() {}; + CFutureApi(){}; + virtual ~CFutureApi(){}; // 初始化函数 public: @@ -90,7 +90,7 @@ public: virtual bool ReqOrderModify(CFutureReqOrderModifyField *pReqOrderModify, int iRequestID) = 0; virtual bool ReqOrderCancel(CFutureReqOrderCancelField *pReqOrderCancel, int iRequestID) = 0; virtual bool ReqPasswordUpdate(CFutureReqPasswordUpdateField *pReqPasswordUpdate, int iRequestID) = 0; - + // 查询函数 public: virtual bool ReqQryOrder(CFutureQryOrderField *pQryOrder, int iRequestID) = 0; @@ -108,4 +108,3 @@ public: virtual bool ReqQryTotalPosition(CFutureQryTotalPositionField *pQryTotalPosition, int iRequestID) = 0; virtual bool ReqQryStrategyDetail(CFutureQryStrategyDetailField *pQryStrategyDetail, int iRequestID) = 0; }; - diff --git a/vnpy/api/da/include/da/DAMarketApi.h b/vnpy/api/da/include/da/DAMarketApi.h index 27edb64c..d9a26b77 100644 --- a/vnpy/api/da/include/da/DAMarketApi.h +++ b/vnpy/api/da/include/da/DAMarketApi.h @@ -12,13 +12,13 @@ class IMarketEvent { - //状态函数 + //状态锟斤拷锟斤拷 public: virtual void OnFrontConnected() {}; virtual void OnFrontDisconnected(int iReason) {}; virtual void OnHeartBeatWarning(int iTimeLapse) {}; - //请求函数 + //锟斤拷锟斤拷锟斤拷 public: virtual void OnRspRawData(const char* rawData) {} virtual void OnRspUserLogin(CMarketRspInfoField *pRspInfo, int iRequestID, bool bIsLast) {}; @@ -29,17 +29,17 @@ public: class DA_API_EXPORT CMarketApi { - // 静态函数 + // 锟斤拷态锟斤拷锟斤拷 public: static const char *GetVersion(); static CMarketApi *CreateMarketApi(bool bRecordLog, const char* lpszLogFileName = "Market.log"); - // 构造函数 + // 锟斤拷锟届函锟斤拷 public: CMarketApi() {}; virtual ~CMarketApi() {}; - // 初始化函数 + // 锟斤拷始锟斤拷锟斤拷锟斤拷 public: virtual bool Init() = 0; virtual void Release() = 0; @@ -47,11 +47,11 @@ public: virtual void RegisterSpi(IMarketEvent *pIMarketEvent) = 0; virtual void RegisterNameServer(const char *pszNsAddress) = 0; - // 请求函数 + // 锟斤拷锟斤拷锟斤拷 public: virtual bool ReqUserLogin(CMarketReqUserLoginField *pReqUserLoginField, int iRequestID) = 0; - virtual bool ReqBrokerData(CMarketReqBrokerDataField* pReqBrokerDataField, int iRequestID) = 0; - virtual bool ReqMarketData(CMarketReqMarketDataField* pReqMarketDataField, int iRequestID) = 0; + virtual bool ReqBrokerData(CMarketReqBrokerDataField *pReqBrokerDataField, int iRequestID) = 0; + virtual bool ReqMarketData(CMarketReqMarketDataField *pReqMarketDataField, int iRequestID) = 0; }; diff --git a/vnpy/api/da/libs/_DAApi_x64.lib b/vnpy/api/da/libs/_DAApi_x64.lib deleted file mode 100644 index c45b37cc..00000000 Binary files a/vnpy/api/da/libs/_DAApi_x64.lib and /dev/null differ diff --git a/vnpy/api/da/vnda/vnda.h b/vnpy/api/da/vnda/vnda.h new file mode 100644 index 00000000..8bd3bd89 --- /dev/null +++ b/vnpy/api/da/vnda/vnda.h @@ -0,0 +1,88 @@ +#include +#include +#include +#include +#include + +#include "pybind11/pybind11.h" + + +using namespace std; +using namespace pybind11; + + +//从字典中获取某个建值对应的整数,并赋值到请求结构体对象的值上 +void getInt(const dict &d, const char *key, int *value) +{ + if (d.contains(key)) //检查字典中是否存在该键值 + { + object o = d[key]; //获取该键值 + *value = o.cast(); + } +}; + + +//从字典中获取某个建值对应的浮点数,并赋值到请求结构体对象的值上 +void getDouble(const dict &d, const char *key, double *value) +{ + if (d.contains(key)) + { + object o = d[key]; + *value = o.cast(); + } +}; + + +//从字典中获取某个建值对应的字符,并赋值到请求结构体对象的值上 +void getChar(const dict &d, const char *key, char *value) +{ + if (d.contains(key)) + { + object o = d[key]; + *value = o.cast(); + } +}; + + +template +using string_literal = char[size]; + +//从字典中获取某个建值对应的字符串,并赋值到请求结构体对象的值上 +template +void getString(const pybind11::dict &d, const char *key, string_literal &value) +{ + if (d.contains(key)) + { + object o = d[key]; + string s = o.cast(); + const char *buf = s.c_str(); + strcpy(value, buf); + } +}; + +//将GBK编码的字符串转换为UTF8 +inline string toUtf(const string &gb2312) +{ +#ifdef _MSC_VER + const static locale loc("zh-CN"); +#else + const static locale loc("zh_CN.GB18030"); +#endif + + vector wstr(gb2312.size()); + wchar_t* wstrEnd = nullptr; + const char* gbEnd = nullptr; + mbstate_t state = {}; + int res = use_facet > + (loc).in(state, + gb2312.data(), gb2312.data() + gb2312.size(), gbEnd, + wstr.data(), wstr.data() + wstr.size(), wstrEnd); + + if (codecvt_base::ok == res) + { + wstring_convert> cutf8; + return cutf8.to_bytes(wstring(wstr.data(), wstrEnd)); + } + + return string(); +} diff --git a/vnpy/api/da/vnda/vnda.sln b/vnpy/api/da/vnda/vnda.sln new file mode 100644 index 00000000..4b2114d7 --- /dev/null +++ b/vnpy/api/da/vnda/vnda.sln @@ -0,0 +1,51 @@ +锘 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28010.2003 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vndamarket", "vndamarket\vndamarket.vcxproj", "{2F6FA88B-CD40-465C-860E-2FCC354CBB11}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vndafuture", "vndafuture\vndafuture.vcxproj", "{0B01BFAB-DB45-4B6E-AB61-0870DD596339}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vndastock", "vndastock\vndastock.vcxproj", "{7EA519E8-2D38-4EA8-AFC1-D8F913AB46B3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2F6FA88B-CD40-465C-860E-2FCC354CBB11}.Debug|x64.ActiveCfg = Debug|x64 + {2F6FA88B-CD40-465C-860E-2FCC354CBB11}.Debug|x64.Build.0 = Debug|x64 + {2F6FA88B-CD40-465C-860E-2FCC354CBB11}.Debug|x86.ActiveCfg = Debug|Win32 + {2F6FA88B-CD40-465C-860E-2FCC354CBB11}.Debug|x86.Build.0 = Debug|Win32 + {2F6FA88B-CD40-465C-860E-2FCC354CBB11}.Release|x64.ActiveCfg = Release|x64 + {2F6FA88B-CD40-465C-860E-2FCC354CBB11}.Release|x64.Build.0 = Release|x64 + {2F6FA88B-CD40-465C-860E-2FCC354CBB11}.Release|x86.ActiveCfg = Release|Win32 + {2F6FA88B-CD40-465C-860E-2FCC354CBB11}.Release|x86.Build.0 = Release|Win32 + {0B01BFAB-DB45-4B6E-AB61-0870DD596339}.Debug|x64.ActiveCfg = Debug|x64 + {0B01BFAB-DB45-4B6E-AB61-0870DD596339}.Debug|x64.Build.0 = Debug|x64 + {0B01BFAB-DB45-4B6E-AB61-0870DD596339}.Debug|x86.ActiveCfg = Debug|Win32 + {0B01BFAB-DB45-4B6E-AB61-0870DD596339}.Debug|x86.Build.0 = Debug|Win32 + {0B01BFAB-DB45-4B6E-AB61-0870DD596339}.Release|x64.ActiveCfg = Release|x64 + {0B01BFAB-DB45-4B6E-AB61-0870DD596339}.Release|x64.Build.0 = Release|x64 + {0B01BFAB-DB45-4B6E-AB61-0870DD596339}.Release|x86.ActiveCfg = Release|Win32 + {0B01BFAB-DB45-4B6E-AB61-0870DD596339}.Release|x86.Build.0 = Release|Win32 + {7EA519E8-2D38-4EA8-AFC1-D8F913AB46B3}.Debug|x64.ActiveCfg = Debug|x64 + {7EA519E8-2D38-4EA8-AFC1-D8F913AB46B3}.Debug|x64.Build.0 = Debug|x64 + {7EA519E8-2D38-4EA8-AFC1-D8F913AB46B3}.Debug|x86.ActiveCfg = Debug|Win32 + {7EA519E8-2D38-4EA8-AFC1-D8F913AB46B3}.Debug|x86.Build.0 = Debug|Win32 + {7EA519E8-2D38-4EA8-AFC1-D8F913AB46B3}.Release|x64.ActiveCfg = Release|x64 + {7EA519E8-2D38-4EA8-AFC1-D8F913AB46B3}.Release|x64.Build.0 = Release|x64 + {7EA519E8-2D38-4EA8-AFC1-D8F913AB46B3}.Release|x86.ActiveCfg = Release|Win32 + {7EA519E8-2D38-4EA8-AFC1-D8F913AB46B3}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {8B2AFD3D-5C06-4ABA-9980-87896FEFA9BC} + EndGlobalSection +EndGlobal diff --git a/vnpy/api/da/vnda/vndafuture/dllmain.cpp b/vnpy/api/da/vnda/vndafuture/dllmain.cpp new file mode 100644 index 00000000..bc73c03e Binary files /dev/null and b/vnpy/api/da/vnda/vndafuture/dllmain.cpp differ diff --git a/vnpy/api/da/vnda/vndafuture/stdafx.cpp b/vnpy/api/da/vnda/vndafuture/stdafx.cpp new file mode 100644 index 00000000..08343afd Binary files /dev/null and b/vnpy/api/da/vnda/vndafuture/stdafx.cpp differ diff --git a/vnpy/api/da/vnda/vndafuture/stdafx.h b/vnpy/api/da/vnda/vndafuture/stdafx.h new file mode 100644 index 00000000..7e9fc495 Binary files /dev/null and b/vnpy/api/da/vnda/vndafuture/stdafx.h differ diff --git a/vnpy/api/da/vnda/vndafuture/targetver.h b/vnpy/api/da/vnda/vndafuture/targetver.h new file mode 100644 index 00000000..7f8bdf09 Binary files /dev/null and b/vnpy/api/da/vnda/vndafuture/targetver.h differ diff --git a/vnpy/api/da/vnda/vndafuture/vndafuture.cpp b/vnpy/api/da/vnda/vndafuture/vndafuture.cpp new file mode 100644 index 00000000..fe6e5042 Binary files /dev/null and b/vnpy/api/da/vnda/vndafuture/vndafuture.cpp differ diff --git a/vnpy/api/da/vnda/vndafuture/vndafuture.vcxproj b/vnpy/api/da/vnda/vndafuture/vndafuture.vcxproj new file mode 100644 index 00000000..a0cae41c --- /dev/null +++ b/vnpy/api/da/vnda/vndafuture/vndafuture.vcxproj @@ -0,0 +1,169 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {0B01BFAB-DB45-4B6E-AB61-0870DD596339} + Win32Proj + vndafuture + 10.0.17763.0 + + + + DynamicLibrary + true + v141 + Unicode + + + DynamicLibrary + false + v141 + true + Unicode + + + DynamicLibrary + true + v141 + Unicode + + + DynamicLibrary + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Use + Level3 + Disabled + true + WIN32;_DEBUG;VNDAFUTURE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + + + Windows + true + + + + + Use + Level3 + Disabled + true + _DEBUG;VNDAFUTURE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + + + Windows + true + + + + + Use + Level3 + MaxSpeed + true + true + true + WIN32;NDEBUG;VNDAFUTURE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + + + Use + Level3 + MaxSpeed + true + true + true + NDEBUG;VNDAFUTURE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + + \ No newline at end of file diff --git a/vnpy/api/da/vnda/vndafuture/vndafuture.vcxproj.filters b/vnpy/api/da/vnda/vndafuture/vndafuture.vcxproj.filters new file mode 100644 index 00000000..3392dee3 --- /dev/null +++ b/vnpy/api/da/vnda/vndafuture/vndafuture.vcxproj.filters @@ -0,0 +1,45 @@ +锘 + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 澶存枃浠 + + + 澶存枃浠 + + + 澶存枃浠 + + + 澶存枃浠 + + + 澶存枃浠 + + + + + 婧愭枃浠 + + + 婧愭枃浠 + + + 婧愭枃浠 + + + \ No newline at end of file diff --git a/vnpy/api/da/vnda/vndafuture/vndafuture.vcxproj.user b/vnpy/api/da/vnda/vndafuture/vndafuture.vcxproj.user new file mode 100644 index 00000000..be250787 --- /dev/null +++ b/vnpy/api/da/vnda/vndafuture/vndafuture.vcxproj.user @@ -0,0 +1,4 @@ +锘 + + + \ No newline at end of file diff --git a/vnpy/api/da/vnda/vndamarket/dllmain.cpp b/vnpy/api/da/vnda/vndamarket/dllmain.cpp new file mode 100644 index 00000000..bc73c03e Binary files /dev/null and b/vnpy/api/da/vnda/vndamarket/dllmain.cpp differ diff --git a/vnpy/api/da/vnda/vndamarket/stdafx.cpp b/vnpy/api/da/vnda/vndamarket/stdafx.cpp new file mode 100644 index 00000000..08343afd Binary files /dev/null and b/vnpy/api/da/vnda/vndamarket/stdafx.cpp differ diff --git a/vnpy/api/da/vnda/vndamarket/stdafx.h b/vnpy/api/da/vnda/vndamarket/stdafx.h new file mode 100644 index 00000000..7e9fc495 Binary files /dev/null and b/vnpy/api/da/vnda/vndamarket/stdafx.h differ diff --git a/vnpy/api/da/vnda/vndamarket/targetver.h b/vnpy/api/da/vnda/vndamarket/targetver.h new file mode 100644 index 00000000..7f8bdf09 Binary files /dev/null and b/vnpy/api/da/vnda/vndamarket/targetver.h differ diff --git a/vnpy/api/da/vnda/vndamarket/vndamarket.cpp b/vnpy/api/da/vnda/vndamarket/vndamarket.cpp new file mode 100644 index 00000000..bc75a6e6 Binary files /dev/null and b/vnpy/api/da/vnda/vndamarket/vndamarket.cpp differ diff --git a/vnpy/api/da/vnda/vndamarket/vndamarket.h b/vnpy/api/da/vnda/vndamarket/vndamarket.h new file mode 100644 index 00000000..0322705a --- /dev/null +++ b/vnpy/api/da/vnda/vndamarket/vndamarket.h @@ -0,0 +1,91 @@ +//系统 +#ifdef WIN32 +#include "stdafx.h" +#endif + +#include + +#include "vnda.h" +#include "pybind11/pybind11.h" +#include "da/DAMarketApi.h" + +using namespace pybind11; +using namespace std; + +///------------------------------------------------------------------------------------- +///C++ SPI的回调函数方法实现 +///------------------------------------------------------------------------------------- + +//API的继承实现 +class MarketApi : public IMarketEvent +{ +private: + CMarketApi* api; //API对象 + +public: + MarketApi() + { + }; + + ~MarketApi() + { + }; + + //------------------------------------------------------------------------------------- + //API回调函数 + //------------------------------------------------------------------------------------- + + void OnFrontConnected(); + void OnFrontDisconnected(int iReason); + void OnHeartBeatWarning(int iTimeLapse); + + void OnRspRawData(const char* rawData); + void OnRspUserLogin(CMarketRspInfoField *pRspInfo, int iRequestID, bool bIsLast); + void OnRspTradeDate(CMarketRspTradeDateField *pRspTradeDate, CMarketRspInfoField *pRspInfo, int iRequestID, bool bIsLast); + void OnRspBrokerData(CMarketRspBrokerDataField *pRspBrokerData, CMarketRspInfoField *pRspInfo, int iRequestID, bool bIsLast); + void OnRspMarketData(CMarketRspMarketDataField *pRspMarketData, CMarketRspInfoField *pRspInfo, int iRequestID, bool bIsLast); + + //------------------------------------------------------------------------------------- + //Python回调函数 + //------------------------------------------------------------------------------------- + + virtual void onFrontConnected() {}; + + virtual void onFrontDisconnected(int reqid) {}; + + virtual void onHeartBeatWarning(int reqid) {}; + + virtual void onRspRawData(string data) {}; + + virtual void onRspUserLogin(const dict &error, int reqid, bool last) {}; + + virtual void onRspTradeDate(const dict &data, const dict &error, int reqid, bool last) {}; + + virtual void onRspBrokerData(const dict &data, const dict &error, int reqid, bool last) {}; + + virtual void onRspMarketData(const dict &data, const dict &error, int reqid, bool last) {}; + + //------------------------------------------------------------------------------------- + //req:主动函数的请求字典 + //------------------------------------------------------------------------------------- + + string getVersion(); + + void createMarketApi(bool recordLog, string logFileName); + + void init(); + + void release(); + + int exit(); + + void setHeartbeatTimeout(int timeout); + + void registerNameServer(string address); + + int reqUserLogin(const dict &req, int reqid); + + int reqBrokerData(const dict &req, int reqid); + + int reqMarketData(const dict &req, int reqid); +}; diff --git a/vnpy/api/da/vnda/vndamarket/vndamarket.vcxproj b/vnpy/api/da/vnda/vndamarket/vndamarket.vcxproj new file mode 100644 index 00000000..2f390b16 --- /dev/null +++ b/vnpy/api/da/vnda/vndamarket/vndamarket.vcxproj @@ -0,0 +1,178 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {2F6FA88B-CD40-465C-860E-2FCC354CBB11} + Win32Proj + vndamarket + 10.0.17763.0 + + + + DynamicLibrary + true + v141 + Unicode + + + DynamicLibrary + false + v141 + true + Unicode + + + DynamicLibrary + true + v141 + Unicode + + + DynamicLibrary + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + $(SolutionDir)..\ + .pyd + C:\Miniconda3\include;$(SolutionDir);$(SolutionDir)..\include;$(SolutionDir)..\include\da;$(IncludePath) + C:\Miniconda3\libs;$(SolutionDir)..\libs;$(LibraryPath) + + + + Use + Level3 + Disabled + true + WIN32;_DEBUG;VNDAMARKET_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + + + Windows + true + + + + + Use + Level3 + Disabled + true + _DEBUG;VNDAMARKET_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + + + Windows + true + + + + + Use + Level3 + MaxSpeed + true + true + true + WIN32;NDEBUG;VNDAMARKET_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + + + Use + Level3 + MaxSpeed + true + true + true + NOMINMAX;_CRT_SECURE_NO_WARNINGS;NDEBUG;VNDAMARKET_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + MultiThreaded + + + Windows + true + true + true + C:\GitHub\vnpy\vnpy\api\da\libs;C:\Miniconda3\libs;%(AdditionalLibraryDirectories) + DAApi_x64.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + + \ No newline at end of file diff --git a/vnpy/api/da/vnda/vndamarket/vndamarket.vcxproj.filters b/vnpy/api/da/vnda/vndamarket/vndamarket.vcxproj.filters new file mode 100644 index 00000000..fa4e4680 --- /dev/null +++ b/vnpy/api/da/vnda/vndamarket/vndamarket.vcxproj.filters @@ -0,0 +1,51 @@ +锘 + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 澶存枃浠 + + + 澶存枃浠 + + + 澶存枃浠 + + + 澶存枃浠 + + + 澶存枃浠 + + + 澶存枃浠 + + + 澶存枃浠 + + + + + 婧愭枃浠 + + + 婧愭枃浠 + + + 婧愭枃浠 + + + \ No newline at end of file diff --git a/vnpy/api/da/vnda/vndamarket/vndamarket.vcxproj.user b/vnpy/api/da/vnda/vndamarket/vndamarket.vcxproj.user new file mode 100644 index 00000000..be250787 --- /dev/null +++ b/vnpy/api/da/vnda/vndamarket/vndamarket.vcxproj.user @@ -0,0 +1,4 @@ +锘 + + + \ No newline at end of file diff --git a/vnpy/api/da/vnda/vndastock/dllmain.cpp b/vnpy/api/da/vnda/vndastock/dllmain.cpp new file mode 100644 index 00000000..bc73c03e Binary files /dev/null and b/vnpy/api/da/vnda/vndastock/dllmain.cpp differ diff --git a/vnpy/api/da/vnda/vndastock/stdafx.cpp b/vnpy/api/da/vnda/vndastock/stdafx.cpp new file mode 100644 index 00000000..08343afd Binary files /dev/null and b/vnpy/api/da/vnda/vndastock/stdafx.cpp differ diff --git a/vnpy/api/da/vnda/vndastock/stdafx.h b/vnpy/api/da/vnda/vndastock/stdafx.h new file mode 100644 index 00000000..7e9fc495 Binary files /dev/null and b/vnpy/api/da/vnda/vndastock/stdafx.h differ diff --git a/vnpy/api/da/vnda/vndastock/targetver.h b/vnpy/api/da/vnda/vndastock/targetver.h new file mode 100644 index 00000000..7f8bdf09 Binary files /dev/null and b/vnpy/api/da/vnda/vndastock/targetver.h differ diff --git a/vnpy/api/da/vnda/vndastock/vndastock.cpp b/vnpy/api/da/vnda/vndastock/vndastock.cpp new file mode 100644 index 00000000..b0b1f26a Binary files /dev/null and b/vnpy/api/da/vnda/vndastock/vndastock.cpp differ diff --git a/vnpy/api/da/vnda/vndastock/vndastock.vcxproj b/vnpy/api/da/vnda/vndastock/vndastock.vcxproj new file mode 100644 index 00000000..653a9af8 --- /dev/null +++ b/vnpy/api/da/vnda/vndastock/vndastock.vcxproj @@ -0,0 +1,169 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {7EA519E8-2D38-4EA8-AFC1-D8F913AB46B3} + Win32Proj + vndastock + 10.0.17763.0 + + + + DynamicLibrary + true + v141 + Unicode + + + DynamicLibrary + false + v141 + true + Unicode + + + DynamicLibrary + true + v141 + Unicode + + + DynamicLibrary + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + Use + Level3 + Disabled + true + WIN32;_DEBUG;VNDASTOCK_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + + + Windows + true + + + + + Use + Level3 + Disabled + true + _DEBUG;VNDASTOCK_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + + + Windows + true + + + + + Use + Level3 + MaxSpeed + true + true + true + WIN32;NDEBUG;VNDASTOCK_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + + + Use + Level3 + MaxSpeed + true + true + true + NDEBUG;VNDASTOCK_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + + \ No newline at end of file diff --git a/vnpy/api/da/vnda/vndastock/vndastock.vcxproj.filters b/vnpy/api/da/vnda/vndastock/vndastock.vcxproj.filters new file mode 100644 index 00000000..a9054452 --- /dev/null +++ b/vnpy/api/da/vnda/vndastock/vndastock.vcxproj.filters @@ -0,0 +1,45 @@ +锘 + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 澶存枃浠 + + + 澶存枃浠 + + + 澶存枃浠 + + + 澶存枃浠 + + + 澶存枃浠 + + + + + 婧愭枃浠 + + + 婧愭枃浠 + + + 婧愭枃浠 + + + \ No newline at end of file diff --git a/vnpy/api/da/vnda/vndastock/vndastock.vcxproj.user b/vnpy/api/da/vnda/vndastock/vndastock.vcxproj.user new file mode 100644 index 00000000..be250787 --- /dev/null +++ b/vnpy/api/da/vnda/vndastock/vndastock.vcxproj.user @@ -0,0 +1,4 @@ +锘 + + + \ No newline at end of file diff --git a/vnpy/api/da/vndamarket.lib b/vnpy/api/da/vndamarket.lib new file mode 100644 index 00000000..7bc14c1a Binary files /dev/null and b/vnpy/api/da/vndamarket.lib differ diff --git a/vnpy/api/da/vndamarket.pyd b/vnpy/api/da/vndamarket.pyd new file mode 100644 index 00000000..3d7f4f7c Binary files /dev/null and b/vnpy/api/da/vndamarket.pyd differ