public void TestClearSymbols()
        {
            TestListener listener           = new TestListener(eventsTimeout, eventsSleepTime, IsConnected);
            string       candleSymbolString = "XBT/USD{=d}";
            string       aaplSymbolString   = "AAPL{=d,price=mark}";

            using (var con = new NativeConnection(address, OnDisconnect))
            {
                Interlocked.Exchange(ref isConnected, 1);
                using (IDxSubscription s = con.CreateSubscription(defaultDateTime, listener))
                {
                    s.AddSymbol(CandleSymbol.ValueOf(candleSymbolString));
                    listener.WaitEvents <IDxCandle>(candleSymbolString);

                    s.Clear();
                    listener.ClearEvents <IDxCandle>();
                    Thread.Sleep(10000);
                    Assert.AreEqual(0, listener.GetEventCount <IDxCandle>());

                    //try to restore symbols
                    s.AddSymbol(CandleSymbol.ValueOf(candleSymbolString));
                    listener.WaitEvents <IDxCandle>(candleSymbolString);

                    //set other symbol
                    s.Clear();
                    listener.ClearEvents <IDxCandle>();
                    s.AddSymbol(CandleSymbol.ValueOf(aaplSymbolString));
                    listener.WaitEvents <IDxCandle>(aaplSymbolString);
                    Assert.AreEqual(listener.GetEventCount <IDxCandle>(), listener.GetEventCount <IDxCandle>(aaplSymbolString));
                }
            }
        }
Пример #2
0
        public void TestGetSymbols()
        {
            TestListener listener = new TestListener(eventsTimeout, eventsSleepTime, IsConnected);
            EventType    events   = EventType.Order;

            using (var con = new NativeConnection(address, OnDisconnect))
            {
                Interlocked.Exchange(ref isConnected, 1);
                using (IDxSubscription s = con.CreateSubscription(events, listener))
                {
                    List <string> symbols = new List <string>(new string[] { "AAPL", "IBM" });
                    s.AddSymbols(symbols.ToArray());

                    IList <string> returnedSymbolList = s.GetSymbols();
                    Assert.AreEqual(symbols.Count, returnedSymbolList.Count);
                    foreach (string symbol in returnedSymbolList)
                    {
                        Assert.True(symbols.Contains(symbol));
                    }

                    s.Clear();
                    returnedSymbolList = s.GetSymbols();
                    Assert.AreEqual(0, returnedSymbolList.Count);
                }
            }
        }
Пример #3
0
        public void TestClearSymbols()
        {
            TestListener listener = new TestListener(eventsTimeout, eventsSleepTime, IsConnected);
            EventType    events   = EventType.Order;

            using (var con = new NativeConnection(address, OnDisconnect))
            {
                Interlocked.Exchange(ref isConnected, 1);
                using (IDxSubscription s = con.CreateSubscription(events, listener))
                {
                    s.AddSymbols("AAPL", "IBM");

                    listener.WaitEvents <IDxOrder>("AAPL", "IBM");

                    s.Clear();
                    listener.ClearEvents <IDxOrder>();

                    Thread.Sleep(10000);
                    Assert.AreEqual(0, listener.GetEventCount <IDxOrder>("AAPL", "IBM"));

                    //add another symbol
                    s.AddSymbols("XBT/USD");
                    listener.WaitEvents <IDxOrder>("XBT/USD");
                }
            }
        }
Пример #4
0
        public void TestGetSymbols()
        {
            SnapshotTestListener listener = new SnapshotTestListener(eventsTimeout, eventsSleepTime, IsConnected);
            string source = "NTV";
            string symbol = "AAPL";

            using (var con = new NativeConnection(address, OnDisconnect))
            {
                Interlocked.Exchange(ref isConnected, 1);
                using (IDxSubscription s = con.CreateSnapshotSubscription(0, listener))
                {
                    s.AddSource(source);
                    s.AddSymbol(symbol);
                    listener.WaitSnapshot <IDxOrder>(symbol, source);

                    IList <string> returnedSymbolList = s.GetSymbols();
                    Assert.AreEqual(1, returnedSymbolList.Count);
                    Assert.AreEqual(symbol, returnedSymbolList[0]);

                    s.Clear();
                    returnedSymbolList = s.GetSymbols();
                    Assert.AreEqual(0, returnedSymbolList.Count);
                }
            }
        }
Пример #5
0
        public void TestClearSymbols2()
        {
            SnapshotTestListener listener = new SnapshotTestListener(eventsTimeout, eventsSleepTime, IsConnected);
            string source       = "NTV";
            string symbol       = "AAPL";
            string candleString = "XBT/USD{=d}";

            using (var con = new NativeConnection(address, OnDisconnect))
            {
                Interlocked.Exchange(ref isConnected, 1);
                using (IDxSubscription s = con.CreateSnapshotSubscription(0, listener))
                {
                    s.AddSource(source);
                    s.AddSymbol(symbol);
                    listener.WaitSnapshot <IDxOrder>(symbol, source);

                    s.Clear();
                    listener.ClearEvents <IDxOrder>();
                    Assert.AreEqual(0, s.GetSymbols().Count);

                    Thread.Sleep(10000);
                    Assert.AreEqual(0, listener.GetSnapshotsCount <IDxOrder>(symbol));

                    //add another symbol
                    s.AddSymbols(CandleSymbol.ValueOf(candleString));
                    listener.WaitSnapshot <IDxCandle>(candleString);
                }
            }
        }
Пример #6
0
 /// <summary>
 ///   Clear all symbols from subscription.
 /// </summary>
 /// <exception cref="DxException"></exception>
 public void Clear()
 {
     subscription.Clear();
     symbols.Clear();
     snapshots.Clear();
     symbolSourceToKey.Clear();
     receivedSnapshots.Clear();
     orderViewStates.Clear();
 }
Пример #7
0
        public void TestGetSymbolsCandle()
        {
            SnapshotTestListener listener = new SnapshotTestListener(eventsTimeout, eventsSleepTime, IsConnected);
            string candleString           = "XBT/USD{=d}";

            using (var con = new NativeConnection(address, OnDisconnect))
            {
                Interlocked.Exchange(ref isConnected, 1);
                using (IDxSubscription s = con.CreateSnapshotSubscription(0, listener))
                {
                    s.AddSymbol(CandleSymbol.ValueOf(candleString));
                    listener.WaitSnapshot <IDxCandle>(candleString);

                    IList <string> returnedSymbolList = s.GetSymbols();
                    Assert.AreEqual(1, returnedSymbolList.Count);
                    Assert.AreEqual(candleString, returnedSymbolList[0]);

                    s.Clear();
                    returnedSymbolList = s.GetSymbols();
                    Assert.AreEqual(0, returnedSymbolList.Count);
                }
            }
        }