Esempio n. 1
0
 public bool SetWatchedSymbols(List <RE.Symbol> symbols)
 {
     if (isEmpty(symbols))
     {
         Channel.closeResources();
         listeners.Clear();
         return(true);
     }
     foreach (var symbol in symbols)
     {
         var tempSymbol = symbol;
         var qSymbol    = new Symbol(symbol);
         if (listeners.ContainsKey(qSymbol))
         {
             continue;
         }
         listeners[qSymbol] = qSymbol.subscribe(tick => tickListener(tempSymbol, tick), true);
     }
     return(true);
 }
Esempio n. 2
0
 public bool SetWatchedSymbols(List <RE.Symbol> symbols)
 {
     if (isEmpty(symbols))
     {
         Channel.closeResources();
         each(threads.Values, thread => thread.Abort());
         threads.Clear();
         return(true);
     }
     foreach (var symbol in symbols)
     {
         var tempSymbol = symbol;
         var qSymbol    = new Symbol(symbol);
         if (threads.ContainsKey(qSymbol))
         {
             continue;
         }
         var rng = new Random();
         threads[qSymbol] = new Thread(() => {
             var delay = 1000;
             var time  = date(Dates.todayAt("05:00:00"));
             while (trueDat())
             {
                 var tick = new RE.TickData {
                     price    = rng.NextDouble() * 100,
                     size     = (ulong)rng.Next(),
                     tickType = RE.TickType.Trade,
                     time     = time
                 };
                 tickListener(tempSymbol, tick);
                 sleep(delay);
                 if (delay > 10)
                 {
                     delay -= 10;
                 }
             }
         });
         threads[qSymbol].Start();
     }
     return(true);
 }