Lean  $LEAN_TAG$
QuantConnect.Securities.Future.FuturesExpiryUtilityFunctions Class Reference

Class to implement common functions used in FuturesExpiryFunctions More...

Static Public Member Functions

static HashSet< DateTime > GetHolidays (string market, string symbol)
 Get holiday list from the MHDB given the market and the symbol of the security More...
 
static DateTime AddBusinessDays (DateTime time, int n, HashSet< DateTime > holidays)
 Method to retrieve n^th succeeding/preceding business day for a given day More...
 
static DateTime AddBusinessDaysIfHoliday (DateTime time, int n, HashSet< DateTime > holidayList)
 Method to retrieve n^th succeeding/preceding business day for a given day if there was a holiday on that day More...
 
static DateTime NthLastBusinessDay (DateTime time, int n, IEnumerable< DateTime > holidayList)
 Method to retrieve the n^th last business day of the delivery month. More...
 
static DateTime NthBusinessDay (DateTime time, int nthBusinessDay, IEnumerable< DateTime > holidayList)
 Calculates the n^th business day of the month (includes checking for holidays) More...
 
static DateTime SecondFriday (DateTime time)
 Method to retrieve the 2nd Friday of the given month More...
 
static DateTime ThirdFriday (DateTime time)
 Method to retrieve the 3rd Friday of the given month More...
 
static DateTime NthFriday (DateTime time, int n)
 Method to retrieve the Nth Friday of the given month More...
 
static DateTime ThirdWednesday (DateTime time)
 Method to retrieve third Wednesday of the given month (usually Monday). More...
 
static DateTime NthWeekday (DateTime time, int n, DayOfWeek dayOfWeek)
 Method to retrieve the Nth Weekday of the given month More...
 
static DateTime LastWeekday (DateTime time, DayOfWeek dayOfWeek)
 Method to retrieve the last weekday of any month More...
 
static DateTime LastThursday (DateTime time)
 Method to retrieve the last Thursday of any month More...
 
static DateTime LastFriday (DateTime time)
 Method to retrieve the last Friday of any month More...
 
static bool NotHoliday (DateTime time, IEnumerable< DateTime > holidayList)
 Method to check whether a given time is holiday or not More...
 
static bool NotPrecededByHoliday (DateTime thursday, IEnumerable< DateTime > holidayList)
 This function takes Thursday as input and returns true if four weekdays preceding it are not Holidays More...
 
static DateTime DairyLastTradeDate (DateTime time, IEnumerable< DateTime > holidayList, TimeSpan? lastTradeTime=null)
 Gets the last trade date corresponding to the contract month More...
 
static int GetDeltaBetweenContractMonthAndContractExpiry (string underlying, DateTime? futureExpiryDate=null)
 Gets the number of months between the contract month and the expiry date. More...
 
static DateTime GetGoodFriday (int year)
 Calculates the date of Good Friday for a given year. More...
 

Detailed Description

Class to implement common functions used in FuturesExpiryFunctions

Definition at line 26 of file FuturesExpiryUtilityFunctions.cs.

Member Function Documentation

◆ GetHolidays()

static HashSet<DateTime> QuantConnect.Securities.Future.FuturesExpiryUtilityFunctions.GetHolidays ( string  market,
string  symbol 
)
static

Get holiday list from the MHDB given the market and the symbol of the security

Parameters
marketThe market the exchange resides in, i.e, 'usa', 'fxcm', ect...
symbolThe particular symbol being traded

s

Definition at line 46 of file FuturesExpiryUtilityFunctions.cs.

Here is the call graph for this function:

◆ AddBusinessDays()

static DateTime QuantConnect.Securities.Future.FuturesExpiryUtilityFunctions.AddBusinessDays ( DateTime  time,
int  n,
HashSet< DateTime >  holidays 
)
static

Method to retrieve n^th succeeding/preceding business day for a given day

