Пример #1
0
        private void OnSubscription(SubscribedResponse response)
        {
            _streams.SubscriptionSubject.OnNext(response);

            var channelId = response.ChanId;

            // ********************
            // ADD HANDLERS BELOW
            // ********************

            switch (response.Channel)
            {
            case "ticker":
                _channelIdToHandler[channelId] = (data, config) =>
                                                 Ticker.Handle(data, response, config, _streams.TickerSubject);
                break;

            case "trades":
                //if pair is null means that is funding
                if (response.Pair == null)
                {
                    _channelIdToHandler[channelId] = (data, config) =>
                                                     Funding.Handle(data, response, config, _streams.FundingsSubject);
                }
                else
                {
                    _channelIdToHandler[channelId] = (data, config) =>
                                                     Trade.Handle(data, response, config, _streams.TradesSubject, _streams.TradesSnapshotSubject);
                }
                break;

            case "candles":
                _channelIdToHandler[channelId] = (data, config) =>
                                                 Candles.Handle(data, response, _streams.CandlesSubject);
                break;

            case "book":
                _channelIdToHandler[channelId] = (data, config) =>
                                                 Book.Handle(data, response, config, _streams.BookSubject, _streams.BookSnapshotSubject, _streams.BookChecksumSubject);
                break;

            case "status":
                if (response.Key.StartsWith("deriv"))
                {
                    _channelIdToHandler[channelId] = (data, config) =>
                                                     DerivativePairStatus.Handle(data, response, _streams.DerivativePairSubject);
                }

                if (response.Key.StartsWith("liq"))
                {
                    _channelIdToHandler[channelId] = (data, config) =>
                                                     LiquidationFeedStatus.Handle(data, response, _streams.LiquidationFeedSubject);
                }

                break;
                //default:
                //    Log.Warning($"Missing subscription handler '{response.Channel}'");
                //    break;
            }
        }