示例#1
0
 public void OnUpdate(MarketDataUpdate marketDataUpdate)
 {
     foreach (var watcher in _watchers)
     {
         watcher.OnUpdate(new[] { marketDataUpdate });
     }
 }
 public void AddItem(MarketDataUpdate item)
 {
     if (this.HasInstrument(item.InstrumentId))
     {
         this.Update(item);
     }
     else
     {
         this.AddNew(item);
     }
 }
示例#3
0
 public async Task SendDataAsync(MarketDataUpdate curItemData)
 {
     if (_start && curItemData != null)
     {
         await _source.SendAsync(curItemData);
     }
     else
     {
         await Task.CompletedTask;
     }
 }
示例#4
0
        public MarketDataUpdate Next()
        {
            var update = new MarketDataUpdate();

            update.InstrumentId = "AAPL_" + this.randomizer.Next(1, 100);
            update.Fields       = new Dictionary <byte, long>();

            for (int i = 0; i < this.randomizer.Next(1, 5); i++)
            {
                update.Fields[(byte)this.randomizer.Next(1, 20)] = this.randomizer.Next(1, 10000);
            }

            return(update);
        }
        private void Update(MarketDataUpdate item)
        {
            var existingItem = this.data[item.InstrumentId];

            foreach (var field in item.Fields)
            {
                if (existingItem.ContainsKey(field.Key))
                {
                    existingItem[field.Key] = field.Value;
                }
                else
                {
                    existingItem.Add(field.Key, field.Value);
                }
            }
        }
示例#6
0
        private void PublishSlice(IDictionary <string, Dictionary <byte, long> > data)
        {
            if (data == null)
            {
                return;
            }

            foreach (var(key, value) in data)
            {
                var itemToSend = new MarketDataUpdate(key, value);

                foreach (var watcher in this.watchers)
                {
                    watcher.OnUpdate(new[] { itemToSend });
                }
            }
        }
示例#7
0
        public void Start()
        {
            Task.Run(() =>
            {
                while (true)
                {
                    Thread.Sleep(1);
                    var update          = new MarketDataUpdate();
                    update.InstrumentId = "AAPL_" + _randomizer.Next(1, 100);
                    update.Fields       = new Dictionary <byte, long>();
                    for (int i = 0; i < _randomizer.Next(1, 5); i++)
                    {
                        update.Fields[(byte)_randomizer.Next(1, 20)] = _randomizer.Next(1, 10000);
                    }

                    foreach (var watcher in _watchers)
                    {
                        watcher.OnUpdate(update);
                    }
                }
            });
        }
 private void AddNew(MarketDataUpdate item)
 {
     this.data.Add(item.InstrumentId, item.Fields);
 }
示例#9
0
 public void Execute(MarketDataUpdate marketDataUpdate)
 {
     Console.WriteLine(marketDataUpdate);
 }
示例#10
0
 public void OnUpdate(MarketDataUpdate marketDataUpdate)
 {
     Task.Run(async() => await aggregator.SendDataAsync(marketDataUpdate));
 }
 public void Execute(MarketDataUpdate marketDataUpdate)
 {
     this.log.AppendLine($"{marketDataUpdate}");
 }
示例#12
0
 public void OnUpdate(MarketDataUpdate marketDataUpdate)
 {
     this.buffer.Enqueue(marketDataUpdate);
 }