예제 #1
0
        void OnStockTick(object sender, StockTick stockTick)
        {
            const decimal maxChangeRatio = 0.1m;

            StockInfo stockInfo;
            var       quoteSymbol     = stockTick.QuoteSymbol;
            var       stockInfoExists = _stockInfos.TryGetValue(quoteSymbol, out stockInfo);

            if (stockInfoExists)
            {
                var priceDiff   = stockTick.Price - stockInfo.PrevPrice;
                var changeRatio = Math.Abs(priceDiff / stockInfo.PrevPrice);
                if (changeRatio > maxChangeRatio)
                {
                    Debug.WriteLine("Stock:{0} has changed with {1} ratio - OldPrice:{2} NewPrice:{3}",
                                    quoteSymbol, changeRatio, stockInfo.PrevPrice, stockTick.Price);
                }
                _stockInfos[quoteSymbol].PrevPrice = stockTick.Price;
            }
            else
            {
                _stockInfos[quoteSymbol] = new StockInfo(quoteSymbol, stockTick.Price);
            }
        }
예제 #2
0
 public void Tick(StockTick tick)
 {
     StockTick(this, tick);
 }