Exemplo n.º 1
0
        /// <summary>
        /// Adds the base currency conversion feed.
        /// </summary>
        /// <param name="security">The security.</param>
        private void AddBaseCurrencyConversionFeed(Security security)
        {
            //get both ways
            string tickerbase     = $"{security.BaseCurrency}/{_basecurrency}";
            string tickerreversed = $"{_basecurrency}/{security.BaseCurrency}";

            //Check both subscriptions
            var tickerbasesubscription =
                DataSubscriptionRequest.CreateSubscriptionRequest(new TickerSymbol(tickerbase, _basecurrency.ToString(), security.BaseCurrency), _datafeed.DataSource, null, DataType.Tick);
            var tickerreversesubscription =
                DataSubscriptionRequest.CreateSubscriptionRequest(new TickerSymbol(tickerreversed, security.BaseCurrency.ToString(), _basecurrency), _datafeed.DataSource, null, DataType.Tick);

            //Add to subscription if needed possible
            string warningmessage(string ticker) =>
            $"Cannot get live updates for currency {ticker} from feed {_datafeed.Name}, currency conversion will not be based on live data as the feed does not provide this conversion";

            if (_datafeed.CanSubscribe(tickerbasesubscription.Ticker))
            {
                AddSubscription(tickerbasesubscription);
            }
            else
            {
                _log.Warn(warningmessage(tickerbase));
            }

            if (_datafeed.CanSubscribe(tickerreversesubscription.Ticker))
            {
                AddSubscription(tickerreversesubscription);
            }
            else
            {
                _log.Warn(warningmessage(tickerreversed));
            }
        }