book
Checkout our new book! Hands on AI Trading with Python, QuantConnect, and AWS Learn More arrow

Trading and Orders

Trading Calendar

Introduction

The trading_calendar contains a variety of events relevant to the assets in your algorithm.

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 get_trading_day method with no arguments.

Select Language:
trading_day = self.trading_calendar.get_trading_day()

To get the trading events of a specific day, pass a datetime object to the get_trading_day method.

Select Language:
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 datetime objects to the get_trading_days method.

Select Language:
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 get_days_by_type method.

Select Language:
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: