Esempio n. 1
0
        protected SeriesViewport(TSeries series, ClosedInterval <TTime> range)
        {
            myOriginalSeries = series;
            Series           = myOriginalSeries;

            ViewPort = range;
        }
Esempio n. 2
0
        private void SetRangeIndices(int from, int to)
        {
            if (!mySeries.Any())
            {
                myFrom = -1;
                myTo   = -1;
                Count  = 0;

                return;
            }

            var range = ClosedInterval.FromOffsetLength(0, mySeries.Count);

            if (!range.Includes(from))
            {
                throw new ArgumentOutOfRangeException("from", from + " is out of range");
            }
            if (!range.Includes(to))
            {
                throw new ArgumentOutOfRangeException("to", to + " is out of range");
            }

            myFrom = from;
            myTo   = to;

            Count = myTo - myFrom + 1;
        }
Esempio n. 3
0
        public bool Equals(ClosedInterval <T> other)
        {
            if (other == null)
            {
                return(false);
            }

            return(Min.Equals(other.Min) && Max.Equals(other.Max));
        }
Esempio n. 4
0
        protected override IPriceSeries CreateSeriesRange(IPriceSeries series, ClosedInterval <int> interval)
        {
            if (interval.IsEmpty)
            {
                return(PriceSeries.Null);
            }

            return(new PriceSeriesRange(series, interval));
        }
Esempio n. 5
0
        // optimized for performance
        private TSeries CreateSeriesRange()
        {
            if (myOriginalSeries.Count == 0)
            {
                return(Series);
            }

            int min = -1;
            int max = -1;

            // search from the end to begin because most of the viewport ranges start from the end
            for (int i = myOriginalSeries.Count - 1; i >= 0; --i)
            {
                var item = myOriginalSeries[i];

                if (item.Time.CompareTo(ViewPort.Max) > 0)
                {
                    // still outside range
                    continue;
                }

                if (item.Time.CompareTo(ViewPort.Min) < 0)
                {
                    // again outside range
                    break;
                }

                // overwrite till we are outside range again
                min = i;

                if (max == -1 && item.Time.CompareTo(ViewPort.Max) <= 0)
                {
                    // set to index of first time inside range
                    max = i;
                }
            }

            if (min < 0 || max < 0)
            {
                return(CreateSeriesRange(myOriginalSeries, new ClosedInterval <int>()));
            }
            else
            {
                return(CreateSeriesRange(myOriginalSeries, ClosedInterval.FromMinMax(min, max)));
            }
        }
Esempio n. 6
0
 public SeriesRange(ITimedValueSeries <TTime, TValue> series, ClosedInterval <int> interval)
     : this(series, interval.Min, interval.Max)
 {
 }
Esempio n. 7
0
 protected abstract TSeries CreateSeriesRange(TSeries series, ClosedInterval <int> interval);
Esempio n. 8
0
 public PriceSeriesRange(IPriceSeries series, ClosedInterval <int> interval)
     : this(series, interval.Min, interval.Max)
 {
 }
Esempio n. 9
0
 public SignalSeriesRange(ISignalSeries series, ClosedInterval <int> interval)
     : this(series, interval.Min, interval.Max)
 {
 }
Esempio n. 10
0
 public PriceSeriesViewport(IPriceSeries series, ClosedInterval <DateTime> range)
     : base(series, range)
 {
 }
Esempio n. 11
0
 public SignalSeriesViewport(ISignalSeries series, ClosedInterval <DateTime> range)
     : base(series, range)
 {
 }