Trading and Orders

Trading Calendar


The TradingCalendartrading_calendar contains a variety of events relevant to the assets in your algorithm. We source the event data from Quantlib.

Trading Day Properties

TradingDay objects represent the trading events of a single day. They have the following properties:

Get a Single Trading Day

To get the trading events of the current day, call the GetTradingDayget_trading_day method with no arguments.

var tradingDay = TradingCalendar.GetTradingDay();
trading_day = self.trading_calendar.get_trading_day()

To get the trading events of a specific day, pass a DateTimedatetime object to the GetTradingDayget_trading_day method.

var tradingDay = TradingCalendar.GetTradingDay(new DateTime(2022, 6, 1));
trading_day = self.trading_calendar.get_trading_day(datetime(2022, 6, 1))

Get Trading Days

To get all the trading events across a range of dates, pass start and end DateTimedatetime objects to the GetTradingDaysget_trading_days method.

var startDate = new DateTime(2022, 6, 1);
var endDate = new DateTime(2022, 7, 1);
var tradingDays = TradingCalendar.GetTradingDays(startDate, endDate);
start_date = datetime(2022, 6, 1)
end_date = datetime(2022, 7, 1)
trading_days = self.trading_calendar.get_trading_days(start_date, end_date)

To get specific trading events across a range of dates, pass a TradingDayType enumeration member and the dates to the GetDaysByTypeget_days_by_type method.

var tradingDays = TradingCalendar.GetDaysByType(TradingDayType.OptionExpiration, startDate, endDate);
trading_days = self.TradingCalendar.get_days_by_type(TradingDayType.OPTION_EXPIRATION, start_date, end_date)

The TradingDayType enumeration has the following members:

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: