Exemplo n.º 1
0
        private void RaiseMarketDataSubscriptionFinished(SubscriptionFinishedMessage message, Subscription subscription)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            if (subscription == null)
            {
                throw new ArgumentNullException(nameof(subscription));
            }

            var securityId = subscription.SecurityId;

            this.AddDebugLog(LocalizedStrings.SubscriptionFinished, securityId, message);
            MarketDataSubscriptionFinished?.Invoke(TryGetSecurity(securityId), message);

            RaiseSubscriptionStopped(subscription, null);

            if (subscription.CandleSeries != null)
            {
                RaiseCandleSeriesStopped(subscription.CandleSeries);
            }
        }
Exemplo n.º 2
0
        private void RaiseMarketDataUnexpectedCancelled(MarketDataMessage message, Exception error, Subscription subscription)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            if (error == null)
            {
                throw new ArgumentNullException(nameof(error));
            }

            if (subscription == null)
            {
                throw new ArgumentNullException(nameof(subscription));
            }

            var securityId = subscription.SecurityId;

            this.AddErrorLog(LocalizedStrings.SubscriptionUnexpectedCancelled, securityId, message.DataType2, error.Message);
            MarketDataUnexpectedCancelled?.Invoke(TryGetSecurity(securityId), message, error);

            RaiseSubscriptionStopped(subscription, error);

            if (subscription.CandleSeries != null)
            {
                RaiseCandleSeriesStopped(subscription.CandleSeries);
            }
        }
Exemplo n.º 3
0
        private void RaiseMarketDataUnSubscriptionFailed(MarketDataMessage origin, SubscriptionResponseMessage reply, Subscription subscription)
        {
            if (origin == null)
            {
                throw new ArgumentNullException(nameof(origin));
            }

            if (reply == null)
            {
                throw new ArgumentNullException(nameof(reply));
            }

            if (subscription == null)
            {
                throw new ArgumentNullException(nameof(subscription));
            }

            var securityId = subscription.SecurityId;
            var error      = reply.Error ?? new NotSupportedException();

            this.AddErrorLog(LocalizedStrings.UnSubscribedError, securityId, origin.DataType2, error.Message);

            var security = TryGetSecurity(securityId);

            MarketDataUnSubscriptionFailed?.Invoke(security, origin, error);
            MarketDataUnSubscriptionFailed2?.Invoke(security, origin, reply);

            RaiseSubscriptionFailed(subscription, error, false);
        }
Exemplo n.º 4
0
        private void RaiseMarketDataUnSubscriptionSucceeded(MarketDataMessage message, Subscription subscription)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            if (subscription == null)
            {
                throw new ArgumentNullException(nameof(subscription));
            }

            var securityId = subscription.SecurityId;

            var msg = LocalizedStrings.UnSubscribedOk.Put(securityId, message.DataType2);

            if (message.From != null && message.To != null)
            {
                msg += LocalizedStrings.Str691Params.Put(message.From.Value, message.To.Value);
            }

            this.AddDebugLog(msg + ".");
            MarketDataUnSubscriptionSucceeded?.Invoke(TryGetSecurity(securityId), message);

            RaiseSubscriptionStopped(subscription, null);

            if (subscription.CandleSeries != null)
            {
                RaiseCandleSeriesStopped(subscription.CandleSeries);
            }
        }
Exemplo n.º 5
0
        private void RaiseMarketDataSubscriptionFailed(MarketDataMessage origin, SubscriptionResponseMessage reply, Subscription subscription)
        {
            if (origin == null)
            {
                throw new ArgumentNullException(nameof(origin));
            }

            if (reply == null)
            {
                throw new ArgumentNullException(nameof(reply));
            }

            if (subscription == null)
            {
                throw new ArgumentNullException(nameof(subscription));
            }

            var securityId = subscription.SecurityId;
            var error      = reply.Error ?? new NotSupportedException(LocalizedStrings.SubscriptionNotSupported.Put(origin));

            if (reply.IsNotSupported())
            {
                this.AddWarningLog(LocalizedStrings.SubscriptionNotSupported, origin);
            }
            else
            {
                this.AddErrorLog(LocalizedStrings.SubscribedError, securityId, origin.DataType2, error.Message);
            }

            var security = TryGetSecurity(securityId);

            MarketDataSubscriptionFailed?.Invoke(security, origin, error);
            MarketDataSubscriptionFailed2?.Invoke(security, origin, reply);

            RaiseSubscriptionFailed(subscription, error, true);

            if (subscription.CandleSeries != null)
            {
                RaiseCandleSeriesError(subscription.CandleSeries, reply);
            }
        }
Exemplo n.º 6
0
 private void RaiseLevel1Received(Subscription subscription, Level1ChangeMessage message)
 {
     Level1Received?.Invoke(subscription, message);
     RaiseSubscriptionReceived(subscription, message);
 }
Exemplo n.º 7
0
 private void RaiseSubscriptionReceived(Subscription subscription, Message message)
 {
     SubscriptionReceived?.Invoke(subscription, message);
 }