本文整理汇总了C#中TimeSeries.Add方法的典型用法代码示例。如果您正苦于以下问题:C# TimeSeries.Add方法的具体用法?C# TimeSeries.Add怎么用?C# TimeSeries.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeSeries
的用法示例。
在下文中一共展示了TimeSeries.Add方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestEMA
public void TestEMA()
{
long ticks = 1000;
var data = new double[] { 20, 40, 22, 35, 33, 78, 21, 45, 33, 5, 67, 22, 98, 22, 34, 54 };
var input = new TimeSeries();
var ema = new EMA(input, 10);
foreach (var d in data)
input.Add(new DateTime().AddTicks(ticks++), d);
for (var i = 0; i < ema.Count; i++)
output.WriteLine(ema[i].ToString());
Assert.Equal(ema[0], 20, precision);
Assert.Equal(ema[1], 23.6363636363636, precision);
Assert.Equal(ema[2], 23.3388429752066, precision);
Assert.Equal(ema[3], 25.4590533433509, precision);
Assert.Equal(ema[4], 26.8301345536507, precision);
Assert.Equal(ema[5], 36.1337464529869, precision);
Assert.Equal(ema[6], 33.3821561888075, precision);
Assert.Equal(ema[7], 35.4944914272061, precision);
Assert.Equal(ema[8], 35.0409475313505, precision);
Assert.Equal(ema[9], 29.5789570711049, precision);
Assert.Equal(ema[10], 36.3827830581768, precision);
Assert.Equal(ema[11], 33.7677315930537, precision);
Assert.Equal(ema[12], 45.4463258488621, precision);
Assert.Equal(ema[13], 41.1833575127054, precision);
Assert.Equal(ema[14], 39.8772925103953, precision);
Assert.Equal(ema[15], 42.4450575085053, precision);
}
示例2: addFixings
public void addFixings(List<Date> d, List<double> v, bool forceOverwrite) {
if ((d.Count != v.Count) || d.Count == 0)
throw new ArgumentException("Wrong collection dimensions when creating index fixings");
TimeSeries<double> t = new TimeSeries<double>();
for(int i=0; i<d.Count; i++)
t.Add(d[i], v[i]);
addFixings(t, forceOverwrite);
}
示例3: Estimate
public EstimationResult Estimate(IEnumerable<IDateValue> dateValues)
{
var series = new TimeSeries();
dateValues.ForEach(x => series.Add(x.Date, x.Value, true));
armaModel.SetInput(0, series, null);
armaModel.FitByMLE(200, 100, 0, null);
armaModel.ComputeResidualsAndOutputs();
var result = armaModel.GetOutput(3) as TimeSeries;
return EstimationResult.Create(result[0], this);
}
示例4: Value
public static double Value(ISeries input, int index, int length1, int length2)
{
if (index >= length1 - 1 && index >= length2 - 1)
{
TimeSeries timeSeries = new TimeSeries();
for (int i = index - Math.Max(length1, length2) + 1; i <= index; i++)
{
timeSeries.Add(input.GetDateTime(i), input[i, BarData.Volume]);
}
double num = SMA.Value(timeSeries, length1 - 1, length1, BarData.Close);
double num2 = SMA.Value(timeSeries, length2 - 1, length2, BarData.Close);
return num - num2;
}
return double.NaN;
}
示例5: TestWMA
public void TestWMA()
{
long ticks = 1000;
var data = new double[] { 20, 40, 22, 35, 33, 78, 21, 45, 33, 5, 67, 22, 98, 22, 34, 54 };
var input = new TimeSeries();
var wma = new WMA(input, 10);
foreach (var d in data)
input.Add(new DateTime().AddTicks(ticks++), d);
Assert.Equal(wma[0], 32.6, precision);
Assert.Equal(wma[1], 38.7454545454545, precision);
Assert.Equal(wma[2], 35.8545454545455, precision);
Assert.Equal(wma[3], 47.1090909090909, precision);
Assert.Equal(wma[4], 43.1636363636364, precision);
Assert.Equal(wma[5], 41.6363636363636, precision);
Assert.Equal(wma[6], 43.7272727272727, precision);
}
示例6: historySeriesMRO
public TimeSeries<string> historySeriesMRO(DateTime sDate, DateTime eDate)
{
TimeSeries<string> hist = new TimeSeries<string>();
TD_MRSTOCKFACTOR_Table_DAOManager dao_m = new TD_MRSTOCKFACTOR_Table_DAOManager();
dao_m.STOCK_ID_ = this.Code_;
dao_m.selectInterval(DataBaseConnectManager.ConnectionFactory("MRO"), sDate, eDate);
foreach (var item in dao_m.DAOList_)
{
string date = item.STD_DATE_;
int year = Convert.ToInt32(date.Substring(0, 4));
int month = Convert.ToInt32(date.Substring(4, 2));
int day = Convert.ToInt32(date.Substring(6, 2));
string value = item.CURR_PRICE_;
hist.Add(new Date(new DateTime(year, month, day)), value);
}
return hist;
}
示例7: historySeries
public TimeSeries<string> historySeries(DateTime sDate, DateTime eDate )
{
TimeSeries<string> hist = new TimeSeries<string>();
INDEX_DATA_Table_DAOManager dao_m = new INDEX_DATA_Table_DAOManager();
dao_m.INDEX_CODE_ = this.Code_;
dao_m.selectInterval(DataBaseConnectManager.ConnectionFactory("myDB"),sDate,eDate);
foreach (var item in dao_m.DAOList_)
{
string date = item.INDEX_DATE_;
int year = Convert.ToInt32(date.Substring(0, 4));
int month = Convert.ToInt32(date.Substring(4, 2));
int day = Convert.ToInt32(date.Substring(6, 2));
string value = item.INDEX_VALUE_;
hist.Add(new Date(new DateTime(year,month, day)), value);
}
return hist;
}
示例8: historyCurveSeriesMRO
public TimeSeries<string> historyCurveSeriesMRO(DateTime sDate, DateTime eDate)
{
TimeSeries<string> hist = new TimeSeries<string>();
IRCurveMarketDataLoader irCurveLoader = IRCurveMarketDataLoader.CreateMarketDataLoader("MRO");
ObservableCollection<Excel_irCurveDataViewModel> e_ircdvmList = new ObservableCollection<Excel_irCurveDataViewModel>();
irCurveLoader.loadInterval(sDate, eDate, this.LinkedCurveCode_, e_ircdvmList);
//TD_MRSTOCKFACTOR_Table_DAOManager dao_m = new TD_MRSTOCKFACTOR_Table_DAOManager();
//dao_m.STOCK_ID_ = this.Code_;
//dao_m.selectInterval(DataBaseConnectManager.ConnectionFactory("MRO"), sDate, eDate);
int tenorIndex = e_ircdvmList[0].getTenorIndex(this.Tenor_);
if (tenorIndex != -1)
{
foreach (var item in e_ircdvmList)
{
string value = item.Excel_rateDataViewModelList_[tenorIndex].Value_;
hist.Add(new Date(item.ReferenceDate_), value);
}
}
return hist;
}
示例9: Value
public static double Value(ISeries input, int index, int length, BarData barData = BarData.Close)
{
if (index >= 1)
{
TimeSeries timeSeries = new TimeSeries();
for (int i = 0; i <= index; i++)
{
timeSeries.Add(input.GetDateTime(i), input[i, barData]);
}
EMA input2 = new EMA(timeSeries, length, barData);
EMA input3 = new EMA(input2, length, barData);
EMA eMA = new EMA(input3, length, barData);
return (eMA[index] - eMA[index - 1]) / eMA[index - 1] * 100.0;
}
return double.NaN;
}
示例10: Value
public static double Value(ISeries input, int index, int length1, int length2)
{
if (index >= length2 - 1)
{
TimeSeries timeSeries = new TimeSeries();
for (int i = 0; i <= index; i++)
{
timeSeries.Add(input.GetDateTime(i), input[i, BarData.High] - input[i, BarData.Low]);
}
EMA eMA = new EMA(timeSeries, length1, BarData.Close);
return (eMA[index] - eMA[index - length2 + 1]) / eMA[index - length2 + 1] * 100.0;
}
return double.NaN;
}
示例11: Value
public static double Value(ISeries input, int index, int length, int order)
{
if (index >= length - 1)
{
TimeSeries timeSeries = new TimeSeries();
for (int i = 0; i <= index; i++)
{
timeSeries.Add(input.GetDateTime(i), input[i, BarData.High] - input[i, BarData.Low]);
}
EMA eMA = new EMA(timeSeries, order, BarData.Close);
EMA eMA2 = new EMA(eMA, order, BarData.Close);
double num = 0.0;
for (int j = index; j > index - length; j--)
{
num += eMA[j] / eMA2[j];
}
return num;
}
return double.NaN;
}