Lean
$LEAN_TAG$
|
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... | |
Class to implement common functions used in FuturesExpiryFunctions
Definition at line 26 of file FuturesExpiryUtilityFunctions.cs.
|
static |
Get holiday list from the MHDB given the market and the symbol of the security
market | The market the exchange resides in, i.e, 'usa', 'fxcm', ect... |
symbol | The particular symbol being traded |
s
Definition at line 46 of file FuturesExpiryUtilityFunctions.cs.
|
static |
Method to retrieve n^th succeeding/preceding business day for a given day
time | The current Time |
n | Number of business days succeeding current time. Use negative value for preceding business days |
holidays | Set of holidays to exclude. These should be sourced from the MarketHoursDatabase |
Definition at line 61 of file FuturesExpiryUtilityFunctions.cs.
|
static |
Method to retrieve n^th succeeding/preceding business day for a given day if there was a holiday on that day
time | The current Time |
n | Number of business days succeeding current time. Use negative value for preceding business days |
holidayList | Enumerable of holidays to exclude. These should be sourced from the MarketHoursDatabase |
Definition at line 106 of file FuturesExpiryUtilityFunctions.cs.
|
static |
Method to retrieve the n^th last business day of the delivery month.
time | DateTime for delivery month |
n | Number of days |
holidayList | Holidays to use while calculating n^th business day. Useful for MHDB entries |
Definition at line 125 of file FuturesExpiryUtilityFunctions.cs.
|
static |
Calculates the n^th business day of the month (includes checking for holidays)
time | Month to calculate business day for |
nthBusinessDay | n^th business day to get |
holidayList | Holidays to not count as business days |
Definition at line 160 of file FuturesExpiryUtilityFunctions.cs.
|
static |
Method to retrieve the 2nd Friday of the given month
time | Date from the given month |
|
static |
Method to retrieve the 3rd Friday of the given month
time | Date from the given month |
|
static |
Method to retrieve the Nth Friday of the given month
time | Date from the given month |
n | The order of the Friday in the period |
|
static |
Method to retrieve third Wednesday of the given month (usually Monday).
time | Date from the given month |
|
static |
Method to retrieve the Nth Weekday of the given month
time | Date from the given month |
n | The order of the Weekday in the period |
dayOfWeek | The day of the week |
Definition at line 255 of file FuturesExpiryUtilityFunctions.cs.
|
static |
Method to retrieve the last weekday of any month
time | Date from the given month |
dayOfWeek | the last weekday to be found |
Definition at line 275 of file FuturesExpiryUtilityFunctions.cs.
|
static |
Method to retrieve the last Thursday of any month
time | Date from the given month |
|
static |
Method to retrieve the last Friday of any month
time | Date from the given month |
|
static |
Method to check whether a given time is holiday or not
time | The DateTime for consideration |
holidayList | Enumerable of holidays to exclude. These should be sourced from the MarketHoursDatabase |
Definition at line 304 of file FuturesExpiryUtilityFunctions.cs.
|
static |
This function takes Thursday as input and returns true if four weekdays preceding it are not Holidays
thursday | DateTime of a given Thursday |
holidayList | Enumerable of holidays to exclude. These should be sourced from the MarketHoursDatabase |
Definition at line 315 of file FuturesExpiryUtilityFunctions.cs.
|
static |
Gets the last trade date corresponding to the contract month
time | Contract month |
holidayList | Enumerable of holidays to exclude. These should be sourced from the MarketHoursDatabase |
lastTradeTime | Time at which the dairy future contract stops trading (usually should be on 17:10:00 UTC) |
Definition at line 345 of file FuturesExpiryUtilityFunctions.cs.
|
static |
Gets the number of months between the contract month and the expiry date.
underlying | The future symbol ticker |
futureExpiryDate | Expiry 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. |
Definition at line 377 of file FuturesExpiryUtilityFunctions.cs.
|
static |
Calculates the date of Good Friday for a given year.
year | Year to calculate Good Friday for |
Definition at line 401 of file FuturesExpiryUtilityFunctions.cs.