public SubscriptionInfo(Subscription subscription) { Subscription = subscription ?? throw new ArgumentNullException(nameof(subscription)); if (Subscription.CandleSeries != null) { Holder = new CandlesSeriesHolder(subscription.CandleSeries); } var type = subscription.DataType; if (type == DataType.PositionChanges || type == DataType.Securities || type == DataType.Board || subscription.SubscriptionMessage is TimeFrameLookupMessage) { Lookup = new LookupInfo(subscription.SubscriptionMessage); } }
public SubscriptionInfo(Subscription subscription) { Subscription = subscription ?? throw new ArgumentNullException(nameof(subscription)); if (Subscription.CandleSeries != null) { Holder = new CandlesSeriesHolder(subscription.CandleSeries); } _last = subscription.SubscriptionMessage.From; var type = subscription.DataType; if (type == DataType.PositionChanges || type == DataType.Securities || type == DataType.Board || type == DataType.TimeFrames) { LookupItems = new List <object>(); } }
public SubscriptionInfo(Subscription subscription, bool keepAfterFinish) { Subscription = subscription ?? throw new ArgumentNullException(nameof(subscription)); KeepAfterFinish = keepAfterFinish; if (Subscription.CandleSeries != null) { Holder = new CandlesSeriesHolder(subscription.CandleSeries); } _last = subscription.SubscriptionMessage.From; var type = subscription.DataType; if (type == DataType.PositionChanges || type == DataType.Securities || type == DataType.Board || type == DataType.TimeFrames) { Lookup = new LookupInfo(subscription.SubscriptionMessage); } }
private void LoadData(CandleSeries series) { var msgType = series.CandleType.ToCandleMessageType(); _holder = new CandlesSeriesHolder(series); _candleTransform.Process(new ResetMessage()); _candleBuilder = msgType.ToCandleMarketDataType().CreateCandleBuilder(); var storage = new StorageRegistry(); BusyIndicator.IsBusy = true; var path = HistoryPath.Folder; var isBuild = BuildFromTicks.IsChecked == true; var format = Format.SelectedFormat; var maxDays = (isBuild || series.CandleType != typeof(TimeFrameCandle)) ? 5 : 30 * (int)((TimeSpan)series.Arg).TotalMinutes; _mdMsg = series.ToMarketDataMessage(true); Task.Factory.StartNew(() => { var date = DateTime.MinValue; if (isBuild) { foreach (var tick in storage.GetTickMessageStorage(series.Security, new LocalMarketDataDrive(path), format).Load()) { _tradeGenerator.Process(tick); if (_candleTransform.Process(tick)) { var candles = _candleBuilder.Process(_mdMsg, _currCandle, _candleTransform); foreach (var candle in candles) { _currCandle = candle; _updatedCandles.Add((CandleMessage)candle.Clone()); } } _lastTime = tick.ServerTime; if (date != tick.ServerTime.Date) { date = tick.ServerTime.Date; var str = date.To <string>(); this.GuiAsync(() => BusyIndicator.BusyContent = str); maxDays--; if (maxDays == 0) { break; } } } } else { foreach (var candleMsg in storage.GetCandleMessageStorage(msgType, series.Security, series.Arg, new LocalMarketDataDrive(path), format).Load()) { if (candleMsg.State != CandleStates.Finished) { candleMsg.State = CandleStates.Finished; } _currCandle = candleMsg; _updatedCandles.Add(candleMsg); _lastTime = candleMsg.OpenTime; if (candleMsg is TimeFrameCandleMessage) { _lastTime += (TimeSpan)series.Arg; } _tradeGenerator.Process(new ExecutionMessage { ExecutionType = ExecutionTypes.Tick, SecurityId = series.Security.ToSecurityId(), ServerTime = _lastTime, TradePrice = candleMsg.ClosePrice, }); if (date != candleMsg.OpenTime.Date) { date = candleMsg.OpenTime.Date; var str = date.To <string>(); this.GuiAsync(() => BusyIndicator.BusyContent = str); maxDays--; if (maxDays == 0) { break; } } } } _historyLoaded = true; }) .ContinueWith(t => { if (t.Exception != null) { Error(t.Exception.Message); } BusyIndicator.IsBusy = false; Chart.IsAutoRange = false; }, TaskScheduler.FromCurrentSynchronizationContext()); }