Parameters
timeThe current Time
nNumber of business days succeeding current time. Use negative value for preceding business days
holidaysSet of holidays to exclude. These should be sourced from the MarketHoursDatabase
Returns
The date-time after adding n business days

Definition at line 61 of file FuturesExpiryUtilityFunctions.cs.

Here is the caller graph for this function:

◆ AddBusinessDaysIfHoliday()

static DateTime QuantConnect.Securities.Future.FuturesExpiryUtilityFunctions.AddBusinessDaysIfHoliday ( DateTime  time,
int  n,
HashSet< DateTime >  holidayList 
)
static

Method to retrieve n^th succeeding/preceding business day for a given day if there was a holiday on that day

Parameters
timeThe current Time
nNumber of business days succeeding current time. Use negative value for preceding business days
holidayListEnumerable of holidays to exclude. These should be sourced from the MarketHoursDatabase
Returns
The date-time after adding n business days

Definition at line 106 of file FuturesExpiryUtilityFunctions.cs.

Here is the call graph for this function:

◆ NthLastBusinessDay()

static DateTime QuantConnect.Securities.Future.FuturesExpiryUtilityFunctions.NthLastBusinessDay ( DateTime  time,
int  n,
IEnumerable< DateTime >  holidayList 
)
static

Method to retrieve the n^th last business day of the delivery month.

Parameters
timeDateTime for delivery month
nNumber of days
holidayListHolidays to use while calculating n^th business day. Useful for MHDB entries
Returns
Nth Last Business day of the month

Definition at line 125 of file FuturesExpiryUtilityFunctions.cs.

Here is the call graph for this function:

◆ NthBusinessDay()

static DateTime QuantConnect.Securities.Future.FuturesExpiryUtilityFunctions.NthBusinessDay ( DateTime  time,
int  nthBusinessDay,
IEnumerable< DateTime >  holidayList 
)
static

Calculates the n^th business day of the month (includes checking for holidays)

Parameters
timeMonth to calculate business day for
nthBusinessDayn^th business day to get
holidayListHolidays to not count as business days
Returns
Nth business day of the month

Definition at line 160 of file FuturesExpiryUtilityFunctions.cs.

Here is the call graph for this function:

◆ SecondFriday()

static DateTime QuantConnect.Securities.Future.FuturesExpiryUtilityFunctions.SecondFriday ( DateTime  time)
static

Method to retrieve the 2nd Friday of the given month

Parameters
timeDate from the given month
Returns
2nd Friday of given month

◆ ThirdFriday()

static DateTime QuantConnect.Securities.Future.FuturesExpiryUtilityFunctions.ThirdFriday ( DateTime  time)
static

Method to retrieve the 3rd Friday of the given month

Parameters
timeDate from the given month
Returns
3rd Friday of given month
Here is the caller graph for this function:

◆ NthFriday()

static DateTime QuantConnect.Securities.Future.FuturesExpiryUtilityFunctions.NthFriday ( DateTime  time,
int  n 
)
static

Method to retrieve the Nth Friday of the given month

Parameters
timeDate from the given month
nThe order of the Friday in the period
Returns
Nth Friday of given month

◆ ThirdWednesday()

static DateTime QuantConnect.Securities.Future.FuturesExpiryUtilityFunctions.ThirdWednesday ( DateTime  time)
static

Method to retrieve third Wednesday of the given month (usually Monday).

Parameters
timeDate from the given month
Returns
Third Wednesday of the given month

◆ NthWeekday()

static DateTime QuantConnect.Securities.Future.FuturesExpiryUtilityFunctions.NthWeekday ( DateTime  time,
int  n,
DayOfWeek  dayOfWeek 
)
static

Method to retrieve the Nth Weekday of the given month

Parameters
timeDate from the given month
nThe order of the Weekday in the period
dayOfWeekThe day of the week
Returns
Nth Weekday of given month

Definition at line 255 of file FuturesExpiryUtilityFunctions.cs.

◆ LastWeekday()

