public void GetsTickData()
        {
            InteractiveBrokersGatewayRunner.StartFromConfiguration();

            var ib = new InteractiveBrokersBrokerage(new OrderProvider());

            ib.Connect();

            ib.Subscribe(null, new Dictionary <SecurityType, List <string> >
            {
                { SecurityType.Forex, new List <string> {
                      "USDJPY", "EURGBP"
                  } }
            });

            Thread.Sleep(1000);

            for (int i = 0; i < 10; i++)
            {
                foreach (var tick in ib.GetNextTicks())
                {
                    Console.WriteLine("{0}: {1} - {2} @ {3}", tick.Time, tick.Symbol, tick.Price, ((Tick)tick).Quantity);
                }
            }

            InteractiveBrokersGatewayRunner.Stop();
        }
Esempio n. 2
0
        public void GetsTickData()
        {
            InteractiveBrokersGatewayRunner.StartFromConfiguration();

            var ib = new InteractiveBrokersBrokerage(new QCAlgorithm(), new OrderProvider(), new SecurityProvider());

            ib.Connect();

            ib.Subscribe(null, new List <Symbol> {
                Symbols.USDJPY, Symbols.EURGBP
            });

            Thread.Sleep(1000);

            var gotUsdData = false;
            var gotEurData = false;

            for (int i = 0; i < 20; i++)
            {
                foreach (var tick in ib.GetNextTicks())
                {
                    Console.WriteLine("{0}: {1} - {2} @ {3}", tick.Time, tick.Symbol, tick.Price, ((Tick)tick).Quantity);
                    gotUsdData |= tick.Symbol == Symbols.USDJPY;
                    gotEurData |= tick.Symbol == Symbols.EURGBP;
                }
            }
            Assert.IsTrue(gotUsdData);
            Assert.IsTrue(gotEurData);
            InteractiveBrokersGatewayRunner.Stop();
        }
Esempio n. 3
0
        public void GetsTickDataAfterDisconnectionConnectionCycle()
        {
            using (var ib = new InteractiveBrokersBrokerage(new QCAlgorithm(), new OrderProvider(), new SecurityProvider()))
            {
                ib.Connect();
                ib.Subscribe(null, new List <Symbol> {
                    Symbols.USDJPY, Symbols.EURGBP
                });
                ib.Disconnect();
                Thread.Sleep(2000);

                for (var i = 0; i < 20; i++)
                {
                    foreach (var tick in ib.GetNextTicks()) // we need to make sure we consumer the already sent data, if any
                    {
                        Console.WriteLine("{0}: {1} - {2} @ {3}", tick.Time, tick.Symbol, tick.Price, ((Tick)tick).Quantity);
                    }
                }

                ib.Connect();
                Thread.Sleep(2000);

                var gotUsdData = false;
                var gotEurData = false;
                for (var i = 0; i < 20; i++)
                {
                    foreach (var tick in ib.GetNextTicks())
                    {
                        Console.WriteLine("{0}: {1} - {2} @ {3}", tick.Time, tick.Symbol, tick.Price, ((Tick)tick).Quantity);
                        gotUsdData |= tick.Symbol == Symbols.USDJPY;
                        gotEurData |= tick.Symbol == Symbols.EURGBP;
                    }
                }
                Assert.IsTrue(gotUsdData);
                Assert.IsTrue(gotEurData);
            }
        }