Пример #1
0
        private void OnStockTick(object?sender, StockTick e)
        {
            var symbol = e.Symbol;
            var price  = e.Price;

            lock (StockLock)
            {
                if (StockInfos.TryGetValue(symbol, out var stockInfo))
                {
                    var prevPrice   = stockInfo.PrevPrice;
                    var changeRatio = Math.Round(Math.Abs(prevPrice - price) / prevPrice, 3);
                    if (changeRatio > MaxChangeRadio)
                    {
                        Console.WriteLine($"Stock:{symbol} has change with {changeRatio} ratio, Old Price:{prevPrice} New Price:{price}");
                    }

                    StockInfos[symbol].PrevPrice = price;
                }
                else
                {
                    StockInfos.Add(symbol, new StockInfo(symbol, price));
                    //StockInfos.TryAdd(symbol, new StockInfo(symbol, price));
                }
            }
        }
Пример #2
0
 public void StockChange(string symbol, decimal price)
 {
     StockTick?.Invoke(this, new StockTick(symbol, price));
 }