Market and exchange trading calendars for pandas
Project description
Market calendars to use with pandas for trading applications.
Documentation
Overview
The Pandas package is widely used in finance and specifically for time series analysis. It includes excellent functionality for generating sequences of dates and capabilities for custom holiday calendars, but as an explicit design choice it does not include the actual holiday calendars for specific exchanges or OTC markets.
The pandas_market_calendars package looks to fill that role with the holiday, late open and early close calendars for specific exchanges and OTC conventions. pandas_market_calendars also adds several functions to manipulate the market calendars and includes a date_range function to create a pandas DatetimeIndex including only the datetimes when the markets are open.
This package is a fork of the Zipline package from Quantopian and extracts just the relevant parts. All credit for their excellent work to Quantopian.
Installation
pip install pandas_market_calendars
Arch Linux package available here: https://aur.archlinux.org/packages/python-pandas_market_calendars/
Quick Start
import pandas_market_calendars as mcal
nyse = mcal.get_calendar('NYSE')
early = nyse.schedule(start_date='2012-07-01', end_date='2012-07-10')
early
market_open market_close =========== ========================= ========================= 2012-07-02 2012-07-02 13:30:00+00:00 2012-07-02 20:00:00+00:00 2012-07-03 2012-07-03 13:30:00+00:00 2012-07-03 17:00:00+00:00 2012-07-05 2012-07-05 13:30:00+00:00 2012-07-05 20:00:00+00:00 2012-07-06 2012-07-06 13:30:00+00:00 2012-07-06 20:00:00+00:00 2012-07-09 2012-07-09 13:30:00+00:00 2012-07-09 20:00:00+00:00 2012-07-10 2012-07-10 13:30:00+00:00 2012-07-10 20:00:00+00:00
mcal.date_range(early, frequency='1D')
DatetimeIndex(['2012-07-02 20:00:00+00:00', '2012-07-03 17:00:00+00:00', '2012-07-05 20:00:00+00:00', '2012-07-06 20:00:00+00:00', '2012-07-09 20:00:00+00:00', '2012-07-10 20:00:00+00:00'], dtype='datetime64[ns, UTC]', freq=None)
mcal.date_range(early, frequency='1H')
DatetimeIndex(['2012-07-02 14:30:00+00:00', '2012-07-02 15:30:00+00:00', '2012-07-02 16:30:00+00:00', '2012-07-02 17:30:00+00:00', '2012-07-02 18:30:00+00:00', '2012-07-02 19:30:00+00:00', '2012-07-02 20:00:00+00:00', '2012-07-03 14:30:00+00:00', '2012-07-03 15:30:00+00:00', '2012-07-03 16:30:00+00:00', '2012-07-03 17:00:00+00:00', '2012-07-05 14:30:00+00:00', '2012-07-05 15:30:00+00:00', '2012-07-05 16:30:00+00:00', '2012-07-05 17:30:00+00:00', '2012-07-05 18:30:00+00:00', '2012-07-05 19:30:00+00:00', '2012-07-05 20:00:00+00:00', '2012-07-06 14:30:00+00:00', '2012-07-06 15:30:00+00:00', '2012-07-06 16:30:00+00:00', '2012-07-06 17:30:00+00:00', '2012-07-06 18:30:00+00:00', '2012-07-06 19:30:00+00:00', '2012-07-06 20:00:00+00:00', '2012-07-09 14:30:00+00:00', '2012-07-09 15:30:00+00:00', '2012-07-09 16:30:00+00:00', '2012-07-09 17:30:00+00:00', '2012-07-09 18:30:00+00:00', '2012-07-09 19:30:00+00:00', '2012-07-09 20:00:00+00:00', '2012-07-10 14:30:00+00:00', '2012-07-10 15:30:00+00:00', '2012-07-10 16:30:00+00:00', '2012-07-10 17:30:00+00:00', '2012-07-10 18:30:00+00:00', '2012-07-10 19:30:00+00:00', '2012-07-10 20:00:00+00:00'], dtype='datetime64[ns, UTC]', freq=None)
Future
This package is open sourced under the MIT license. Everyone is welcome to add more exchanges or OTC markets, confirm or correct the existing calendars, and generally do whatever they desire with this code.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pandas_market_calendars-0.15.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a5d62e447a4a971165a9b849875bb2e44fc46dfaf87321fa41b1d0ff2dc4171 |
|
MD5 | cc8d28ebd95158867c2879f2a5e1bbc8 |
|
BLAKE2b-256 | 4f597eb10c396dbc261625792aaef0b9ba5a2777929fb42557ce254c7aeef73e |
Hashes for pandas_market_calendars-0.15-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 558a2d0e5feb9f96119e5e8893e7aaac0011d1b7488387fe7ab0af7a9b95f6b5 |
|
MD5 | 379f3b846c5dae82cdc9013a0aeb051a |
|
BLAKE2b-256 | db6166f6c6a2118d9fb53deb82f6720028bea19484e58c130a3fc7ac56f832ae |