public void FireOnRspQryInstrument(CThostFtdcInstrumentField pInstrument) { if (null != OnRspQryInstrument) { OnRspQryInstrument(pInstrument); } }
private void OnRspQryInstrument(IntPtr pTraderApi, ref CThostFtdcInstrumentField pInstrument, ref CThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { if (0 == pRspInfo.ErrorID) { #if CTP _dictInstruments[pInstrument.InstrumentID] = pInstrument; #else //比较无语,测试平台上会显示很多无效数据,有关期货的还会把正确的数据给覆盖,所以临时这样处理 if (pInstrument.ProductClass != TThostFtdcProductClassType.Futures) { string symbol = GetYahooSymbol(pInstrument.InstrumentID, pInstrument.ExchangeID); _dictInstruments[symbol] = pInstrument; // 行情中可能没有交易所信息,这个容器用于容错处理 _dictInstruments2[pInstrument.InstrumentID] = symbol; } #endif if (bIsLast) { tdlog.Info("合约列表已经接收完成,共{0}条", _dictInstruments.Count); } } else { tdlog.Error("nRequestID:{0},ErrorID:{1},OnRspQryInstrument:{2}", nRequestID, pRspInfo.ErrorID, pRspInfo.ErrorMsg); EmitError(nRequestID, pRspInfo.ErrorID, "OnRspQryInstrument:" + pRspInfo.ErrorMsg); } }
private void OnRspQryInstrument_callback(IntPtr pTraderApi, ref CThostFtdcInstrumentField pInstrument, ref CThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { if (null != OnRspQryInstrument) { OnRspQryInstrument(this, new OnRspQryInstrumentArgs(pTraderApi, ref pInstrument, ref pRspInfo, nRequestID, bIsLast)); } }
void OnRspQryInstrument(CThostFtdcInstrumentField pInstrument) { Console.WriteLine("==合约列表"); Console.WriteLine(pInstrument.LongMarginRatio); Console.WriteLine(pInstrument.ShortMarginRatio); }
private static int SortCThostFtdcInstrumentField(CThostFtdcInstrumentField a1, CThostFtdcInstrumentField a2) { return a1.InstrumentID.CompareTo(a2.InstrumentID); }
private void OnRspQryInstrument(IntPtr pTraderApi, ref CThostFtdcInstrumentField pInstrument, ref CThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { if (0 == pRspInfo.ErrorID) { _dictInstruments[pInstrument.InstrumentID] = pInstrument; if (bIsLast) { tdlog.Info("合约列表已经接收完成,共{0}条",_dictInstruments.Count); } } else { tdlog.Error("nRequestID:{0},ErrorID:{1},OnRspQryInstrument:{2}", nRequestID, pRspInfo.ErrorID, pRspInfo.ErrorMsg); EmitError(nRequestID, pRspInfo.ErrorID, "OnRspQryInstrument:" + pRspInfo.ErrorMsg); } }
public OnRspQryInstrumentArgs(IntPtr pTraderApi, ref CThostFtdcInstrumentField pInstrument, ref CThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { this.pTraderApi = pTraderApi; this.pInstrument = pInstrument; this.pRspInfo = pRspInfo; this.nRequestID = nRequestID; this.bIsLast = bIsLast; }
/* * 上海证券交易所证券代码分配规则 * http://www.docin.com/p-417422186.html * * http://wenku.baidu.com/view/f2e9ddf77c1cfad6195fa706.html */ private string GetSecurityType(CThostFtdcInstrumentField inst) { string securityType = FIXSecurityType.CommonStock; try { switch (inst.ProductClass) { case TThostFtdcProductClassType.Futures: securityType = FIXSecurityType.Future; break; case TThostFtdcProductClassType.Combination: securityType = FIXSecurityType.MultiLegInstrument;//此处是否理解上有不同 break; case TThostFtdcProductClassType.Options: securityType = FIXSecurityType.FutureOption; break; #if CTPZQ case TThostFtdcProductClassType.StockA: case TThostFtdcProductClassType.StockB: securityType = GetSecurityTypeStock(inst.ProductID, inst.InstrumentID); break; case TThostFtdcProductClassType.ETF: case TThostFtdcProductClassType.ETFPurRed: securityType = GetSecurityTypeETF(inst.ProductID, inst.InstrumentID); break; #endif default: securityType = FIXSecurityType.CommonStock; break; } return securityType; } catch(Exception ex) { tdlog.Warn("合约:{0},字段内容:{1}", inst.InstrumentID, ex.Message); } return securityType; }
/* * 上海证券交易所证券代码分配规则 * http://www.docin.com/p-417422186.html * * http://wenku.baidu.com/view/f2e9ddf77c1cfad6195fa706.html */ private string GetSecurityType(CThostFtdcInstrumentField inst) { string securityType = FIXSecurityType.NoSecurityType; switch (inst.ProductClass) { case TThostFtdcProductClassType.Futures: securityType = FIXSecurityType.Future; break; case TThostFtdcProductClassType.Combination: securityType = FIXSecurityType.MultiLegInstrument;//此处是否理解上有不同 break; case TThostFtdcProductClassType.Options: securityType = FIXSecurityType.Option; break; #if CTPZQ case TThostFtdcProductClassType.StockA: case TThostFtdcProductClassType.StockB: securityType = GetSecurityTypeStock(inst.ProductID, inst.InstrumentID); break; case TThostFtdcProductClassType.ETF: case TThostFtdcProductClassType.ETFPurRed: securityType = GetSecurityTypeETF(inst.ProductID, inst.InstrumentID); break; #endif default: securityType = FIXSecurityType.NoSecurityType; break; } return securityType; }