本文整理汇总了C#中FreeQuant.Series.TimeSeries.GetDateTime方法的典型用法代码示例。如果您正苦于以下问题:C# TimeSeries.GetDateTime方法的具体用法?C# TimeSeries.GetDateTime怎么用?C# TimeSeries.GetDateTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FreeQuant.Series.TimeSeries
的用法示例。
在下文中一共展示了TimeSeries.GetDateTime方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Crosses
public ECross Crosses(TimeSeries series, DateTime datetime, int row = 0)
{
int index1 = this.GetIndex(datetime);
int index2 = series.GetIndex(datetime);
if (index1 <= 0 || index1 >= this.Count || index2 <= 0 || index2 >= series.Count)
{
return ECross.None;
}
DateTime dt1 = this.GetDateTime(index1 - 1);
DateTime dt2 = series.GetDateTime(index2 - 1);
if (dt1 == dt2)
{
if (this[index1-1, row] <= series[index2 - 1, row] && this[index1, row] > series[index2, row])
return ECross.Above;
if (this[index1-1, row] >= series[index2 - 1, row] && this[index1, row] < series[index2, row])
return ECross.Below;
}
else
{
double num1;
double num2;
if (dt1 < dt2)
{
DateTime dateTime3 = this.GetDateTime(index1 - 1);
num1 = this[index1 - 1, row];
num2 = series.GetIndex(dateTime3, EIndexOption.Next) == index2 ? series[series.GetIndex(dateTime3, EIndexOption.Prev), row] : series[series.GetIndex(dateTime3, EIndexOption.Next), row];
}
else
{
DateTime dateTime3 = series.GetDateTime(index2 - 1);
num2 = series[index2 - 1, row];
num1 = this.GetIndex(dateTime3, EIndexOption.Next) == index1 ? this[this.GetIndex(dateTime3, EIndexOption.Prev), row] : this[this.GetIndex(dateTime3, EIndexOption.Next), row];
}
if (num1 <= num2 && this[index1, row] > series[index2, row])
return ECross.Above;
if (num1 >= num2 && this[index1, row] < series[index2, row])
return ECross.Below;
}
return ECross.None;
}
示例2: Value
public static double Value(TimeSeries input, int index, int length1, int length2)
{
if (index < length2 - 1 + input.FirstIndex)
return double.NaN;
DoubleSeries doubleSeries = new DoubleSeries();
for (int index1 = 0; index1 <= index; ++index1)
doubleSeries.Add(input.GetDateTime(index1), input[index1, BarData.High] - input[index1, BarData.Low]);
EMA ema = new EMA((TimeSeries) doubleSeries, length1, BarData.Close);
return (ema[index] - ema[index - length2 + 1]) / ema[index - length2 + 1] * 100.0;
}
示例3: Value
public static double Value(TimeSeries input, int index, int length, BarData option, RegressionDistanceMode distanceMode)
{
if (index < length - 1)
return double.NaN;
double x = 0.0;
double num1 = 0.0;
double num2 = 0.0;
double num3 = 0.0;
if (distanceMode == RegressionDistanceMode.Time)
{
double num4 = (double) input.GetDateTime(index).Subtract(input.GetDateTime(index - 1)).Ticks;
for (int index1 = index; index1 > index - length; --index1)
{
x += (double) input.GetDateTime(index1).Subtract(input.GetDateTime(index - length + 1)).Ticks / num4;
num1 += (double) input.GetDateTime(index1).Subtract(input.GetDateTime(index - length + 1)).Ticks / num4 * input[index1, option];
num2 += input[index1, option];
num3 += (double) input.GetDateTime(index1).Subtract(input.GetDateTime(index - length + 1)).Ticks / num4 * (double) input.GetDateTime(index1).Subtract(input.GetDateTime(index - length + 1)).Ticks / num4;
}
}
else
{
for (int index1 = index; index1 > index - length; --index1)
{
x += (double) (index1 - index + length - 1);
num1 += (double) (index1 - index + length - 1) * input[index1, option];
num2 += input[index1, option];
num3 += (double) ((index1 - index + length - 1) * (index1 - index + length - 1));
}
}
return ((double) length * num1 - x * num2) / ((double) length * num3 - Math.Pow(x, 2.0));
}
示例4: Value
public static double Value(TimeSeries input, int index, int length, BarData option)
{
if (index < 1 + input.FirstIndex)
return double.NaN;
DoubleSeries doubleSeries = new DoubleSeries();
for (int firstIndex = input.FirstIndex; firstIndex <= index; ++firstIndex)
doubleSeries.Add(input.GetDateTime(firstIndex), input[firstIndex, option]);
EMA ema = new EMA((TimeSeries) new EMA((TimeSeries) new EMA((TimeSeries) doubleSeries, length, option), length, option), length, option);
return (ema[index - input.FirstIndex] - ema[index - 1 - input.FirstIndex]) / ema[index - 1 - input.FirstIndex] * 100.0;
}
示例5: Value
public static double Value(TimeSeries input, int index, int length1, int length2)
{
if (index < length1 - 1 + input.FirstIndex || index < length2 - 1 + input.FirstIndex)
return double.NaN;
DoubleSeries doubleSeries = new DoubleSeries();
for (int index1 = index; index1 > index - Math.Max(length1, length2); --index1)
doubleSeries.Add(input.GetDateTime(index1), input[index1, BarData.Volume]);
return SMA.Value((TimeSeries) doubleSeries, length1 - 1, length1, BarData.Close) - SMA.Value((TimeSeries) doubleSeries, length2 - 1, length2, BarData.Close);
}
示例6: Value
public static double Value(TimeSeries input, int index, int length, int order)
{
if (index < length - 1 + input.FirstIndex)
return double.NaN;
DoubleSeries doubleSeries = new DoubleSeries();
double num = 0.0;
for (int index1 = 0; index1 <= index; ++index1)
doubleSeries.Add(input.GetDateTime(index1), input[index1, BarData.High] - input[index1, BarData.Low]);
EMA ema1 = new EMA((TimeSeries) doubleSeries, order, BarData.Close);
EMA ema2 = new EMA((TimeSeries) ema1, order, BarData.Close);
for (int index1 = index; index1 > index - length; --index1)
num += ema1[index1] / ema2[index1];
return num;
}