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 = TradingCalendar.GetTradingDay()

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 = TradingCalendar.GetTradingDay(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 GetTradingDay method.

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

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

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