Beispiel #1
0
        public void UpdateRow(Tick k)
        {
            // bool exist = GridViewModel.QuoteGridList.Any(x => x.Symbol == k.FullSymbol);
            var item = QuoteGridList.FirstOrDefault(i => i.Symbol == k.FullSymbol);

            if (item != null)
            {
                if (k.HasBid)
                {
                    item.BidPair = new QuoteGridLine.QuotePair(item.BidPair._newvalue, k.BidPrice);
                    item.BidSize = k.BidSize;
                }
                if (k.HasAsk)
                {
                    item.AskPair = new QuoteGridLine.QuotePair(item.AskPair._newvalue, k.AskPrice);
                    item.AskSize = k.AskSize;
                }

                if (k.IsTrade)
                {
                    // decimal old_trade = (decimal)item.TradePair._newvalue;
                    item.TradePair = new QuoteGridLine.QuotePair(item.TradePair._newvalue, k.TradePrice);
                    item.Size      = k.TradeSize;

                    //item.TradeColor = k.TradePrice > old_trade ? System.Windows.Media.Colors.Green
                    //   : (k.TradePrice == old_trade ? System.Windows.Media.Colors.White : System.Windows.Media.Colors.Red);

                    if (item.PreClose != 0m)
                    {
                        item.Change           = k.TradePrice - item.PreClose;
                        item.ChangePercentage = String.Format("{0:P3}.", k.TradePrice / item.PreClose - 1);
                    }
                }
            }
        }
Beispiel #2
0
        public void UpdatePreclose(string sym, decimal preclose)
        {
            var item = QuoteGridList.FirstOrDefault(i => i.Symbol == sym);

            if (item != null)
            {
                item.PreClose = preclose;
                if (item.PreClose != 0m)
                {
                    item.Change           = item.TradePair._newvalue - item.PreClose;
                    item.ChangePercentage = String.Format("{0:P3}.", item.TradePair._newvalue / item.PreClose - 1);
                }
            }
        }