Example #1
0
        public async Task SubscribeMarketData()
        {
            List <SymbolModel> symbols = new () { new SymbolModel("EUR/USD", "fxcm", SecurityType.Cfd) };

            // Act
            _api.Login();
            IReadOnlyList <QuoteBar> list = null;
            await _api.SubscribeMarketDataAsync(symbols, m =>
            {
                if (m is IReadOnlyList <QuoteBar> quotes)
                {
                    list = quotes;
                }
            }).ConfigureAwait(false);

            Thread.Sleep(6000);
            Assert.IsNotNull(list);
            Assert.AreNotEqual(0, list.Count);

            await _api.UnsubscribeQuotesAsync(symbols).ConfigureAwait(false);

            list = null;
            Thread.Sleep(6000);
            Assert.IsNull(list);
            _api.Logout();
        }
Example #2
0
        public override void GetMarketData(ProviderModel provider, Action <object> update)
        {
            DateTime now = DateTime.Now;

            if (!_symbolsUpdated)
            {
                IReadOnlyList <SymbolModel> symbols = _api.GetSymbolsAsync().Result;
                UpdateSymbols(provider, symbols, true);
                update(provider.Symbols);
                _symbolsUpdated = true;
                _api.SubscribeMarketDataAsync(provider.Symbols, update).Wait();
            }

            provider.LastDate = now;
        }