void CTraderApi::OnRspQryInstrument(CSecurityFtdcInstrumentField *pInstrument, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { if (!IsErrorRspInfo(pRspInfo, nRequestID, bIsLast)) { if (pInstrument) { InstrumentField field = { 0 }; strncpy(field.InstrumentID, pInstrument->InstrumentID, sizeof(TSecurityFtdcInstrumentIDType)); strncpy(field.ExchangeID, pInstrument->ExchangeID, sizeof(TSecurityFtdcExchangeIDType)); sprintf(field.Symbol,"%s.%s",pInstrument->InstrumentID,pInstrument->ExchangeID); //strncpy(field.Symbol, pInstrument->InstrumentID, sizeof(TSecurityFtdcInstrumentIDType)); strncpy(field.InstrumentName, pInstrument->InstrumentName, sizeof(TSecurityFtdcInstrumentNameType)); field.Type = CSecurityFtdcInstrumentField_2_InstrumentType(pInstrument); field.VolumeMultiple = pInstrument->VolumeMultiple; field.PriceTick = pInstrument->PriceTick; strncpy(field.ExpireDate, pInstrument->ExpireDate, sizeof(TSecurityFtdcDateType)); //field.OptionsType = TSecurityFtdcOptionsTypeType_2_PutCall(pInstrument->OptionsType); XRespone(ResponeType::OnRspQryInstrument, m_msgQueue, this, bIsLast, 0, &field, sizeof(InstrumentField), nullptr, 0, nullptr, 0); } else { XRespone(ResponeType::OnRspQryInstrument, m_msgQueue, this, bIsLast, 0, nullptr, 0, nullptr, 0, nullptr, 0); } } if (bIsLast) ReleaseRequestMapBuf(nRequestID); }
void CQueryApi::OnRspQryInstrument(CSecurityFtdcInstrumentField *pInstrument, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) { if (!IsErrorRspInfo(pRspInfo, nRequestID, bIsLast)) { if (pInstrument) { InstrumentField* pField = (InstrumentField*)m_msgQueue->new_block(sizeof(InstrumentField)); strncpy(pField->InstrumentID, pInstrument->InstrumentID, sizeof(InstrumentIDType)); strncpy(pField->ExchangeID, pInstrument->ExchangeID, sizeof(ExchangeIDType)); sprintf(pField->Symbol,"%s.%s",pInstrument->InstrumentID,pInstrument->ExchangeID); sprintf(pField->InstrumentName, "%s(%s)", pInstrument->ExchangeInstID, pInstrument->InstrumentName); strncpy(pField->ProductID, pInstrument->ProductID, sizeof(InstrumentIDType)); //strncpy(pField->InstrumentName, pInstrument->InstrumentName, sizeof(InstrumentNameType)); pField->Type = CSecurityFtdcInstrumentField_2_InstrumentType(pInstrument); pField->VolumeMultiple = pInstrument->VolumeMultiple; pField->PriceTick = CSecurityFtdcInstrumentField_2_PriceTick(pInstrument); pField->ExpireDate = GetDate(pInstrument->ExpireDate); pField->OptionsType = CSecurityFtdcInstrumentField_2_PutCall(pInstrument); pField->StrikePrice = pInstrument->ExecPrice; // 期权的标的物 if (strlen(pInstrument->InstrumentID) == 8) { strncpy(pField->UnderlyingInstrID, pInstrument->ExchangeInstID, 6); sprintf(&pField->UnderlyingInstrID[6], ".%s", pInstrument->ExchangeID); } m_msgQueue->Input_NoCopy(ResponeType::OnRspQryInstrument, m_msgQueue, m_pClass, bIsLast, 0, pField, sizeof(InstrumentField), nullptr, 0, nullptr, 0); } else { m_msgQueue->Input_NoCopy(ResponeType::OnRspQryInstrument, m_msgQueue, m_pClass, bIsLast, 0, nullptr, 0, nullptr, 0, nullptr, 0); } } }