Add() public method

public Add ( System.DateTime dateTime, double value ) : void
dateTime System.DateTime
value double
return void
Esempio n. 1
0
        private TimeSeries MathTransform(string name, Func <double, double> func)
        {
            var ts = new TimeSeries(name, this.description, -1);

            for (int i = 0; i < Count; i++)
            {
                ts.Add(GetDateTime(i), func(this[i, 0]));
            }
            return(ts);
        }
Esempio n. 2
0
        private static TimeSeries OpTimeSeriesAndValue(TimeSeries series, double value, string name, Func <double, double, double> op, bool valueAsSecond = true, bool checkZero = false)
        {
            var ts = new TimeSeries(name, "", -1);

            for (int i = 0; i < series.Count; ++i)
            {
                var dt = series.GetDateTime(i);
                var sv = series[i, 0];
                if (valueAsSecond)
                {
                    ts.Add(dt, op(sv, value));
                }
                else
                {
                    if (!checkZero || sv != 0.0)
                    {
                        ts.Add(dt, op(value, sv));
                    }
                }
            }
            return(ts);
        }
Esempio n. 3
0
        public virtual TimeSeries GetNegativeSeries()
        {
            var ts = new TimeSeries();

            for (int i = 0; i < Count; i++)
            {
                if (this[i] < 0)
                {
                    ts.Add(GetDateTime(i), this[i]);
                }
            }
            return(ts);
        }
Esempio n. 4
0
        private static TimeSeries OpTwoTimeSeries(TimeSeries ts1, TimeSeries ts2, string name, Func <double, double, double> op, bool checkZero = false)
        {
            var ts = new TimeSeries(name, "", -1);

            for (int i = 0; i < ts1.Count; ++i)
            {
                var datetime = ts1.GetDateTime(i);
                if (ts2.Contains(datetime))
                {
                    var d2 = ts2[datetime, SearchOption.ExactFirst];
                    if (!checkZero || d2 != 0.0)
                    {
                        ts.Add(datetime, op(ts1[datetime, 0, SearchOption.ExactFirst], d2));
                    }
                }
            }
            return(ts);
        }
Esempio n. 5
0
        public virtual TimeSeries GetReturnSeries()
        {
            var ts = new TimeSeries(this.name, this.description + " (return)", -1);

            if (Count <= 1)
            {
                return(ts);
            }

            double p0 = this[0];

            for (var i = 0; i < Count; i++)
            {
                var p1 = this[i];
                ts.Add(GetDateTime(i), p0 != 0 ? p1 / p0 : 0);
                p0 = p1;
            }
            return(ts);
        }
Esempio n. 6
0
 private static TimeSeries OpTimeSeriesAndValue(TimeSeries series, double value, string name, Func<double, double, double> op, bool valueAsSecond = true, bool checkZero = false)
 {
     var ts = new TimeSeries(name, "", -1);
     for (int i = 0; i < series.Count; ++i)
     {
         var dt = series.GetDateTime(i);
         var sv = series[i, 0];
         if (valueAsSecond)
             ts.Add(dt, op(sv, value));
         else
         {
             if (!checkZero || sv != 0.0)
                 ts.Add(dt, op(value, sv));
         }
     }
     return ts;
 }
Esempio n. 7
0
 private static TimeSeries OpTwoTimeSeries(TimeSeries ts1, TimeSeries ts2, string name, Func<double, double, double> op, bool checkZero = false)
 {
     var ts = new TimeSeries(name, "", -1);
     for (int i = 0; i < ts1.Count; ++i)
     {
         var datetime = ts1.GetDateTime(i);
         if (ts2.Contains(datetime))
         {
             var d2 = ts2[datetime, SearchOption.ExactFirst];
             if (!checkZero || d2 != 0.0)
                 ts.Add(datetime, op(ts1[datetime, 0, SearchOption.ExactFirst], d2));
         }
     }
     return ts;
 }
Esempio n. 8
0
        public virtual TimeSeries GetReturnSeries()
        {
            var ts = new TimeSeries(this.name, this.description + " (return)", -1);
            if (Count <= 1)
                return ts;

            double p0 = this[0];
            for (var i = 0; i < Count; i++)
            {
                var p1 = this[i];
                ts.Add(GetDateTime(i), p0 != 0 ? p1/p0 : 0);
                p0 = p1;
            }
            return ts;
        }
Esempio n. 9
0
 public virtual TimeSeries GetNegativeSeries()
 {
     var ts = new TimeSeries();
     for (int i = 0; i < Count; i++)
         if (this[i] < 0)
             ts.Add(GetDateTime(i), this[i]);
     return ts;
 }
Esempio n. 10
0
 private TimeSeries MathTransform(string name, Func<double, double> func)
 {
     var ts = new TimeSeries(name, this.description, -1);
     for (int i = 0; i < Count; i++)
         ts.Add(GetDateTime(i), func(this[i, 0]));
     return ts;
 }