Exemple #1
0
            public IEnumerable <Tuple <Subscription, Candle> > UpdateCandles(CandleMessage message)
            {
                foreach (var subscriptionId in message.GetSubscriptionIds())
                {
                    SubscriptionInfo info;

                    lock (_syncObject)
                    {
                        if (!_subscriptions.TryGetValue(subscriptionId, out info))
                        {
                            TryWriteLog(subscriptionId);
                            continue;
                        }
                    }

                    if (info.Holder == null)
                    {
                        continue;
                    }

                    if (!info.UpdateLastTime(message.OpenTime))
                    {
                        continue;
                    }

                    if (!info.Holder.UpdateCandle(message, out var candle))
                    {
                        continue;
                    }

                    yield return(Tuple.Create(info.Subscription, candle));
                }
            }
Exemple #2
0
            public IEnumerable <Tuple <Subscription, Candle> > UpdateCandles(CandleMessage message)
            {
                foreach (var subscriptionId in message.GetSubscriptionIds())
                {
                    SubscriptionInfo info;

                    lock (_syncObject)
                    {
                        if (!_subscriptions.TryGetValue(subscriptionId, out info))
                        {
                            TryWriteLog(subscriptionId);
                            continue;
                        }

                        if (info.Security == null)
                        {
                            if (info.SecurityNotFound)
                            {
                                continue;
                            }

                            var security = _connector.TryGetSecurity(info.Subscription.SecurityId);

                            if (security == null)
                            {
                                info.SecurityNotFound = true;
                                _connector.AddWarningLog(LocalizedStrings.Str704Params.Put(info.Subscription.SecurityId));
                                continue;
                            }

                            info.Security = security;
                        }
                    }

                    if (!info.UpdateLastTime(message.OpenTime))
                    {
                        continue;
                    }

                    if (!info.UpdateCandle(message, out var candle))
                    {
                        continue;
                    }

                    yield return(Tuple.Create(info.Subscription, candle));
                }
            }
        /// <summary>
        /// Update candles by new message.
        /// </summary>
        /// <param name="message">Message.</param>
        /// <returns>Candles series.</returns>
        public IEnumerable <Tuple <CandleSeries, Candle, long> > UpdateCandles(CandleMessage message)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            foreach (var subscriptionId in message.GetSubscriptionIds())
            {
                var info = _holders.TryGetValue(subscriptionId);

                if (info == null)
                {
                    continue;
                }

                if (!info.UpdateCandle(message, out var candle))
                {
                    continue;
                }

                yield return(Tuple.Create(info.Series, candle, subscriptionId));
            }
        }