Class BespokeCalendar
Bespoke calendar.
public sealed class BespokeCalendar : Calendar, IEquatable<Calendar>
- Inheritance
-
BespokeCalendar
- Implements
- Inherited Members
Remarks
This calendar has no predefined set of business days. Holidays and weekend days are defined by means of the provided interface: AddWeekend(Weekday), AddHoliday(Date) and RemoveHoliday(Date), each returning a modified copy. In QuantLib, copies of a bespoke calendar stay linked to the original, and an edit changes them all.
Two bespoke calendars are equal when they have the same name, the same weekend, the same added holidays that fall
on a working weekday, and the same removed holidays; QuantLib compares their names alone, so that "different
bespoke calendars created with the same name (or different bespoke calendars created with no name) will compare as
equal" (bespokecalendar.hpp:55-58). A holiday added before its weekday became a weekend day stays in
AddedHolidays, as QuantLib records it, but doesn't count: the calendar equals one rebuilt
with its weekend first and its holidays after, whatever the order of the edits.
Constructors
BespokeCalendar(string)
Initializes a new instance of the BespokeCalendar class with no weekend and no holidays.
public BespokeCalendar(string name = "")
Parameters
namestringThe calendar's name.
Exceptions
- ArgumentNullException
nameis null.
Properties
Name
Gets the calendar's name, used for output and comparison; not meant for switch-on-type code.
public override string Name { get; }
Property Value
Methods
AddWeekend(Weekday)
A copy of the calendar with the weekday marked as part of the weekend.
public BespokeCalendar AddWeekend(Weekday w)
Parameters
wWeekdayThe weekday.
Returns
- BespokeCalendar
The modified copy; the receiver is unchanged.
Exceptions
- ArgumentOutOfRangeException
The weekday isn't a member of the enum.
Equals(Calendar?)
Whether the calendar equals another: a bespoke calendar with the same name, weekend, added holidays on working weekdays and removed holidays.
public override bool Equals(Calendar? other)
Parameters
otherCalendarThe other calendar.
Returns
GetHashCode()
public override int GetHashCode()
Returns
IsBusinessDayCore(Date)
Whether the date is a business day by the calendar's own rules, before added and removed holidays.
protected override bool IsBusinessDayCore(Date date)
Parameters
dateDate
Returns
IsWeekend(Weekday)
Whether the weekday is part of the weekend for the given market.
public override bool IsWeekend(Weekday w)
Parameters
wWeekdayThe weekday.