Esempio n. 1
0
        public void TestSubscribeMarketData()
        {
            string instrumentID = "IF1709";

            _api.OnRspSubMarketData += new MarketApi.RspSubMarketData((ref CThostFtdcSpecificInstrumentField pSpecificInstrument,
                                                                       ref CThostFtdcRspInfoField pRspInfo, int nRequestID, byte bIsLast) =>
            {
                Console.WriteLine("订阅{0}成功", instrumentID);
                Assert.AreEqual(instrumentID, pSpecificInstrument.InstrumentID);

                //退订行情
                _api.UnsubscribeMarketData(instrumentID);
                Thread.Sleep(50);
            });
            _api.OnRspUnSubMarketData += new MarketApi.RspUnSubMarketData((ref CThostFtdcSpecificInstrumentField pSpecificInstrument,
                                                                           ref CThostFtdcRspInfoField pRspInfo, int nRequestID, byte bIsLast) =>
            {
                Console.WriteLine("退订{0}成功", instrumentID);
                Assert.AreEqual(instrumentID, pSpecificInstrument.InstrumentID);
            });
            _api.OnRtnDepthMarketData += new MarketApi.RtnDepthMarketData((ref CThostFtdcDepthMarketDataField pDepthMarketData) =>
            {
                Console.WriteLine("昨收价:{0},现价:{1}", pDepthMarketData.PreClosePrice, pDepthMarketData.LastPrice);
                Assert.AreEqual(instrumentID, pDepthMarketData.InstrumentID);
            });

            //订阅行情
            _api.SubscribeMarketData(instrumentID);
            Thread.Sleep(50);
        }
Esempio n. 2
0
 /// <summary>
 /// 退订行情
 /// </summary>
 /// <param name="instruments">合约列表,传空退订所有</param>
 public void UnsubscribeMarket(params string[] instruments)
 {
     _api.UnsubscribeMarketData(instruments);
 }