예제 #1
0
        public static void UpdateHistoryItem(ITicker item)
        {
            TickerHistoryItem last = item.History.Count == 0 ? null : item.History.Last();

            if (item.History.Count > 36000)
            {
                item.History.RemoveAt(0);
            }
            if (last != null)
            {
                if (last.Ask == item.LowestAsk && last.Bid == item.HighestBid && last.Current == item.Last)
                {
                    return;
                }
                item.Change = ((item.Last - last.Current) / last.Current) * 100;
                if (last.Bid != item.HighestBid)
                {
                    item.BidChange = (item.HighestBid - last.Bid) * 100;
                }
                if (last.Ask != item.LowestAsk)
                {
                    item.AskChange = item.LowestAsk - last.Ask;
                }
            }
            item.History.Add(new TickerHistoryItem()
            {
                Time = item.Time, Ask = item.LowestAsk, Bid = item.HighestBid, Current = item.Last
            });
            item.RaiseHistoryItemAdded();
        }