Beispiel #1
0
        protected SeriesViewport(TSeries series, ClosedInterval <TTime> range)
        {
            myOriginalSeries = series;
            Series           = myOriginalSeries;

            ViewPort = range;
        }
Beispiel #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;
        }
Beispiel #3
0
        public bool Equals(ClosedInterval <T> other)
        {
            if (other == null)
            {
                return(false);
            }

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

            return(new PriceSeriesRange(series, interval));
        }
Beispiel #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)));
            }
        }
Beispiel #6
0
 public SeriesRange(ITimedValueSeries <TTime, TValue> series, ClosedInterval <int> interval)
     : this(series, interval.Min, interval.Max)
 {
 }
Beispiel #7
0
 protected abstract TSeries CreateSeriesRange(TSeries series, ClosedInterval <int> interval);
Beispiel #8
0
 public PriceSeriesRange(IPriceSeries series, ClosedInterval <int> interval)
     : this(series, interval.Min, interval.Max)
 {
 }
Beispiel #9
0
 public SignalSeriesRange(ISignalSeries series, ClosedInterval <int> interval)
     : this(series, interval.Min, interval.Max)
 {
 }
Beispiel #10
0
 public PriceSeriesViewport(IPriceSeries series, ClosedInterval <DateTime> range)
     : base(series, range)
 {
 }
Beispiel #11
0
 public SignalSeriesViewport(ISignalSeries series, ClosedInterval <DateTime> range)
     : base(series, range)
 {
 }