calendar

calendar

Exchange sessions, closures, and market-time operations.

Functions

Name Description
non_trading_days_after Count closed calendar dates after each exchange session.
schedule Return exchange sessions and their local opening and closing times.

non_trading_days_after

calendar.non_trading_days_after(dates, exchange)

Count closed calendar dates after each exchange session.

An early close is still a trading session. For example, a Friday early close followed by a Monday session has two non-trading days after it.

Parameters

Name Type Description Default
dates pd.Series Session dates. Time components are ignored and the index is preserved. required
exchange str ISO 10383 market identifier code, such as "XNYS" or "XSTO". required

Returns

Name Type Description
pd.Series Integer Series named non_trading_days_after.

Raises

Name Type Description
TypeError If dates is not a Series.
ValueError If the exchange is unknown or a value is missing or is not an exchange session.

schedule

calendar.schedule(start, end, exchange)

Return exchange sessions and their local opening and closing times.

Parameters

Name Type Description Default
start str | pd.Timestamp First calendar date to include. required
end str | pd.Timestamp Last calendar date to include. required
exchange str ISO 10383 market identifier code, such as "XNYS" or "XSTO". required

Returns

Name Type Description
pd.DataFrame DataFrame indexed by session date with timezone-aware open and
pd.DataFrame close columns expressed in the exchange’s local timezone.

Raises

Name Type Description
ValueError If the exchange is unknown, a date is missing, or start is after end.
Back to top