예제 #1
0
        public void OnNewStreamItem(Quote quote)
        {
            //Quotes.Add(quote);
            var gq = new QuoteGraphDataPoint
            {
                Ask  = Convert.ToDecimal(quote.Ask),
                Bid  = Convert.ToDecimal(quote.Bid),
                Time = DateTime.Parse(quote.Datetime)
            };

            var ask = Convert.ToDouble(quote.Ask);
            var bid = Convert.ToDouble(quote.Bid);

            if (ask > _yAxisMax)
            {
                yAxisMax = ask;
            }
            if (ask < _yAxisMin)
            {
                yAxisMin = ask;
            }

            if (bid > _yAxisMax)
            {
                yAxisMax = bid;
            }
            if (bid < _yAxisMin)
            {
                yAxisMin = bid;
            }

            GraphQuotes.Add(gq);
        }
예제 #2
0
        private void LoadQuotes()
        {
            using (var db = DbFactory.GetDbSource())
            {
                Quotes = new ObservableCollection <Quote>(db.GetStreamQuotes(Ticker));

                foreach (var quote in Quotes)
                {
                    var gq = new QuoteGraphDataPoint
                    {
                        Ask  = Convert.ToDecimal(quote.Ask),
                        Bid  = Convert.ToDecimal(quote.Bid),
                        Time = DateTime.Parse(quote.Datetime)
                    };

                    GraphQuotes.Add(gq);

                    var ask = Convert.ToDouble(quote.Ask);
                    var bid = Convert.ToDouble(quote.Bid);

                    // TODO - make date checking generic to check within the selected date range
                    if (gq.Time >= _xAxisMin && gq.Time <= _xAxisMax)
                    {
                        if (ask > _yAxisMax)
                        {
                            _yAxisMax = ask;
                        }
                        if (ask < _yAxisMin)
                        {
                            _yAxisMin = ask;
                        }

                        if (bid > _yAxisMax)
                        {
                            _yAxisMax = bid;
                        }
                        if (bid < _yAxisMin)
                        {
                            _yAxisMin = bid;
                        }
                    }
                }

                Quotes.Clear();
            }
        }