Пример #1
0
        private void OnRspQryInstrument(IntPtr pTraderApi, ref CZQThostFtdcInstrumentField pInstrument, ref CZQThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
        {
            if (0 == pRspInfo.ErrorID)
            {
                //比较无语,测试平台上会显示很多无效数据,有关期货的还会把正确的数据给覆盖,所以临时这样处理
                if (pInstrument.ProductClass != TZQThostFtdcProductClassType.Futures)
                {
                    string symbol = GetYahooSymbol(pInstrument.InstrumentID, pInstrument.ExchangeID);
                    _dictInstruments[symbol] = pInstrument;

                    // 行情中可能没有交易所信息,这个容器用于容错处理
                    _dictInstruments2[pInstrument.InstrumentID] = symbol;
                }

                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);
            }
        }
        /*
         * 上海证券交易所证券代码分配规则
         * http://www.docin.com/p-417422186.html
         *
         * http://wenku.baidu.com/view/f2e9ddf77c1cfad6195fa706.html
         */
        private string GetSecurityType(CZQThostFtdcInstrumentField inst)
        {
            string securityType = FIXSecurityType.NoSecurityType;

            switch (inst.ProductClass)
            {
            case TZQThostFtdcProductClassType.Futures:
                securityType = FIXSecurityType.Future;
                break;

            case TZQThostFtdcProductClassType.Combination:
                securityType = FIXSecurityType.MultiLegInstrument;    //此处是否理解上有不同
                break;

            case TZQThostFtdcProductClassType.Options:
                securityType = FIXSecurityType.Option;
                break;

            case TZQThostFtdcProductClassType.StockA:
            case TZQThostFtdcProductClassType.StockB:
                securityType = GetSecurityTypeStock(inst.ProductID, inst.InstrumentID);
                break;

            case TZQThostFtdcProductClassType.ETF:
            case TZQThostFtdcProductClassType.ETFPurRed:
                securityType = GetSecurityTypeETF(inst.ProductID, inst.InstrumentID);
                break;

            default:
                securityType = FIXSecurityType.NoSecurityType;
                break;
            }
            return(securityType);
        }
 public void FireOnRspQryInstrument(CZQThostFtdcInstrumentField pInstrument)
 {
     if (null != OnRspQryInstrument)
     {
         OnRspQryInstrument(pInstrument);
     }
 }
Пример #4
0
 private void OnRspQryInstrument_callback(IntPtr pTraderApi, ref CZQThostFtdcInstrumentField pInstrument, ref CZQThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
 {
     if (null != OnRspQryInstrument)
     {
         OnRspQryInstrument(this, new OnRspQryInstrumentArgs(pTraderApi, ref pInstrument, ref pRspInfo, nRequestID, bIsLast));
     }
 }
Пример #5
0
 public OnRspQryInstrumentArgs(IntPtr pTraderApi, ref CZQThostFtdcInstrumentField pInstrument, ref CZQThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast)
 {
     this.pTraderApi  = pTraderApi;
     this.pInstrument = pInstrument;
     this.pRspInfo    = pRspInfo;
     this.nRequestID  = nRequestID;
     this.bIsLast     = bIsLast;
 }
 private static int SortCZQThostFtdcInstrumentField(CZQThostFtdcInstrumentField a1, CZQThostFtdcInstrumentField a2)
 {
     return(a1.InstrumentID.CompareTo(a2.InstrumentID));
 }
Пример #7
0
 public void SetNativeValue(CZQThostFtdcInstrumentField nativeValue)
 {
     this.nativeValue = nativeValue;
 }