private static DateTime CalculateTimeStamp(ThostFtdcDepthMarketDataField field) { DateTime result = DateTime.MinValue; TimeSpan updateTime = CTPMarketDataHelper.GetUpdateTime(field.UpdateTime); if (updateTime > CTPMarketDataHelper.nightTimeSpan) { result = CTPMarketDataHelper.PreTradingDay.Add(updateTime).AddMilliseconds((double)field.UpdateMillisec); } else if (updateTime > CTPMarketDataHelper.dayTimeSpan) { result = CTPMarketDataHelper.GetDate(field.TradingDay).Add(updateTime).AddMilliseconds((double)field.UpdateMillisec); } else { result = CTPMarketDataHelper.PreTradingDay.AddDays(1.0).Add(updateTime).AddMilliseconds((double)field.UpdateMillisec); } return(result); }
public static Tick ConvertToTick(ThostFtdcDepthMarketDataField field) { return(new Tick { InstrumentID = field.InstrumentID, ExchangeID = field.ExchangeID, ExchangeInstID = field.ExchangeID, LastPrice = CTPMarketDataHelper.GetDoubleValue(field.LastPrice), PreSettlementPrice = CTPMarketDataHelper.GetDoubleValue(field.PreSettlementPrice), PreClosePrice = CTPMarketDataHelper.GetDoubleValue(field.PreClosePrice), OpenPrice = CTPMarketDataHelper.GetDoubleValue(field.OpenPrice), HighestPrice = CTPMarketDataHelper.GetDoubleValue(field.HighestPrice), LowestPrice = CTPMarketDataHelper.GetDoubleValue(field.LowestPrice), Volume = field.Volume, Turnover = CTPMarketDataHelper.GetDoubleValue(field.Turnover), OpenInterest = CTPMarketDataHelper.GetDoubleValue(field.OpenInterest), ClosePrice = CTPMarketDataHelper.GetDoubleValue(field.ClosePrice), SettlementPrice = CTPMarketDataHelper.GetDoubleValue(field.SettlementPrice), // HighLimitedPrice = CTPMarketDataHelper.GetDoubleValue(field.UpperLimitPrice), // LowLimitedPrice = CTPMarketDataHelper.GetDoubleValue(field.LowerLimitPrice), PreDelta = CTPMarketDataHelper.GetDoubleValue(field.PreDelta), CurrDelta = CTPMarketDataHelper.GetDoubleValue(field.CurrDelta), UpdateTime = field.UpdateTime, UpdateMillisec = field.UpdateMillisec, BidPrice1 = CTPMarketDataHelper.GetDoubleValue(field.BidPrice1), BidVolume1 = field.BidVolume1, AskPrice1 = CTPMarketDataHelper.GetDoubleValue(field.AskPrice1), AskVolume1 = field.AskVolume1, AveragePrice = CTPMarketDataHelper.GetDoubleValue(field.AveragePrice), PreOpenInterest = field.PreOpenInterest, // LastVolume = (long)field.Volume - lastVolume, // TimeStamp = CTPMarketDataHelper.CalculateTimeStamp(field) }); }