Trading and Orders

Trading Calendar

Introduction

The TradingCalendar 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 GetTradingDay 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 GetTradingDay 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 GetTradingDays 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 GetDaysByType method.

var tradingDays = TradingCalendar.GetDaysByType(TradingDayType.OptionExpiration, startDate, endDate);
trading_days = self.TradingCalendar.GetDaysByType(TradingDayType.OptionExpiration, 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: