Пример #1
0
        public void SubscribeManyPerChannel()
        {
            var subscriptionManager = new FakeDataQueuehandlerSubscriptionManager((t) => t.ToString());

            for (int i = 0; i < 5; i++)
            {
                subscriptionManager.Subscribe(GetSubscriptionDataConfig <TradeBar>(Symbols.AAPL, Resolution.Minute));
            }

            Assert.IsTrue(subscriptionManager.IsSubscribed(Symbols.AAPL, TickType.Trade));
            Assert.IsFalse(subscriptionManager.IsSubscribed(Symbols.AAPL, TickType.Quote));

            subscriptionManager.Subscribe(GetSubscriptionDataConfig <QuoteBar>(Symbols.AAPL, Resolution.Minute));

            Assert.IsTrue(subscriptionManager.IsSubscribed(Symbols.AAPL, TickType.Trade));
            Assert.IsTrue(subscriptionManager.IsSubscribed(Symbols.AAPL, TickType.Quote));

            for (int i = 0; i < 5; i++)
            {
                subscriptionManager.Unsubscribe(GetSubscriptionDataConfig <TradeBar>(Symbols.AAPL, Resolution.Minute));
            }

            Assert.IsFalse(subscriptionManager.IsSubscribed(Symbols.AAPL, TickType.Trade));
            Assert.IsTrue(subscriptionManager.IsSubscribed(Symbols.AAPL, TickType.Quote));

            subscriptionManager.Unsubscribe(GetSubscriptionDataConfig <QuoteBar>(Symbols.AAPL, Resolution.Minute));

            Assert.IsFalse(subscriptionManager.IsSubscribed(Symbols.AAPL, TickType.Trade));
            Assert.IsFalse(subscriptionManager.IsSubscribed(Symbols.AAPL, TickType.Quote));
        }
Пример #2
0
        public void SubscribeSinglePerChannel(Type type, TickType tickType)
        {
            var subscriptionManager = new FakeDataQueuehandlerSubscriptionManager((t) => t.ToString());

            subscriptionManager.Subscribe(GetSubscriptionDataConfig(type, Symbols.AAPL, Resolution.Minute));

            Assert.AreEqual(1, subscriptionManager.GetSubscribedSymbols().Count());
            Assert.Contains(Symbols.AAPL, subscriptionManager.GetSubscribedSymbols().ToArray());

            foreach (var value in Enum.GetValues(typeof(TickType)))
            {
                Assert.AreEqual(tickType == (TickType)value, subscriptionManager.IsSubscribed(Symbols.AAPL, (TickType)value));
            }
        }