Building a Trading-Day Calendar in pandas with CustomBusinessDay
A tutorial explains that daily market-related data such as news and filings arrives on weekends and holidays, while prices exist only on trading days, causing misalignment. It introduces pandas' CustomBusinessDay, which uses a weekmask and holiday list to model exchange sessions. The example builds a trading calendar with a sample holiday block, showing 10 trading days versus 16 plain business days for three weeks. It also demonstrates date arithmetic and rollforward/rollback behavior for mapping non-trading-day items to the next session. The author notes that real projects should load official exchange holiday lists each year rather than hardcode dates.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in