Exemple #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);
     }
 }
Exemple #3
0
 public async Task SendDataAsync(MarketDataUpdate curItemData)
 {
     if (_start && curItemData != null)
     {
         await _source.SendAsync(curItemData);
     }
     else
     {
         await Task.CompletedTask;
     }
 }
Exemple #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);
                }
            }
        }
Exemple #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 });
                }
            }
        }
Exemple #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);
 }
Exemple #9
0
 public void Execute(MarketDataUpdate marketDataUpdate)
 {
     Console.WriteLine(marketDataUpdate);
 }
Exemple #10
0
 public void OnUpdate(MarketDataUpdate marketDataUpdate)
 {
     Task.Run(async() => await aggregator.SendDataAsync(marketDataUpdate));
 }
 public void Execute(MarketDataUpdate marketDataUpdate)
 {
     this.log.AppendLine($"{marketDataUpdate}");
 }
Exemple #12
0
 public void OnUpdate(MarketDataUpdate marketDataUpdate)
 {
     this.buffer.Enqueue(marketDataUpdate);
 }