예제 #1
0
        public ChannelReader <Quote> StreamDepth(string symbol)
        {
            IObservable <Quote>   observable = _nbboService.SubscribeToDepth(symbol);
            ChannelReader <Quote> reader     = observable.AsChannelReader(10);

            return(reader);
        }
예제 #2
0
 public ChannelReader <SensorData> Values()
 {
     if (_Sensor == null)
     {
         var rand = new Random(DateTime.Now.Millisecond);
         _Sensor = Observable.Generate(
             initialState: 0.0,
             condition: x => true,
             iterate: inVal => rand.NextDouble(),
             resultSelector: val => new SensorData
         {
             TimeStamp   = DateTime.Now,
             SensorType  = (Math.Floor(val * 4) + 1).ToString(),
             SensorValue = val * 20
         },
             timeSelector: val => TimeSpan.FromMilliseconds(val * 1000));
     }
     return(_Sensor.AsChannelReader(Context.ConnectionAborted));
 }