Trading Centres
Trading centres provide business day calendars for financial date calculations. A TradingCentre wraps a single holiday calendar. TradingCentres combines multiple centres for joint business day calculations.
Available centres
| Code | Description |
|---|---|
TGT |
TARGET (European Central Bank) |
LON |
London (United Kingdom) |
NY |
New York (United States) |
Functions
ccy.tradingcentres.centres
Return a TradingCentres instance for the given centre codes.
| PARAMETER | DESCRIPTION |
|---|---|
codes
|
Comma-separated trading centre codes, e.g. 'LON,NY'
TYPE:
|
Source code in ccy/tradingcentres/__init__.py
ccy.tradingcentres.nextbizday
Return the date nd business days after dte.
| PARAMETER | DESCRIPTION |
|---|---|
dte
|
The reference date
TYPE:
|
nd
|
Number of business days to move forward; 0 adjusts to next biz day
TYPE:
|
tcs
|
Comma-separated trading centre codes
TYPE:
|
Source code in ccy/tradingcentres/__init__.py
ccy.tradingcentres.prevbizday
Return the date nd business days before dte.
| PARAMETER | DESCRIPTION |
|---|---|
dte
|
The reference date
TYPE:
|
nd
|
Number of business days to move back
TYPE:
|
tcs
|
Comma-separated trading centre codes
TYPE:
|
Source code in ccy/tradingcentres/__init__.py
Classes
ccy.tradingcentres.TradingCentre
pydantic-model
Bases: BaseModel
Fields:
isholiday
ccy.tradingcentres.TradingCentres
pydantic-model
Bases: BaseModel
Fields:
-
centres(dict[str, TradingCentre])
isbizday
Return True if the date is a business day across all centres.
| PARAMETER | DESCRIPTION |
|---|---|
dte
|
The date to check
TYPE:
|
Source code in ccy/tradingcentres/__init__.py
nextbizday
Return the date nd business days after dte.
| PARAMETER | DESCRIPTION |
|---|---|
dte
|
The reference date
TYPE:
|
nd
|
Number of business days to move forward; 0 adjusts to next biz day
TYPE:
|
Source code in ccy/tradingcentres/__init__.py
prevbizday
Return the date nd business days before dte.
| PARAMETER | DESCRIPTION |
|---|---|
dte
|
The reference date
TYPE:
|
nd
|
Number of business days to move back
TYPE:
|
Source code in ccy/tradingcentres/__init__.py
Usage
Business day checks
from datetime import date
from ccy.tradingcentres import centres
tcs = centres("TGT")
tcs.isbizday(date(2024, 12, 25)) # False — Christmas
tcs.isbizday(date(2024, 12, 24)) # True
Combine multiple centres — a day is a business day only if it is in all of them:
tcs = centres("LON,NY")
tcs.code # "LON,NY"
tcs.isbizday(date(2024, 7, 4)) # False — US Independence Day
Next and previous business day
from ccy.tradingcentres import nextbizday, prevbizday
from datetime import date
friday = date(2024, 12, 20)
nextbizday(friday) # date(2024, 12, 23) — skips weekend
nextbizday(friday, nd=2) # date(2024, 12, 24)
prevbizday(friday) # date(2024, 12, 19)
prevbizday(friday, nd=3) # date(2024, 12, 17)
Pass a centre code to apply its holiday calendar:
nd=0 — adjust to business day
Passing nd=0 to nextbizday adjusts the date forward to the next business day if it falls on a weekend or holiday, and leaves it unchanged otherwise: