private void LoadInstumentTradingTimeCommon(List <Protocal.TradingInstrument.InstrumentDayOpenCloseParams> instrumentDayOpenCloseParams) { Logger.InfoFormat("LoadInstumentTradingTimeCommon, instrumentParamsCount = {0}", instrumentDayOpenCloseParams.Count); InstrumentTradingStatusBuilderProxy builder = new InstrumentTradingStatusBuilderProxy(); foreach (var eachInstrumentDayOpenCloseParam in instrumentDayOpenCloseParams) { this.LoadTimeCheckPoints(eachInstrumentDayOpenCloseParam, builder); } if (builder.ExistsStatus()) { Logger.Info("LoadInstumentTradingTimeCommon"); this.OnInstrumentsStatusChanged(builder.StatusDict); } }
private void DoTimePointCheck() { Logger.InfoFormat("check point counts = {0}", _checkPointHeap.Count); InstrumentTradingStatusBuilderProxy statusBuilder = null; lock (_mutex) { while (_checkPointHeap.Count > 0 && _checkPointHeap.Pick().CheckTime <= DateTime.Now) { CheckPoint point = _checkPointHeap.Pop(); _loadedInstrumentCheckPoints.Remove(new InstrumentCheckTimeKey(point.InstrumentId, point.CheckTime)); Logger.InfoFormat("Dequeue, current check point {0}", point); if (statusBuilder == null) { statusBuilder = new InstrumentTradingStatusBuilderProxy(); } statusBuilder.Add(point.InstrumentId, point.Status, point.CheckTime, point.TradeDay); } } if (statusBuilder != null) { this.OnInstrumentsStatusChanged(statusBuilder.StatusDict); } }
private void AddCheckPoint(Guid instrumentId, DateTime checkTime, InstrumentStatus status, DateTime tradeDay, InstrumentTradingStatusBuilderProxy tradingStatus) { CheckPoint checkPoint = new CheckPoint(instrumentId, checkTime, status, tradeDay); var now = DateTime.Now; Logger.InfoFormat("add check point, {0}", checkPoint.ToString()); if (checkPoint.CheckTime <= now) { tradingStatus.Add(checkPoint.InstrumentId, checkPoint.Status, checkPoint.CheckTime, tradeDay); } else { if (_loadedInstrumentCheckPoints.Contains(new InstrumentCheckTimeKey(instrumentId, checkTime))) { return; } _loadedInstrumentCheckPoints.Add(new InstrumentCheckTimeKey(instrumentId, checkTime)); _checkPointHeap.Add(checkPoint); } }
private void LoadTimeCheckPoints(InstrumentDayOpenCloseParams instrumentTradingParam, InstrumentTradingStatusBuilderProxy tradingStatus) { if (instrumentTradingParam.IsTrading) { this.AddCheckPoint(instrumentTradingParam.Id, instrumentTradingParam.DayOpenTime.Value, InstrumentStatus.DayOpen, instrumentTradingParam.TradeDay, tradingStatus); this.AddCheckPoint(instrumentTradingParam.Id, instrumentTradingParam.DayCloseTime.Value, InstrumentStatus.DayClose, instrumentTradingParam.TradeDay, tradingStatus); foreach (var eachSession in instrumentTradingParam.TradingSessions) { this.AddCheckPoint(instrumentTradingParam.Id, eachSession.BeginTime, InstrumentStatus.SessionOpen, instrumentTradingParam.TradeDay, tradingStatus); this.AddCheckPoint(instrumentTradingParam.Id, eachSession.EndTime, InstrumentStatus.SessionClose, instrumentTradingParam.TradeDay, tradingStatus); } if (instrumentTradingParam.DayCloseTime != null) { DateTime acceptEndTime = instrumentTradingParam.DayCloseTime.Value.AddMinutes(-instrumentTradingParam.LastAcceptTimeSpan); this.AddCheckPoint(instrumentTradingParam.Id, acceptEndTime, InstrumentStatus.StopPlace, instrumentTradingParam.TradeDay, tradingStatus); } } }