Add GenerateFutureDates
This commit is contained in:
@@ -342,6 +342,30 @@ namespace MarketData.Utils
|
||||
}
|
||||
return histDates;
|
||||
}
|
||||
/// <summary>
|
||||
/// Generates dates into the future respecting weekens and market holidays
|
||||
/// </summary>
|
||||
/// <param name="startDate"></param>
|
||||
/// <param name="dayCount"></param>
|
||||
/// <returns></returns>
|
||||
public List<DateTime> GenerateFutureDates(DateTime startDate, int dayCount)
|
||||
{
|
||||
List<DateTime> futureDates=new List<DateTime>();
|
||||
DateTime futureDate;
|
||||
TimeSpan singleDay;
|
||||
|
||||
startDate = startDate.Date;
|
||||
futureDate=startDate;
|
||||
if(dayCount<0)singleDay=new TimeSpan(1,0,0,0);
|
||||
else singleDay=new TimeSpan(1,0,0,0);
|
||||
dayCount=dayCount<0?-dayCount:dayCount;
|
||||
while(futureDates.Count<dayCount)
|
||||
{
|
||||
if(IsMarketOpen(futureDate))futureDates.Add(futureDate);
|
||||
futureDate=futureDate.Add(singleDay);
|
||||
}
|
||||
return futureDates;
|
||||
}
|
||||
|
||||
public int TradingDaysBetween(DateTime startDate,DateTime endDate)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user