Esempio n. 1
0
        void UpdateYRange()
        {
            IEnumerable <QuoteRange> ranges = new QuoteRange[] { _quoteData.GetSymbolYRange(rs.LowerValue, rs.UpperValue, Binding) };

            if (_comparisonSymbols != null)
            {
                var cssRange = from cs in _comparisonSymbols where cs.Value.Visibility == SeriesVisibility.Visible select cs.Value.DataSource.GetSymbolYRange(rs.LowerValue, rs.UpperValue, Binding);

                ranges = ranges.Union(cssRange);
            }
            if (ranges.Any())
            {
                financialChart1.AxisX.Min = rs.LowerValue;
                financialChart1.AxisX.Max = rs.UpperValue;
                financialChart1.AxisY.Min = ranges.Min(p => p == null ? int.MaxValue : p.PriceMin);
                financialChart1.AxisY.Max = ranges.Max(p => p == null ? int.MinValue : p.PriceMax);
                if (ranges.First() != null)
                {
                    vs.AxisY.Min = ranges.First().VolumeMin;
                    vs.AxisY.Max = ranges.First().VolumeMax * 12;
                }
            }
        }
        public QuoteRange GetSymbolYRange(IEnumerable <Quote> quoteData, double s, double e, string porperty = null)
        {
            QuoteRange          qr         = null;
            DateTime            ds         = Utilities.FromOADate(s); //  DateTime.FromOADate(s);
            DateTime            de         = Utilities.FromOADate(e);
            IEnumerable <Quote> quoteCache = from p in quoteData where p.date >= ds && p.date <= de select p;

            if (quoteCache.Any())
            {
                qr          = new QuoteRange();
                qr.PriceMin = quoteCache.Min((k) =>
                {
                    if (string.IsNullOrEmpty(porperty) || porperty.ToUpper() == "high,low,open,close".ToUpper())
                    {
                        return(k.low);
                    }
                    else
                    {
                        return(k.GetValue(porperty));
                    }
                });
                qr.PriceMax = quoteCache.Max((k) =>
                {
                    if (string.IsNullOrEmpty(porperty) || porperty.ToUpper() == "high,low,open,close".ToUpper())
                    {
                        return(k.high);
                    }
                    else
                    {
                        return(k.GetValue(porperty));
                    }
                });
                qr.VolumeMin = quoteCache.Min(k => k.volume);
                qr.VolumeMax = quoteCache.Max(k => k.volume);
            }
            return(qr);
        }