internal void Initialize(DataSet ds)
        {
            this.LoadTradingInfo(ds);
            var table = ds.Tables["TradingTime"];

            foreach (DataRow dr in table.Rows)
            {
                Guid InstrumentId = (Guid)dr["InstrumentID"];
                Protocal.TradingInstrument.InstrumentDayOpenCloseParams instrument;
                if (!_instrumentDict.TryGetValue(InstrumentId, out instrument))
                {
                    TradingTime tradingTIme = Settings.Setting.Default.GetTradingTime(InstrumentId);
                    instrument = new Protocal.TradingInstrument.InstrumentDayOpenCloseParams
                    {
                        Id           = InstrumentId,
                        TradeDay     = tradingTIme.DayOpenTime.Date,
                        DayOpenTime  = tradingTIme.DayOpenTime,
                        DayCloseTime = tradingTIme.DayCloseTime,
                        IsTrading    = true
                    };
                    _instrumentDict.Add(InstrumentId, instrument);
                }
                DateTime beginTime = (DateTime)dr["BeginTime"];
                DateTime endTime   = (DateTime)dr["EndTime"];
                var      session   = new Protocal.TradingInstrument.TradingSession
                {
                    BeginTime = beginTime,
                    EndTime   = endTime
                };
                instrument.AddSession(session);
            }
        }
Exemple #2
0
        private void ParseIndividualTradingTime(DataRow dr, Dictionary <Guid, Protocal.TradingInstrument.InstrumentDayOpenCloseParams> instrumentParamDict)
        {
            Guid instrumentId = (Guid)dr["InstrumentID"];

            Protocal.TradingInstrument.InstrumentDayOpenCloseParams instrumentParams;
            var instrument = InstrumentManager.Default.GetInstrument(instrumentId);

            if (instrument.TradeDay == null)
            {
                return;
            }
            if (!instrumentParamDict.TryGetValue(instrumentId, out instrumentParams))
            {
                instrumentParams = new Protocal.TradingInstrument.InstrumentDayOpenCloseParams
                {
                    Id                 = instrumentId,
                    TradeDay           = instrument.TradeDay.Value,
                    DayOpenTime        = instrument.DayOpenTime,
                    DayCloseTime       = instrument.DayCloseTime,
                    LastAcceptTimeSpan = instrument.LastAcceptTimeSpan,
                    IsTrading          = true
                };
                instrumentParamDict.Add(instrumentId, instrumentParams);
            }
            DateTime beginTime = (DateTime)dr["BeginTime"];
            DateTime endTime   = (DateTime)dr["EndTime"];
            var      session   = new Protocal.TradingInstrument.TradingSession
            {
                BeginTime = beginTime,
                EndTime   = endTime
            };

            instrumentParams.AddSession(session);
        }
Exemple #3
0
 public void AddSession(TradingSession session)
 {
     if (this.TradingSessions == null)
     {
         this.TradingSessions = new List <TradingSession>();
     }
     this.TradingSessions.Add(session);
 }
        private void LoadTradingInfo(DataSet ds)
        {
            _tradingInfo = new Protocal.TradingInstrument.TradingInfo();
            _tradingInfo.TradingTimeList = new List <InstrumentTradingTime>();
            Dictionary <Guid, InstrumentTradingTime> tradingTimeDict = new Dictionary <Guid, InstrumentTradingTime>();
            var table = ds.Tables["TradingTime"];

            foreach (DataRow dr in table.Rows)
            {
                Guid instrumentId = (Guid)dr["InstrumentID"];
                InstrumentTradingTime instrumentTradingTime;
                if (!tradingTimeDict.TryGetValue(instrumentId, out instrumentTradingTime))
                {
                    instrumentTradingTime = new InstrumentTradingTime();
                    tradingTimeDict.Add(instrumentId, instrumentTradingTime);
                    instrumentTradingTime.Id       = instrumentId;
                    instrumentTradingTime.Sessions = new List <TradingSession>();
                }

                DateTime beginTime = (DateTime)dr["BeginTime"];
                DateTime endTime   = (DateTime)dr["EndTime"];
                var      session   = new Protocal.TradingInstrument.TradingSession
                {
                    BeginTime = beginTime,
                    EndTime   = endTime
                };
                instrumentTradingTime.Sessions.Add(session);
            }

            var tradeDay = Setting.Default.GetTradeDay();

            _tradingInfo.TradeDayInfo = new TradeDayInfo()
            {
                TradeDay  = tradeDay.Day,
                BeginTime = tradeDay.BeginTime,
                EndTime   = tradeDay.EndTime
            };

            foreach (var eachTradingTime in tradingTimeDict.Values)
            {
                _tradingInfo.TradingTimeList.Add(eachTradingTime);
            }
        }