public bool UpdateCandle(CandleMessage message, out Candle candle)
            {
                if (message == null)
                {
                    throw new ArgumentNullException(nameof(message));
                }

                candle = null;

                if (_currentCandle != null && _currentCandle.OpenTime == message.OpenTime)
                {
                    if (_currentCandle.State == CandleStates.Finished)
                    {
                        return(false);
                    }

                    _currentCandle.Update(message);
                }
                else
                {
                    _currentCandle = message.ToCandle(Series);
                }

                candle = _currentCandle;
                return(true);
            }
Beispiel #2
0
        private void ProcessCandleMessage(CandleMessage message)
        {
            if (!UseExternalCandleSource)
            {
                return;
            }

            var security = GetSecurity(message.SecurityId);
            var series   = _series.TryGetValue(security);

            if (series != null)
            {
                _newCandles.SafeInvoke(series, new[] { message.ToCandle(series) });
            }
        }
Beispiel #3
0
            private void ProcessCandle(SeriesInfo info, CandleMessage candleMsg)
            {
                if (info.CurrentCandle != null && info.CurrentCandle.OpenTime == candleMsg.OpenTime)
                {
                    if (info.CurrentCandle.State == CandleStates.Finished)
                    {
                        return;
                    }

                    info.CurrentCandle.Update(candleMsg);
                }
                else
                {
                    info.CurrentCandle = candleMsg.ToCandle(info.Series);
                }

                Processing?.Invoke(info.Series, info.CurrentCandle);
            }
        /// <summary>
        /// Update candle by new message.
        /// </summary>
        /// <param name="message">Message.</param>
        /// <param name="candle">Updated candle.</param>
        /// <returns>Candles series.</returns>
        public CandleSeries UpdateCandle(CandleMessage message, out Candle candle)
        {
            candle = null;

            if (_currentCandle != null && _currentCandle.OpenTime == message.OpenTime)
            {
                if (_currentCandle.State == CandleStates.Finished)
                {
                    return(null);
                }

                _currentCandle.Update(message);
            }
            else
            {
                _currentCandle = message.ToCandle(Series);
            }

            candle = _currentCandle;
            return(Series);
        }
		private void ProcessCandleMessage(CandleMessage message)
		{
			if (!UseExternalCandleSource)
				return;

			var security = GetSecurity(message.SecurityId);
			var series = _series.TryGetValue(security);

			if (series != null)
			{
				_newCandles.SafeInvoke(series, new[] { message.ToCandle(series) });

				if (message.IsFinished)
					_stopped.SafeInvoke(series);
			}
		}