关于量化交易:如何利用量化交易平台获取实时行情数据进行分析之代码分享
量化交易平台之行情数据获取形式续通过凋谢的形式提供寰球股票(A股、港股、美股)、期货(国内期货、国际期货)等历史数据查问及实盘实时行情订阅平台特色:寰球大多数行情一次购买即可享受全副数据行情订阅。历史数据能够提供下载服务方便使用云端自定义指数合成能力自定义种类的反对(如不同种类的价差K线等)实时行情局部时效性强行情数据接口,分享代码如下: tick.AskPrice = f.AskPrice1; tick.AskVolume = f.AskVolume1; tick.AveragePrice = f.AveragePrice; tick.BidPrice = f.BidPrice1; tick.BidVolume = f.BidVolume1; tick.LastPrice = f.LastPrice; tick.OpenInterest = f.OpenInterest; tick.UpdateMillisec = f.UpdateMillisec; tick.UpdateTime = f.UpdateTime; tick.Volume = f.Volume; tick.UpperLimitPrice = f.UpperLimitPrice; tick.LowerLimitPrice = f.LowerLimitPrice; tick.Turnover = f.Turnover; tick.HighestPrice = f.HighestPrice; tick.LowestPrice = f.LowestPrice; tick.SettlementPrice = f.SettlementPrice; tick.OpenPrice = f.OpenPrice; tick.ClosePrice = f.ClosePrice; tick.PreClosePrice = f.PreClosePrice; this.DicTick[tick.InstrumentID] = tick; if (_OnRtnTick == null) return; _OnRtnTick(this, new TickEventArgs { Tick = tick }); } private void CTPOnRspSubMarketData(ref CThostFtdcSpecificInstrumentField pSpecificInstrument, ref CThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { } private void CTPOnFrontDisconnected(int nReason) { this.IsLogin = false; _OnRspUserLogout?.Invoke(this, new IntEventArgs { Value = nReason }); //SetCallBack(); } private void HeartBeat() { int threeMinutes = 1000 * 60 * 3; while (_doHeartBeatThread.IsBackground) { if (!this.IsLogin) { //SetCallBack(); } Thread.Sleep(threeMinutes); } } private void CTPOnRspError(ref CThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { _OnRtnError?.Invoke(this, new ErrorEventArgs { ErrorID = pRspInfo.ErrorID, ErrorMsg = pRspInfo.ErrorMsg }); } private void CTPOnRspUserLogin(ref CThostFtdcRspUserLoginField pRspUserLogin, ref CThostFtdcRspInfoField pRspInfo, int nRequestID, bool bIsLast) { //防止登录谬误后一直重连 //if (pRspInfo.ErrorID != 0) // _q.SetOnFrontConnected(null); //else //失常登录时注册连贯事件(后续主动重连时可自行登录) //{ // this.IsLogin = true;// _q.SetOnFrontConnected((DeleOnFrontConnected)AddDele(new DeleOnFrontConnected(CTPOnFrontConnected))); // } ...