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); }
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); }
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); }
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); }
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); }
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; }
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; }
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; }
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; }
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; }