static DateTime QuantConnect.Securities.Future.FuturesExpiryUtilityFunctions.LastWeekday ( DateTime  time,
DayOfWeek  dayOfWeek 
)
static

Method to retrieve the last weekday of any month

Parameters
timeDate from the given month
dayOfWeekthe last weekday to be found
Returns
Last day of the we

Definition at line 275 of file FuturesExpiryUtilityFunctions.cs.

◆ LastThursday()

static DateTime QuantConnect.Securities.Future.FuturesExpiryUtilityFunctions.LastThursday ( DateTime  time)
static

Method to retrieve the last Thursday of any month

Parameters
timeDate from the given month
Returns
Last Thursday of the given month

◆ LastFriday()

static DateTime QuantConnect.Securities.Future.FuturesExpiryUtilityFunctions.LastFriday ( DateTime  time)
static

Method to retrieve the last Friday of any month

Parameters
timeDate from the given month
Returns
Last Friday of the given month

◆ NotHoliday()

static bool QuantConnect.Securities.Future.FuturesExpiryUtilityFunctions.NotHoliday ( DateTime  time,
IEnumerable< DateTime >  holidayList 
)
static

Method to check whether a given time is holiday or not

Parameters
timeThe DateTime for consideration
holidayListEnumerable of holidays to exclude. These should be sourced from the MarketHoursDatabase
Returns
True if the time is not a holidays, otherwise returns false

Definition at line 304 of file FuturesExpiryUtilityFunctions.cs.

Here is the caller graph for this function:

◆ NotPrecededByHoliday()

static bool QuantConnect.Securities.Future.FuturesExpiryUtilityFunctions.NotPrecededByHoliday ( DateTime  thursday,
IEnumerable< DateTime >  holidayList 
)
static

This function takes Thursday as input and returns true if four weekdays preceding it are not Holidays

Parameters
thursdayDateTime of a given Thursday
holidayListEnumerable of holidays to exclude. These should be sourced from the MarketHoursDatabase
Returns
False if DayOfWeek is not Thursday or is not preceded by four weekdays,Otherwise returns True

Definition at line 315 of file FuturesExpiryUtilityFunctions.cs.

Here is the call graph for this function:

◆ DairyLastTradeDate()

static DateTime QuantConnect.Securities.Future.FuturesExpiryUtilityFunctions.DairyLastTradeDate ( DateTime  time,
IEnumerable< DateTime >  holidayList,
TimeSpan?  lastTradeTime = null 
)
static

Gets the last trade date corresponding to the contract month

Parameters
timeContract month
holidayListEnumerable of holidays to exclude. These should be sourced from the MarketHoursDatabase
lastTradeTimeTime at which the dairy future contract stops trading (usually should be on 17:10:00 UTC)
Returns

Definition at line 345 of file FuturesExpiryUtilityFunctions.cs.

◆ GetDeltaBetweenContractMonthAndContractExpiry()

static int QuantConnect.Securities.Future.FuturesExpiryUtilityFunctions.GetDeltaBetweenContractMonthAndContractExpiry ( string  underlying,
DateTime?  futureExpiryDate = null 
)
static

Gets the number of months between the contract month and the expiry date.

Parameters
underlyingThe future symbol ticker
futureExpiryDateExpiry date to use to look up contract month delta. Only used for dairy, since we need to lookup its contract month in a pre-defined table.
Returns
The number of months between the contract month and the contract expiry

Definition at line 377 of file FuturesExpiryUtilityFunctions.cs.

Here is the caller graph for this function:

◆ GetGoodFriday()

static DateTime QuantConnect.Securities.Future.FuturesExpiryUtilityFunctions.GetGoodFriday ( int  year)
static

Calculates the date of Good Friday for a given year.

Parameters
yearYear to calculate Good Friday for
Returns
Date of Good Friday

Definition at line 401 of file FuturesExpiryUtilityFunctions.cs.


The documentation for this class was generated from the following file: