本文整理汇总了C#中QuantConnect.Data.BaseData.Last方法的典型用法代码示例。如果您正苦于以下问题:C# BaseData.Last方法的具体用法?C# BaseData.Last怎么用?C# BaseData.Last使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QuantConnect.Data.BaseData
的用法示例。
在下文中一共展示了BaseData.Last方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FillForwardHoursAtEndOfDayByHalfHour
public void FillForwardHoursAtEndOfDayByHalfHour()
{
var dataResolution = Time.OneHour;
var reference = new DateTime(2015, 6, 25, 14, 0, 0);
var data = new BaseData[]
{
// thurs 6/25
new TradeBar{Value = 0, Time = reference, Period = dataResolution},
// fri 6/26
new TradeBar{Value = 1, Time = reference.Date.AddDays(1), Period = dataResolution},
}.ToList();
var enumerator = data.GetEnumerator();
var exchange = new EquityExchange();
bool isExtendedMarketHours = false;
var ffResolution = TimeSpan.FromMinutes(30);
var fillForwardEnumerator = new FillForwardEnumerator(enumerator, exchange, ffResolution, isExtendedMarketHours, data.Last().EndTime, dataResolution);
// 3:00
Assert.IsTrue(fillForwardEnumerator.MoveNext());
Assert.AreEqual(reference.AddHours(1), fillForwardEnumerator.Current.EndTime);
Assert.AreEqual(0, fillForwardEnumerator.Current.Value);
Assert.IsFalse(fillForwardEnumerator.Current.IsFillForward);
// 3:30
Assert.IsTrue(fillForwardEnumerator.MoveNext());
Assert.AreEqual(reference.AddHours(1.5), fillForwardEnumerator.Current.EndTime);
Assert.AreEqual(0, fillForwardEnumerator.Current.Value);
Assert.IsTrue(fillForwardEnumerator.Current.IsFillForward);
// 4:00
Assert.IsTrue(fillForwardEnumerator.MoveNext());
Assert.AreEqual(reference.AddHours(2), fillForwardEnumerator.Current.EndTime);
Assert.AreEqual(0, fillForwardEnumerator.Current.Value);
Assert.IsTrue(fillForwardEnumerator.Current.IsFillForward);
// 12:00am
Assert.IsTrue(fillForwardEnumerator.MoveNext());
Assert.AreEqual(data.Last().EndTime, fillForwardEnumerator.Current.EndTime);
Assert.AreEqual(1, fillForwardEnumerator.Current.Value);
Assert.IsFalse(fillForwardEnumerator.Current.IsFillForward);
Assert.IsFalse(fillForwardEnumerator.MoveNext());
}
示例2: FillsForwardDailyMissingDays
public void FillsForwardDailyMissingDays()
{
var dataResolution = Time.OneDay;
var reference = new DateTime(2015, 6, 25);
var data = new BaseData[]
{
// thurs 6/25
new TradeBar{Value = 0, Time = reference, Period = Time.OneDay},
// fri 6/26
new TradeBar{Value = 1, Time = reference.AddDays(5), Period = Time.OneDay},
}.ToList();
var enumerator = data.GetEnumerator();
var exchange = new EquityExchange();
bool isExtendedMarketHours = false;
var fillForwardEnumerator = new FillForwardEnumerator(enumerator, exchange, TimeSpan.FromDays(1), isExtendedMarketHours, data.Last().EndTime.AddDays(1), dataResolution);
// 6/25
Assert.IsTrue(fillForwardEnumerator.MoveNext());
Assert.AreEqual(reference.AddDays(1), fillForwardEnumerator.Current.EndTime);
Assert.AreEqual(0, fillForwardEnumerator.Current.Value);
Assert.IsFalse(fillForwardEnumerator.Current.IsFillForward);
Assert.IsTrue(((TradeBar)fillForwardEnumerator.Current).Period == dataResolution);
// 6/26
Assert.IsTrue(fillForwardEnumerator.MoveNext());
Assert.AreEqual(reference.AddDays(2), fillForwardEnumerator.Current.EndTime);
Assert.AreEqual(0, fillForwardEnumerator.Current.Value);
Assert.IsTrue(fillForwardEnumerator.Current.IsFillForward);
Assert.IsTrue(((TradeBar)fillForwardEnumerator.Current).Period == dataResolution);
// 6/29
Assert.IsTrue(fillForwardEnumerator.MoveNext());
Assert.AreEqual(reference.AddDays(5), fillForwardEnumerator.Current.EndTime);
Assert.AreEqual(0, fillForwardEnumerator.Current.Value);
Assert.IsTrue(fillForwardEnumerator.Current.IsFillForward);
Assert.IsTrue(((TradeBar)fillForwardEnumerator.Current).Period == dataResolution);
// 6/30
Assert.IsTrue(fillForwardEnumerator.MoveNext());
Assert.AreEqual(reference.AddDays(6), fillForwardEnumerator.Current.EndTime);
Assert.AreEqual(1, fillForwardEnumerator.Current.Value);
Assert.IsFalse(fillForwardEnumerator.Current.IsFillForward);
Assert.IsTrue(((TradeBar)fillForwardEnumerator.Current).Period == dataResolution);
// 7/1
Assert.IsTrue(fillForwardEnumerator.MoveNext());
Assert.AreEqual(reference.AddDays(7), fillForwardEnumerator.Current.EndTime);
Assert.AreEqual(1, fillForwardEnumerator.Current.Value);
Assert.IsTrue(fillForwardEnumerator.Current.IsFillForward);
Assert.IsTrue(((TradeBar)fillForwardEnumerator.Current).Period == dataResolution);
Assert.IsFalse(fillForwardEnumerator.MoveNext());
}
示例3: FillsForwardMissingDaysOnFillForwardResolutionOfAnHour
public void FillsForwardMissingDaysOnFillForwardResolutionOfAnHour()
{
var dataResolution = Time.OneDay;
var reference = new DateTime(2015, 6, 23);
var data = new BaseData[]
{
// tues 6/23
new TradeBar{Value = 0, Time = reference, Period = dataResolution},
// wed 7/1
new TradeBar{Value = 1, Time = reference.AddDays(8), Period = dataResolution},
}.ToList();
var enumerator = data.GetEnumerator();
var exchange = new EquityExchange();
bool isExtendedMarketHours = false;
var ffResolution = TimeSpan.FromHours(1);
var fillForwardEnumerator = new FillForwardEnumerator(enumerator, exchange, ffResolution, isExtendedMarketHours, data.Last().EndTime, dataResolution);
int dailyBars = 0;
int hourlyBars = 0;
while (fillForwardEnumerator.MoveNext())
{
Console.WriteLine(fillForwardEnumerator.Current.EndTime);
if (fillForwardEnumerator.Current.Time.TimeOfDay == TimeSpan.Zero)
{
dailyBars++;
}
else
{
hourlyBars++;
}
}
// we expect 7 daily bars here, beginning tues, wed, thurs, fri, mon, tues, wed
Assert.AreEqual(7, dailyBars);
// we expect 6 days worth of ff hourly bars at 7 bars a day
Assert.AreEqual(42, hourlyBars);
}
示例4: FillsForwardHourlyOnMinutesBeginningOfDay
public void FillsForwardHourlyOnMinutesBeginningOfDay()
{
var dataResolution = Time.OneHour;
var reference = new DateTime(2015, 6, 25);
var data = new BaseData[]
{
// thurs 6/25
new TradeBar{Value = 0, Time = reference, Period = dataResolution},
// fri 6/26
new TradeBar{Value = 1, Time = reference.Date.AddHours(9), Period = dataResolution},
}.ToList();
var enumerator = data.GetEnumerator();
var exchange = new EquityExchange();
bool isExtendedMarketHours = false;
var ffResolution = TimeSpan.FromMinutes(15);
var fillForwardEnumerator = new FillForwardEnumerator(enumerator, exchange, ffResolution, isExtendedMarketHours, data.Last().EndTime, dataResolution);
// 12:00
Assert.IsTrue(fillForwardEnumerator.MoveNext());
Assert.AreEqual(reference.AddHours(1), fillForwardEnumerator.Current.EndTime);
Assert.AreEqual(0, fillForwardEnumerator.Current.Value);
Assert.IsFalse(fillForwardEnumerator.Current.IsFillForward);
// 9:45 (ff)
Assert.IsTrue(fillForwardEnumerator.MoveNext());
Assert.AreEqual(reference.AddHours(9.75), fillForwardEnumerator.Current.EndTime);
Assert.AreEqual(0, fillForwardEnumerator.Current.Value);
Assert.IsTrue(fillForwardEnumerator.Current.IsFillForward);
// 10:00
Assert.IsTrue(fillForwardEnumerator.MoveNext());
Assert.AreEqual(reference.AddHours(10), fillForwardEnumerator.Current.EndTime);
Assert.AreEqual(1, fillForwardEnumerator.Current.Value);
Assert.IsFalse(fillForwardEnumerator.Current.IsFillForward);
Assert.IsFalse(fillForwardEnumerator.MoveNext());
}
示例5: FillsForwardDailyOnHoursInMarketHours
public void FillsForwardDailyOnHoursInMarketHours()
{
var dataResolution = Time.OneDay;
var reference = new DateTime(2015, 6, 25);
var data = new BaseData[]
{
// thurs 6/25
new TradeBar{Value = 0, Time = reference, Period = Time.OneDay},
// fri 6/26
new TradeBar{Value = 1, Time = reference.AddDays(1), Period = Time.OneDay},
}.ToList();
var enumerator = data.GetEnumerator();
var exchange = new EquityExchange();
bool isExtendedMarketHours = false;
var fillForwardEnumerator = new FillForwardEnumerator(enumerator, exchange, TimeSpan.FromHours(1), isExtendedMarketHours, data.Last().EndTime, dataResolution);
// 12:00am
Assert.IsTrue(fillForwardEnumerator.MoveNext());
Assert.AreEqual(reference.AddDays(1), fillForwardEnumerator.Current.EndTime);
Assert.AreEqual(0, fillForwardEnumerator.Current.Value);
Assert.IsFalse(fillForwardEnumerator.Current.IsFillForward);
Assert.AreEqual(dataResolution, fillForwardEnumerator.Current.EndTime - fillForwardEnumerator.Current.Time);
// 10:00 (ff)
Assert.IsTrue(fillForwardEnumerator.MoveNext());
Assert.AreEqual(reference.AddDays(1).AddHours(10), fillForwardEnumerator.Current.EndTime);
Assert.AreEqual(0, fillForwardEnumerator.Current.Value);
Assert.IsTrue(fillForwardEnumerator.Current.IsFillForward);
Assert.AreEqual(dataResolution, fillForwardEnumerator.Current.EndTime - fillForwardEnumerator.Current.Time);
// 11:00 (ff)
Assert.IsTrue(fillForwardEnumerator.MoveNext());
Assert.AreEqual(reference.AddDays(1).AddHours(11), fillForwardEnumerator.Current.EndTime);
Assert.AreEqual(0, fillForwardEnumerator.Current.Value);
Assert.IsTrue(fillForwardEnumerator.Current.IsFillForward);
Assert.AreEqual(dataResolution, fillForwardEnumerator.Current.EndTime - fillForwardEnumerator.Current.Time);
// 12:00pm (ff)
Assert.IsTrue(fillForwardEnumerator.MoveNext());
Assert.AreEqual(reference.AddDays(1).AddHours(12), fillForwardEnumerator.Current.EndTime);
Assert.AreEqual(0, fillForwardEnumerator.Current.Value);
Assert.IsTrue(fillForwardEnumerator.Current.IsFillForward);
Assert.AreEqual(dataResolution, fillForwardEnumerator.Current.EndTime - fillForwardEnumerator.Current.Time);
// 1:00 (ff)
Assert.IsTrue(fillForwardEnumerator.MoveNext());
Assert.AreEqual(reference.AddDays(1).AddHours(13), fillForwardEnumerator.Current.EndTime);
Assert.AreEqual(0, fillForwardEnumerator.Current.Value);
Assert.IsTrue(fillForwardEnumerator.Current.IsFillForward);
Assert.AreEqual(dataResolution, fillForwardEnumerator.Current.EndTime - fillForwardEnumerator.Current.Time);
// 2:00 (ff)
Assert.IsTrue(fillForwardEnumerator.MoveNext());
Assert.AreEqual(reference.AddDays(1).AddHours(14), fillForwardEnumerator.Current.EndTime);
Assert.AreEqual(0, fillForwardEnumerator.Current.Value);
Assert.IsTrue(fillForwardEnumerator.Current.IsFillForward);
Assert.AreEqual(dataResolution, fillForwardEnumerator.Current.EndTime - fillForwardEnumerator.Current.Time);
// 3:00 (ff)
Assert.IsTrue(fillForwardEnumerator.MoveNext());
Assert.AreEqual(reference.AddDays(1).AddHours(15), fillForwardEnumerator.Current.EndTime);
Assert.AreEqual(0, fillForwardEnumerator.Current.Value);
Assert.IsTrue(fillForwardEnumerator.Current.IsFillForward);
Assert.AreEqual(dataResolution, fillForwardEnumerator.Current.EndTime - fillForwardEnumerator.Current.Time);
// 4:00 (ff)
Assert.IsTrue(fillForwardEnumerator.MoveNext());
Assert.AreEqual(reference.AddDays(1).AddHours(16), fillForwardEnumerator.Current.EndTime);
Assert.AreEqual(0, fillForwardEnumerator.Current.Value);
Assert.IsTrue(fillForwardEnumerator.Current.IsFillForward);
Assert.AreEqual(dataResolution, fillForwardEnumerator.Current.EndTime - fillForwardEnumerator.Current.Time);
// 12:00am
Assert.IsTrue(fillForwardEnumerator.MoveNext());
Assert.AreEqual(reference.AddDays(2), fillForwardEnumerator.Current.EndTime);
Assert.AreEqual(1, fillForwardEnumerator.Current.Value);
Assert.IsFalse(fillForwardEnumerator.Current.IsFillForward);
Assert.AreEqual(dataResolution, fillForwardEnumerator.Current.EndTime - fillForwardEnumerator.Current.Time);
Assert.IsFalse(fillForwardEnumerator.MoveNext());
}