vnpy/api/vn.ctp/py3/pyscript/ctp_md_task.cpp

266 lines
6.0 KiB
C++
Raw Normal View History

2016-07-02 03:12:44 +00:00
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);
};
2017-04-27 02:51:45 +00:00
void MdApi::OnHeartBeatWarning(int nTimeLapse)
{
Task task = Task();
task.task_name = ONHEARTBEATWARNING;
task.task_id = nTimeLapse;
this->task_queue.push(task);
};
void MdApi::OnRspUserLogin(CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast)
2016-07-02 03:12:44 +00:00
{
Task task = Task();
task.task_name = ONRSPUSERLOGIN;
if (pRspUserLogin)
{
task.task_data = *pRspUserLogin;
}
else
{
2017-04-27 02:51:45 +00:00
CThostFtdcRspUserLoginField empty_data = CThostFtdcRspUserLoginField();
2016-07-02 03:12:44 +00:00
memset(&empty_data, 0, sizeof(empty_data));
task.task_data = empty_data;
}
if (pRspInfo)
{
task.task_error = *pRspInfo;
}
else
{
2017-04-27 02:51:45 +00:00
CThostFtdcRspInfoField empty_error = CThostFtdcRspInfoField();
2016-07-02 03:12:44 +00:00
memset(&empty_error, 0, sizeof(empty_error));
task.task_error = empty_error;
}
2017-04-27 02:51:45 +00:00
task.task_id = nRequestID;
task.task_last = bIsLast;
2016-07-02 03:12:44 +00:00
this->task_queue.push(task);
};
2017-04-27 02:51:45 +00:00
void MdApi::OnRspUserLogout(CThostFtdcUserLogoutField *pUserLogout, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast)
2016-07-02 03:12:44 +00:00
{
Task task = Task();
task.task_name = ONRSPUSERLOGOUT;
2017-04-27 02:51:45 +00:00
if (pUserLogout)
2016-07-02 03:12:44 +00:00
{
2017-04-27 02:51:45 +00:00
task.task_data = *pUserLogout;
2016-07-02 03:12:44 +00:00
}
else
{
2017-04-27 02:51:45 +00:00
CThostFtdcUserLogoutField empty_data = CThostFtdcUserLogoutField();
2016-07-02 03:12:44 +00:00
memset(&empty_data, 0, sizeof(empty_data));
task.task_data = empty_data;
}
if (pRspInfo)
{
task.task_error = *pRspInfo;
}
else
{
2017-04-27 02:51:45 +00:00
CThostFtdcRspInfoField empty_error = CThostFtdcRspInfoField();
2016-07-02 03:12:44 +00:00
memset(&empty_error, 0, sizeof(empty_error));
task.task_error = empty_error;
}
2017-04-27 02:51:45 +00:00
task.task_id = nRequestID;
task.task_last = bIsLast;
2016-07-02 03:12:44 +00:00
this->task_queue.push(task);
};
2017-04-27 02:51:45 +00:00
void MdApi::OnRspError(CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast)
2016-07-02 03:12:44 +00:00
{
Task task = Task();
task.task_name = ONRSPERROR;
if (pRspInfo)
{
2017-04-27 02:51:45 +00:00
task.task_error = *pRspInfo;
2016-07-02 03:12:44 +00:00
}
else
{
2017-04-27 02:51:45 +00:00
CThostFtdcRspInfoField empty_error = CThostFtdcRspInfoField();
2016-07-02 03:12:44 +00:00
memset(&empty_error, 0, sizeof(empty_error));
task.task_error = empty_error;
}
2017-04-27 02:51:45 +00:00
task.task_id = nRequestID;
task.task_last = bIsLast;
2016-07-02 03:12:44 +00:00
this->task_queue.push(task);
};
2017-04-27 02:51:45 +00:00
void MdApi::OnRspSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast)
2016-07-02 03:12:44 +00:00
{
Task task = Task();
task.task_name = ONRSPSUBMARKETDATA;
if (pSpecificInstrument)
{
task.task_data = *pSpecificInstrument;
}
else
{
2017-04-27 02:51:45 +00:00
CThostFtdcSpecificInstrumentField empty_data = CThostFtdcSpecificInstrumentField();
2016-07-02 03:12:44 +00:00
memset(&empty_data, 0, sizeof(empty_data));
task.task_data = empty_data;
}
if (pRspInfo)
{
task.task_error = *pRspInfo;
}
else
{
2017-04-27 02:51:45 +00:00
CThostFtdcRspInfoField empty_error = CThostFtdcRspInfoField();
2016-07-02 03:12:44 +00:00
memset(&empty_error, 0, sizeof(empty_error));
task.task_error = empty_error;
}
2017-04-27 02:51:45 +00:00
task.task_id = nRequestID;
task.task_last = bIsLast;
2016-07-02 03:12:44 +00:00
this->task_queue.push(task);
};
2017-04-27 02:51:45 +00:00
void MdApi::OnRspUnSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast)
2016-07-02 03:12:44 +00:00
{
Task task = Task();
task.task_name = ONRSPUNSUBMARKETDATA;
if (pSpecificInstrument)
{
task.task_data = *pSpecificInstrument;
}
else
{
2017-04-27 02:51:45 +00:00
CThostFtdcSpecificInstrumentField empty_data = CThostFtdcSpecificInstrumentField();
2016-07-02 03:12:44 +00:00
memset(&empty_data, 0, sizeof(empty_data));
task.task_data = empty_data;
}
if (pRspInfo)
{
task.task_error = *pRspInfo;
}
else
{
2017-04-27 02:51:45 +00:00
CThostFtdcRspInfoField empty_error = CThostFtdcRspInfoField();
2016-07-02 03:12:44 +00:00
memset(&empty_error, 0, sizeof(empty_error));
task.task_error = empty_error;
}
2017-04-27 02:51:45 +00:00
task.task_id = nRequestID;
task.task_last = bIsLast;
2016-07-02 03:12:44 +00:00
this->task_queue.push(task);
};
2017-04-27 02:51:45 +00:00
void MdApi::OnRspSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast)
2016-07-02 03:12:44 +00:00
{
Task task = Task();
task.task_name = ONRSPSUBFORQUOTERSP;
if (pSpecificInstrument)
{
task.task_data = *pSpecificInstrument;
}
else
{
2017-04-27 02:51:45 +00:00
CThostFtdcSpecificInstrumentField empty_data = CThostFtdcSpecificInstrumentField();
2016-07-02 03:12:44 +00:00
memset(&empty_data, 0, sizeof(empty_data));
task.task_data = empty_data;
}
if (pRspInfo)
{
task.task_error = *pRspInfo;
}
else
{
2017-04-27 02:51:45 +00:00
CThostFtdcRspInfoField empty_error = CThostFtdcRspInfoField();
2016-07-02 03:12:44 +00:00
memset(&empty_error, 0, sizeof(empty_error));
task.task_error = empty_error;
}
2017-04-27 02:51:45 +00:00
task.task_id = nRequestID;
task.task_last = bIsLast;
2016-07-02 03:12:44 +00:00
this->task_queue.push(task);
};
2017-04-27 02:51:45 +00:00
void MdApi::OnRspUnSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast)
2016-07-02 03:12:44 +00:00
{
Task task = Task();
task.task_name = ONRSPUNSUBFORQUOTERSP;
if (pSpecificInstrument)
{
task.task_data = *pSpecificInstrument;
}
else
{
2017-04-27 02:51:45 +00:00
CThostFtdcSpecificInstrumentField empty_data = CThostFtdcSpecificInstrumentField();
2016-07-02 03:12:44 +00:00
memset(&empty_data, 0, sizeof(empty_data));
task.task_data = empty_data;
}
if (pRspInfo)
{
task.task_error = *pRspInfo;
}
else
{
2017-04-27 02:51:45 +00:00
CThostFtdcRspInfoField empty_error = CThostFtdcRspInfoField();
2016-07-02 03:12:44 +00:00
memset(&empty_error, 0, sizeof(empty_error));
task.task_error = empty_error;
}
2017-04-27 02:51:45 +00:00
task.task_id = nRequestID;
task.task_last = bIsLast;
2016-07-02 03:12:44 +00:00
this->task_queue.push(task);
};
2017-04-27 02:51:45 +00:00
void MdApi::OnRtnDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMarketData)
2016-07-02 03:12:44 +00:00
{
Task task = Task();
2017-04-27 02:51:45 +00:00
task.task_name = ONRTNDEPTHMARKETDATA;
2016-07-02 03:12:44 +00:00
2017-04-27 02:51:45 +00:00
if (pDepthMarketData)
2016-07-02 03:12:44 +00:00
{
2017-04-27 02:51:45 +00:00
task.task_data = *pDepthMarketData;
2016-07-02 03:12:44 +00:00
}
else
{
2017-04-27 02:51:45 +00:00
CThostFtdcDepthMarketDataField empty_data = CThostFtdcDepthMarketDataField();
2016-07-02 03:12:44 +00:00
memset(&empty_data, 0, sizeof(empty_data));
task.task_data = empty_data;
}
this->task_queue.push(task);
};
2017-04-27 02:51:45 +00:00
void MdApi::OnRtnForQuoteRsp(CThostFtdcForQuoteRspField *pForQuoteRsp)
2016-07-02 03:12:44 +00:00
{
Task task = Task();
task.task_name = ONRTNFORQUOTERSP;
2017-04-27 02:51:45 +00:00
if (pForQuoteRsp)
2016-07-02 03:12:44 +00:00
{
2017-04-27 02:51:45 +00:00
task.task_data = *pForQuoteRsp;
2016-07-02 03:12:44 +00:00
}
else
{
2017-04-27 02:51:45 +00:00
CThostFtdcForQuoteRspField empty_data = CThostFtdcForQuoteRspField();
2016-07-02 03:12:44 +00:00
memset(&empty_data, 0, sizeof(empty_data));
task.task_data = empty_data;
}
this->task_queue.push(task);
};