public GetDateTime ( int index ) : System.DateTime | ||
index | int | |
리턴 | System.DateTime |
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); }
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 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 Cross Crosses(TimeSeries series, DateTime dateTime) { var num = IndexOf(dateTime); var num2 = series.IndexOf(dateTime); if (num <= 0 || num >= this.series.Count) { return Cross.None; } if (num2 > 0 && num2 < series.Count) { DateTime dateTime2 = GetDateTime(num - 1); DateTime dateTime3 = series.GetDateTime(num2 - 1); if (dateTime2 == dateTime3) { if (this.GetValue(num - 1) <= series.GetValue(num2 - 1) && this.GetValue(num) > series.GetValue(num2)) { return Cross.Above; } if (this.GetValue(num - 1) >= series.GetValue(num2 - 1) && this.GetValue(num) < series.GetValue(num2)) { return Cross.Below; } } else { double value; double value2; if (dateTime2 < dateTime3) { DateTime dateTime4 = this.GetDateTime(num - 1); value = this.GetValue(num - 1); if (series.IndexOf(dateTime4, SearchOption.Next) != num2) { value2 = series.GetValue(series.IndexOf(dateTime4, SearchOption.Next)); } else { value2 = series.GetValue(series.IndexOf(dateTime4, SearchOption.Prev)); } } else { DateTime dateTime5 = series.GetDateTime(num2 - 1); value2 = series.GetValue(num2 - 1); if (this.IndexOf(dateTime5, SearchOption.Prev) != num) { value = this.GetValue(this.IndexOf(dateTime5, SearchOption.Next)); } else { value = this.GetValue(this.IndexOf(dateTime5, SearchOption.Prev)); } } if (value <= value2 && this.GetValue(num) > series.GetValue(num2)) { return Cross.Above; } if (value >= value2 && this.GetValue(num) < series.GetValue(num2)) { return Cross.Below; } } return Cross.None; } return Cross.None; }
public Cross Crosses(TimeSeries series, DateTime dateTime) { var num = IndexOf(dateTime); var num2 = series.IndexOf(dateTime); if (num <= 0 || num >= this.series.Count) { return(Cross.None); } if (num2 > 0 && num2 < series.Count) { DateTime dateTime2 = GetDateTime(num - 1); DateTime dateTime3 = series.GetDateTime(num2 - 1); if (dateTime2 == dateTime3) { if (this.GetValue(num - 1) <= series.GetValue(num2 - 1) && this.GetValue(num) > series.GetValue(num2)) { return(Cross.Above); } if (this.GetValue(num - 1) >= series.GetValue(num2 - 1) && this.GetValue(num) < series.GetValue(num2)) { return(Cross.Below); } } else { double value; double value2; if (dateTime2 < dateTime3) { DateTime dateTime4 = this.GetDateTime(num - 1); value = this.GetValue(num - 1); if (series.IndexOf(dateTime4, SearchOption.Next) != num2) { value2 = series.GetValue(series.IndexOf(dateTime4, SearchOption.Next)); } else { value2 = series.GetValue(series.IndexOf(dateTime4, SearchOption.Prev)); } } else { DateTime dateTime5 = series.GetDateTime(num2 - 1); value2 = series.GetValue(num2 - 1); if (this.IndexOf(dateTime5, SearchOption.Prev) != num) { value = this.GetValue(this.IndexOf(dateTime5, SearchOption.Next)); } else { value = this.GetValue(this.IndexOf(dateTime5, SearchOption.Prev)); } } if (value <= value2 && this.GetValue(num) > series.GetValue(num2)) { return(Cross.Above); } if (value >= value2 && this.GetValue(num) < series.GetValue(num2)) { return(Cross.Below); } } return(Cross.None); } return(Cross.None); }