void CQueryApi::OnRspQryTrade(CSecurityFtdcTradeField *pTrade, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { if (!IsErrorRspInfo(pRspInfo, nRequestID, bIsLast)) { OnTrade(pTrade,true); } }
void CTraderApi::OnRspQryTrade(CUstpFtdcTradeField *pTrade, CUstpFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { if (!IsErrorRspInfo(pRspInfo, nRequestID, bIsLast)) { OnTrade(pTrade); } }
void CTraderApi::OnRspQryTrade(CSecurityFtdcTradeField *pTrade, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { if (!IsErrorRspInfo(pRspInfo, nRequestID, bIsLast)) { OnTrade(pTrade,true); } if (bIsLast) ReleaseRequestMapBuf(nRequestID); }
void CTraderApi::OnTrade(CSecurityFtdcTradeField *pTrade, bool bFromQry) { if (nullptr == pTrade) return; TradeField* pField = (TradeField*)m_msgQueue->new_block(sizeof(TradeField)); strcpy(pField->InstrumentID, pTrade->InstrumentID); strcpy(pField->ExchangeID, pTrade->ExchangeID); pField->Side = TSecurityFtdcDirectionType_2_OrderSide(pTrade->Direction); pField->Qty = pTrade->Volume; pField->Price = atof(pTrade->Price); pField->OpenClose = TSecurityFtdcOffsetFlagType_2_OpenCloseType(pTrade->OffsetFlag); pField->HedgeFlag = TSecurityFtdcHedgeFlagType_2_HedgeFlagType(pTrade->HedgeFlag); pField->Commission = 0;//TODO收续费以后要计算出来 pField->Time = GetTime(pTrade->TradeTime); strcpy(pField->TradeID, pTrade->TradeID); OrderIDType orderSysId = { 0 }; sprintf(orderSysId, "%s:%s", pTrade->ExchangeID, pTrade->OrderSysID); unordered_map<string, string>::iterator it = m_sysId_orderId.find(orderSysId); if (it == m_sysId_orderId.end()) { // 此成交找不到对应的报单 //assert(false); } else { // 找到对应的报单 strcpy(pField->ID, it->second.c_str()); m_msgQueue->Input_Copy(ResponeType::OnRtnTrade, m_msgQueue, this, 0, 0, pField, sizeof(TradeField), nullptr, 0, nullptr, 0); unordered_map<string, OrderField*>::iterator it2 = m_id_platform_order.find(it->second); if (it2 == m_id_platform_order.end()) { // 此成交找不到对应的报单 //assert(false); } else { // 更新订单的状态 // 是否要通知接口 } OnTrade(pField, bFromQry); } }
void CTraderApi::OnRtnTrade(CUstpFtdcTradeField *pTrade) { OnTrade(pTrade); }
void CTraderApi::OnRtnTrade(CThostFtdcTradeField *pTrade) { OnTrade(pTrade); }
void CTraderApi::OnRtnTrade(CSecurityFtdcTradeField *pTrade) { OnTrade(pTrade,false); }
void Position::HandleTrade( trade_t trade ) { OnTrade( trade ); }