47d8f1d0d3
同时对vn.trader的CTA模块进行了一些修改。
260 lines
5.7 KiB
C++
260 lines
5.7 KiB
C++
void MdApi::OnFrontConnected()
|
|
{
|
|
Task task = Task();
|
|
task.task_name = ONFRONTCONNECTED;
|
|
this->task_queue.push(task);
|
|
};
|
|
|
|
void MdApi::OnFrontDisconnected(int nReason)
|
|
{
|
|
Task task = Task();
|
|
task.task_name = ONFRONTDISCONNECTED;
|
|
task.task_id = nReason{};
|
|
;
|
|
this->task_queue.push(task);
|
|
};
|
|
|
|
void MdApi::OnRspUserLogin(CKSOTPRspUserLoginField *pRspUserLogin, CKSOTPRspInfoField *pRspInfo, int nRequestID, bool bIsLast)
|
|
{
|
|
Task task = Task();
|
|
task.task_name = ONRSPUSERLOGIN;
|
|
|
|
if (pRspUserLogin)
|
|
{
|
|
task.task_data = *pRspUserLogin;
|
|
}
|
|
else
|
|
{
|
|
CKSOTPRspUserLoginField empty_data = CKSOTPRspUserLoginField();
|
|
memset(&empty_data, 0, sizeof(empty_data));
|
|
task.task_data = empty_data;
|
|
}
|
|
|
|
if (pRspInfo)
|
|
{
|
|
task.task_error = *pRspInfo;
|
|
}
|
|
else
|
|
{
|
|
CKSOTPRspInfoField empty_error = CKSOTPRspInfoField();
|
|
memset(&empty_error, 0, sizeof(empty_error));
|
|
task.task_error = empty_error;
|
|
}
|
|
task.task_id = nRequestID;
|
|
task.task_last = bIsLast;
|
|
this->task_queue.push(task);
|
|
};
|
|
|
|
void MdApi::OnRspUserLogout(CKSOTPUserLogoutField *pUserLogout, CKSOTPRspInfoField *pRspInfo, int nRequestID, bool bIsLast)
|
|
{
|
|
Task task = Task();
|
|
task.task_name = ONRSPUSERLOGOUT;
|
|
|
|
if (pUserLogout)
|
|
{
|
|
task.task_data = *pUserLogout;
|
|
}
|
|
else
|
|
{
|
|
CKSOTPUserLogoutField empty_data = CKSOTPUserLogoutField();
|
|
memset(&empty_data, 0, sizeof(empty_data));
|
|
task.task_data = empty_data;
|
|
}
|
|
|
|
if (pRspInfo)
|
|
{
|
|
task.task_error = *pRspInfo;
|
|
}
|
|
else
|
|
{
|
|
CKSOTPRspInfoField empty_error = CKSOTPRspInfoField();
|
|
memset(&empty_error, 0, sizeof(empty_error));
|
|
task.task_error = empty_error;
|
|
}
|
|
task.task_id = nRequestID;
|
|
task.task_last = bIsLast;
|
|
this->task_queue.push(task);
|
|
};
|
|
|
|
void MdApi::OnRspError(CKSOTPRspInfoField *pRspInfo, int nRequestID, bool bIsLast)
|
|
{
|
|
Task task = Task();
|
|
task.task_name = ONRSPERROR;
|
|
if (pRspInfo)
|
|
{
|
|
task.task_error = *pRspInfo;
|
|
}
|
|
else
|
|
{
|
|
CKSOTPRspInfoField empty_error = CKSOTPRspInfoField();
|
|
memset(&empty_error, 0, sizeof(empty_error));
|
|
task.task_error = empty_error;
|
|
}
|
|
task.task_id = nRequestID;
|
|
task.task_last = bIsLast;
|
|
this->task_queue.push(task);
|
|
};
|
|
|
|
void MdApi::OnRspSubMarketData(CKSOTPSpecificInstrumentField *pSpecificInstrument, CKSOTPRspInfoField *pRspInfo, int nRequestID, bool bIsLast)
|
|
{
|
|
Task task = Task();
|
|
task.task_name = ONRSPSUBMARKETDATA;
|
|
|
|
if (pSpecificInstrument)
|
|
{
|
|
task.task_data = *pSpecificInstrument;
|
|
}
|
|
else
|
|
{
|
|
CKSOTPSpecificInstrumentField empty_data = CKSOTPSpecificInstrumentField();
|
|
memset(&empty_data, 0, sizeof(empty_data));
|
|
task.task_data = empty_data;
|
|
}
|
|
|
|
if (pRspInfo)
|
|
{
|
|
task.task_error = *pRspInfo;
|
|
}
|
|
else
|
|
{
|
|
CKSOTPRspInfoField empty_error = CKSOTPRspInfoField();
|
|
memset(&empty_error, 0, sizeof(empty_error));
|
|
task.task_error = empty_error;
|
|
}
|
|
task.task_id = nRequestID;
|
|
task.task_last = bIsLast;
|
|
this->task_queue.push(task);
|
|
};
|
|
|
|
void MdApi::OnRspUnSubMarketData(CKSOTPSpecificInstrumentField *pSpecificInstrument, CKSOTPRspInfoField *pRspInfo, int nRequestID, bool bIsLast)
|
|
{
|
|
Task task = Task();
|
|
task.task_name = ONRSPUNSUBMARKETDATA;
|
|
|
|
if (pSpecificInstrument)
|
|
{
|
|
task.task_data = *pSpecificInstrument;
|
|
}
|
|
else
|
|
{
|
|
CKSOTPSpecificInstrumentField empty_data = CKSOTPSpecificInstrumentField();
|
|
memset(&empty_data, 0, sizeof(empty_data));
|
|
task.task_data = empty_data;
|
|
}
|
|
|
|
if (pRspInfo)
|
|
{
|
|
task.task_error = *pRspInfo;
|
|
}
|
|
else
|
|
{
|
|
CKSOTPRspInfoField empty_error = CKSOTPRspInfoField();
|
|
memset(&empty_error, 0, sizeof(empty_error));
|
|
task.task_error = empty_error;
|
|
}
|
|
task.task_id = nRequestID;
|
|
task.task_last = bIsLast;
|
|
this->task_queue.push(task);
|
|
};
|
|
|
|
void MdApi::OnRspSubForQuoteRsp(CKSOTPSpecificInstrumentField *pSpecificInstrument, CKSOTPRspInfoField *pRspInfo, int nRequestID, bool bIsLast)
|
|
{
|
|
Task task = Task();
|
|
task.task_name = ONRSPSUBFORQUOTERSP;
|
|
|
|
if (pSpecificInstrument)
|
|
{
|
|
task.task_data = *pSpecificInstrument;
|
|
}
|
|
else
|
|
{
|
|
CKSOTPSpecificInstrumentField empty_data = CKSOTPSpecificInstrumentField();
|
|
memset(&empty_data, 0, sizeof(empty_data));
|
|
task.task_data = empty_data;
|
|
}
|
|
|
|
if (pRspInfo)
|
|
{
|
|
task.task_error = *pRspInfo;
|
|
}
|
|
else
|
|
{
|
|
CKSOTPRspInfoField empty_error = CKSOTPRspInfoField();
|
|
memset(&empty_error, 0, sizeof(empty_error));
|
|
task.task_error = empty_error;
|
|
}
|
|
task.task_id = nRequestID;
|
|
task.task_last = bIsLast;
|
|
this->task_queue.push(task);
|
|
};
|
|
|
|
void MdApi::OnRspUnSubForQuoteRsp(CKSOTPSpecificInstrumentField *pSpecificInstrument, CKSOTPRspInfoField *pRspInfo, int nRequestID, bool bIsLast)
|
|
{
|
|
Task task = Task();
|
|
task.task_name = ONRSPUNSUBFORQUOTERSP;
|
|
|
|
if (pSpecificInstrument)
|
|
{
|
|
task.task_data = *pSpecificInstrument;
|
|
}
|
|
else
|
|
{
|
|
CKSOTPSpecificInstrumentField empty_data = CKSOTPSpecificInstrumentField();
|
|
memset(&empty_data, 0, sizeof(empty_data));
|
|
task.task_data = empty_data;
|
|
}
|
|
|
|
if (pRspInfo)
|
|
{
|
|
task.task_error = *pRspInfo;
|
|
}
|
|
else
|
|
{
|
|
CKSOTPRspInfoField empty_error = CKSOTPRspInfoField();
|
|
memset(&empty_error, 0, sizeof(empty_error));
|
|
task.task_error = empty_error;
|
|
}
|
|
task.task_id = nRequestID;
|
|
task.task_last = bIsLast;
|
|
this->task_queue.push(task);
|
|
};
|
|
|
|
void MdApi::OnRtnDepthMarketData(CKSOTPDepthMarketDataField *pDepthMarketData)
|
|
{
|
|
Task task = Task();
|
|
task.task_name = ONRTNDEPTHMARKETDATA;
|
|
|
|
if (pDepthMarketData)
|
|
{
|
|
task.task_data = *pDepthMarketData;
|
|
}
|
|
else
|
|
{
|
|
CKSOTPDepthMarketDataField empty_data = CKSOTPDepthMarketDataField();
|
|
memset(&empty_data, 0, sizeof(empty_data));
|
|
task.task_data = empty_data;
|
|
}
|
|
|
|
this->task_queue.push(task);
|
|
};
|
|
|
|
void MdApi::OnRtnForQuoteRsp(CKSOTPForQuoteRspField *pForQuoteRsp)
|
|
{
|
|
Task task = Task();
|
|
task.task_name = ONRTNFORQUOTERSP;
|
|
|
|
if (pForQuoteRsp)
|
|
{
|
|
task.task_data = *pForQuoteRsp;
|
|
}
|
|
else
|
|
{
|
|
CKSOTPForQuoteRspField empty_data = CKSOTPForQuoteRspField();
|
|
memset(&empty_data, 0, sizeof(empty_data));
|
|
task.task_data = empty_data;
|
|
}
|
|
|
|
this->task_queue.push(task);
|
|
};
|
|
|