示例#1
0
 /// <summary>
 /// create a tracker for preferred provider with custom tick timeout and poll frequency settings
 /// </summary>
 /// <param name="pollintervalms"></param>
 /// <param name="timeoutintervalsec"></param>
 /// <param name="client"></param>
 /// <param name="PreferredBroker"></param>
 /// <param name="connectany"></param>
 public TLTracker(int pollintervalms, int timeoutintervalsec, TLClient client, Providers PreferredBroker, bool connectany)
 {
     _tl = client;
     _tw = new TickWatcher(pollintervalms);
     _tw.AlertThreshold = timeoutintervalsec;
     _connected = (client.ProvidersAvailable.Length > 0) && (client.ProviderSelected >= 0);
     if (!_connected && (GotConnectFail!= null))
         GotConnectFail();
     if (_connected && (GotConnect != null))
         GotConnect();
     // handle situations when no ticks arrive
     _tw.GotMassAlert += new Int32Delegate(_tw_GotMassAlert);
     _broker = PreferredBroker;
     _connectany = connectany;
 }
示例#2
0
 /// <summary>
 /// create a tracker for preferred provider with custom tick timeout and poll frequency settings
 /// </summary>
 /// <param name="pollintervalms"></param>
 /// <param name="timeoutintervalsec"></param>
 /// <param name="client"></param>
 /// <param name="PreferredBroker"></param>
 /// <param name="connectany"></param>
 public TLTracker(int pollintervalms, int timeoutintervalsec, TLClient client, Providers PreferredBroker, bool connectany)
 {
     _tl = client;
     _tw = new TickWatcher(pollintervalms);
     _tw.AlertThreshold = timeoutintervalsec;
     _connected         = (client.ProvidersAvailable.Length > 0) && (client.ProviderSelected >= 0);
     if (!_connected && (GotConnectFail != null))
     {
         GotConnectFail();
     }
     if (_connected && (GotConnect != null))
     {
         GotConnect();
     }
     // handle situations when no ticks arrive
     _tw.GotMassAlert += new Int32Delegate(_tw_GotMassAlert);
     _broker           = PreferredBroker;
     _connectany       = connectany;
 }
示例#3
0
        public void WatcherTest()
        {
            // create a new tick watcher
            TickWatcher tw = new TickWatcher(0);
            tw.GotAlert += new SymDelegate(tw_GotAlert);
            const string sym = "TST";
            const int y = 2008;
            const int m = 1;
            const int d = 1;
            int date = Util.ToTLDate(new DateTime(y, m, d));
            TickImpl t = TickImpl.NewTrade(sym,date,130000,100m,100,"");
            // watch this stock and supply a watch time
            // we have no previous updates to no whether to alert on, 
            // so it returns false
            Assert.IsFalse(tw.newTick(t));
            tw.AlertThreshold= 300;
            Assert.That(tw.AlertThreshold== 300);
            TickImpl t2 = TickImpl.Copy(t);
            t2.time = 130458;
            // this should succeed bc it's within the window (but no alert sent)
            Assert.IsFalse(tw.newTick(t2));

            // this time check should send no alerts bc it's w/in window
            tw.SendAlerts(new DateTime(y,m,d, 13, 4, 0));

            TickImpl t3 = TickImpl.Copy(t2);
            t3.time = 131000;
            // this should return false and send an alert
            Assert.That(tw.newTick(t3));

            // this timecheck is outside the window, should alert
            DateTime iswaylate = new DateTime(y,m,d, 14, 0, 1);
            tw.SendAlerts(iswaylate);

            Assert.AreEqual(2,alertssent); // here's our alert check
        }