{"id":13699949,"url":"https://github.com/quantopian/trading_calendars","last_synced_at":"2025-05-15T04:08:06.800Z","repository":{"id":37390506,"uuid":"137123375","full_name":"quantopian/trading_calendars","owner":"quantopian","description":"Calendars for various securities exchanges.","archived":false,"fork":false,"pushed_at":"2023-07-17T00:25:53.000Z","size":4354,"stargazers_count":636,"open_issues_count":33,"forks_count":396,"subscribers_count":34,"default_branch":"master","last_synced_at":"2025-04-14T06:49:33.568Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/quantopian.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-06-12T20:20:33.000Z","updated_at":"2025-04-05T13:46:48.000Z","dependencies_parsed_at":"2024-01-14T19:14:36.899Z","dependency_job_id":"d907abac-e7cd-47c1-8e18-85b26b96a4be","html_url":"https://github.com/quantopian/trading_calendars","commit_stats":{"total_commits":379,"total_committers":56,"mean_commits":6.767857142857143,"dds":0.8944591029023746,"last_synced_commit":"19c4b677f13147928d34be5a3da50ba4161be45d"},"previous_names":[],"tags_count":37,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quantopian%2Ftrading_calendars","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quantopian%2Ftrading_calendars/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quantopian%2Ftrading_calendars/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quantopian%2Ftrading_calendars/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/quantopian","download_url":"https://codeload.github.com/quantopian/trading_calendars/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254270656,"owners_count":22042860,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T20:00:46.372Z","updated_at":"2025-05-15T04:08:01.777Z","avatar_url":"https://github.com/quantopian.png","language":"Python","readme":"# **IMPORTANT NOTE**\n\nThis package is currently unmaintained as the sponsor, quantopian, is going through corporate changes. As such there is a fork of this project that will receive more active maintenance, https://github.com/gerrymanoim/trading_calendars, and the actively developed and maintained alternative implimentation here: https://github.com/rsheftel/pandas_market_calendars . The process to merge these implementations will continue in those two respective repos.\n\n# trading_calendars\n\n[![CI](https://github.com/quantopian/trading_calendars/workflows/CI/badge.svg)](https://github.com/quantopian/trading_calendars/actions?query=workflow%3ACI)\n[![PyPI version](https://img.shields.io/pypi/v/trading-calendars.svg)](https://pypi.org/project/trading-calendars/)\n[![Conda version](https://img.shields.io/conda/vn/conda-forge/trading-calendars.svg)](https://anaconda.org/conda-forge/trading-calendars)\n\nA Python library of exchange calendars, frequently used with [Zipline](https://github.com/quantopian/zipline).\n\n\n## Installation\n\n```bash\n$ pip install trading-calendars\n```\n\n## Quick Start\n\n```python\nimport trading_calendars as tc\nimport pandas as pd\nimport pytz\n```\n\nGet all registered calendars with `get_calendar_names`:\n\n```python\n\u003e\u003e\u003e tc.get_calendar_names()[:5]\n['XPHS', 'FWB', 'CFE', 'CMES', 'XSGO']\n```\n\nGet a calendar with `get_calendar`:\n\n```python\n\u003e\u003e\u003e xnys = tc.get_calendar(\"XNYS\")\n```\n\nWorking with sessions:\n\n```python\n\u003e\u003e\u003e xnys.is_session(pd.Timestamp(\"2020-01-01\"))\nFalse\n\n\u003e\u003e\u003e xnys.next_open(pd.Timestamp(\"2020-01-01\"))\nTimestamp('2020-01-02 14:31:00+0000', tz='UTC')\n\n\u003e\u003e\u003e pd.Timestamp(\"2020-01-01\", tz=pytz.UTC)+xnys.day\nTimestamp('2020-01-02 00:00:00+0000', tz='UTC')\n\n\u003e\u003e\u003e xnys.previous_close(pd.Timestamp(\"2020-01-01\"))\nTimestamp('2019-12-31 21:00:00+0000', tz='UTC')\n\n\u003e\u003e\u003e xnys.sessions_in_range(\n\u003e\u003e\u003e     pd.Timestamp(\"2020-01-01\", tz=pytz.UTC),\n\u003e\u003e\u003e     pd.Timestamp(\"2020-01-10\", tz=pytz.UTC)\n\u003e\u003e\u003e )\nDatetimeIndex(['2020-01-02 00:00:00+00:00', '2020-01-03 00:00:00+00:00',\n                '2020-01-06 00:00:00+00:00', '2020-01-07 00:00:00+00:00',\n                '2020-01-08 00:00:00+00:00', '2020-01-09 00:00:00+00:00',\n                '2020-01-10 00:00:00+00:00'],\n                dtype='datetime64[ns, UTC]', freq='C')\n\n\u003e\u003e\u003e xnys.sessions_window(\n\u003e\u003e\u003e     pd.Timestamp(\"2020-01-02\", tz=pytz.UTC),\n\u003e\u003e\u003e     7\n\u003e\u003e\u003e )\nDatetimeIndex(['2020-01-02 00:00:00+00:00', '2020-01-03 00:00:00+00:00',\n                '2020-01-06 00:00:00+00:00', '2020-01-07 00:00:00+00:00',\n                '2020-01-08 00:00:00+00:00', '2020-01-09 00:00:00+00:00',\n                '2020-01-10 00:00:00+00:00', '2020-01-13 00:00:00+00:00'],\n                dtype='datetime64[ns, UTC]', freq='C')\n```\n\n**NOTE**: see the [TradingCalendar class](https://github.com/quantopian/trading_calendars/blob/master/trading_calendars/trading_calendar.py) for more advanced usage.\n\nTrading calendars also supports command line usage, printing a unix-cal like calendar indicating which days are trading sessions or holidays.\n\n```bash\ntcal XNYS 2020\n```\n                                            2020\n            January                        February                        March\n    Su  Mo  Tu  We  Th  Fr  Sa     Su  Mo  Tu  We  Th  Fr  Sa     Su  Mo  Tu  We  Th  Fr  Sa\n                [ 1]  2   3 [ 4]                           [ 1]\n    [ 5]  6   7   8   9  10 [11]   [ 2]  3   4   5   6   7 [ 8]   [ 1]  2   3   4   5   6 [ 7]\n    [12] 13  14  15  16  17 [18]   [ 9] 10  11  12  13  14 [15]   [ 8]  9  10  11  12  13 [14]\n    [19][20] 21  22  23  24 [25]   [16][17] 18  19  20  21 [22]   [15] 16  17  18  19  20 [21]\n    [26] 27  28  29  30  31        [23] 24  25  26  27  28 [29]   [22] 23  24  25  26  27 [28]\n                                                                [29] 30  31\n\n            April                           May                            June\n    Su  Mo  Tu  We  Th  Fr  Sa     Su  Mo  Tu  We  Th  Fr  Sa     Su  Mo  Tu  We  Th  Fr  Sa\n                1   2   3 [ 4]                         1 [ 2]         1   2   3   4   5 [ 6]\n    [ 5]  6   7   8   9 [10][11]   [ 3]  4   5   6   7   8 [ 9]   [ 7]  8   9  10  11  12 [13]\n    [12] 13  14  15  16  17 [18]   [10] 11  12  13  14  15 [16]   [14] 15  16  17  18  19 [20]\n    [19] 20  21  22  23  24 [25]   [17] 18  19  20  21  22 [23]   [21] 22  23  24  25  26 [27]\n    [26] 27  28  29  30            [24][25] 26  27  28  29 [30]   [28] 29  30\n                                   [31]\n\n                July                          August                       September\n    Su  Mo  Tu  We  Th  Fr  Sa     Su  Mo  Tu  We  Th  Fr  Sa     Su  Mo  Tu  We  Th  Fr  Sa\n                1   2 [ 3][ 4]                           [ 1]             1   2   3   4 [ 5]\n    [ 5]  6   7   8   9  10 [11]   [ 2]  3   4   5   6   7 [ 8]   [ 6][ 7]  8   9  10  11 [12]\n    [12] 13  14  15  16  17 [18]   [ 9] 10  11  12  13  14 [15]   [13] 14  15  16  17  18 [19]\n    [19] 20  21  22  23  24 [25]   [16] 17  18  19  20  21 [22]   [20] 21  22  23  24  25 [26]\n    [26] 27  28  29  30  31        [23] 24  25  26  27  28 [29]   [27] 28  29  30\n                                   [30] 31\n\n            October                        November                       December\n    Su  Mo  Tu  We  Th  Fr  Sa     Su  Mo  Tu  We  Th  Fr  Sa     Su  Mo  Tu  We  Th  Fr  Sa\n                    1   2 [ 3]                                            1   2   3   4 [ 5]\n    [ 4]  5   6   7   8   9 [10]   [ 1]  2   3   4   5   6 [ 7]   [ 6]  7   8   9  10  11 [12]\n    [11] 12  13  14  15  16 [17]   [ 8]  9  10  11  12  13 [14]   [13] 14  15  16  17  18 [19]\n    [18] 19  20  21  22  23 [24]   [15] 16  17  18  19  20 [21]   [20] 21  22  23  24 [25][26]\n    [25] 26  27  28  29  30 [31]   [22] 23  24  25 [26] 27 [28]   [27] 28  29  30  31\n                                   [29] 30\n\n```bash\ntcal XNYS 1 2020\n```\n\n            January 2020\n    Su  Mo  Tu  We  Th  Fr  Sa\n                [ 1]  2   3 [ 4]\n    [ 5]  6   7   8   9  10 [11]\n    [12] 13  14  15  16  17 [18]\n    [19][20] 21  22  23  24 [25]\n    [26] 27  28  29  30  31\n\n## Frequently Asked Questions\n\n### Why are open times one minute late?\n\nDue to its historical use in the [Zipline](https://github.com/quantopian/zipline) backtesting system, `trading_calendars` will only indicate a market is open upon the completion of the first minute bar in a day. Zipline uses minute bars labeled with the end of the bar, e.g. 9:31AM for 9:30-9:31AM. As an example, on a regular trading day for NYSE:\n\n- 9:30:00 is treated as closed.\n- 9:30:01 is treated as closed.\n- 9:31:00 is the first time treated as open.\n- 16:00:00 is treated as open\n- 16:00:01 is treated as closed\n\nThis may change in the future.\n\n\n## Calendar Support\n\n| Exchange                        | ISO Code | Country        | Version Added | Exchange Website (English)                                   |\n| ------------------------------- | -------- | -------------- | ------------- | ------------------------------------------------------------ |\n| New York Stock Exchange         | XNYS     | USA            | 1.0           | https://www.nyse.com/index                                   |\n| CBOE Futures                    | XCBF     | USA            | 1.0           | https://markets.cboe.com/us/futures/overview/                |\n| Chicago Mercantile Exchange     | CMES     | USA            | 1.0           | https://www.cmegroup.com/                                    |\n| ICE US                          | IEPA     | USA            | 1.0           | https://www.theice.com/index                                 |\n| Toronto Stock Exchange          | XTSE     | Canada         | 1.0           | https://www.tsx.com/                                         |\n| BMF Bovespa                     | BVMF     | Brazil         | 1.0           | http://www.b3.com.br/en_us/                                  |\n| London Stock Exchange           | XLON     | England        | 1.0           | https://www.londonstockexchange.com/home/homepage.htm        |\n| Euronext Amsterdam              | XAMS     | Netherlands    | 1.2           | https://www.euronext.com/en/regulation/amsterdam             |\n| Euronext Brussels               | XBRU     | Belgium        | 1.2           | https://www.euronext.com/en/regulation/brussels              |\n| Euronext Lisbon                 | XLIS     | Portugal       | 1.2           | https://www.euronext.com/en/regulation/lisbon                |\n| Euronext Paris                  | XPAR     | France         | 1.2           | https://www.euronext.com/en/regulation/paris                 |\n| Frankfurt Stock Exchange        | XFRA     | Germany        | 1.2           | http://en.boerse-frankfurt.de/                               |\n| SIX Swiss Exchange              | XSWX     | Switzerland    | 1.2           | https://www.six-group.com/exchanges/index.html               |\n| Tokyo Stock Exchange            | XTKS     | Japan          | 1.2           | https://www.jpx.co.jp/english/                               |\n| Austrialian Securities Exchange | XASX     | Australia      | 1.3           | https://www.asx.com.au/                                      |\n| Bolsa de Madrid                 | XMAD     | Spain          | 1.3           | http://www.bolsamadrid.es/ing/aspx/Portada/Portada.aspx      |\n| Borsa Italiana                  | XMIL     | Italy          | 1.3           | https://www.borsaitaliana.it/homepage/homepage.en.htm        |\n| New Zealand Exchange            | XNZE     | New Zealand    | 1.3           | https://www.nzx.com/                                         |\n| Wiener Borse                    | XWBO     | Austria        | 1.3           | https://www.wienerborse.at/en/                               |\n| Hong Kong Stock Exchange        | XHKG     | Hong Kong      | 1.3           | https://www.hkex.com.hk/?sc_lang=en                          |\n| Copenhagen Stock Exchange       | XCSE     | Denmark        | 1.4           | http://www.nasdaqomxnordic.com/                              |\n| Helsinki Stock Exchange         | XHEL     | Finland        | 1.4           | http://www.nasdaqomxnordic.com/                              |\n| Stockholm Stock Exchange        | XSTO     | Sweden         | 1.4           | http://www.nasdaqomxnordic.com/                              |\n| Oslo Stock Exchange             | XOSL     | Norway         | 1.4           | https://www.oslobors.no/ob_eng/                              |\n| Irish Stock Exchange            | XDUB     | Ireland        | 1.4           | http://www.ise.ie/                                           |\n| Bombay Stock Exchange           | XBOM     | India          | 1.5           | https://www.bseindia.com                                     |\n| Singapore Exchange              | XSES     | Singapore      | 1.5           | https://www.sgx.com                                          |\n| Shanghai Stock Exchange         | XSHG     | China          | 1.5           | http://english.sse.com.cn                                    |\n| Korea Exchange                  | XKRX     | South Korea    | 1.6           | http://global.krx.co.kr                                      |\n| Iceland Stock Exchange          | XICE     | Iceland        | 1.7           | http://www.nasdaqomxnordic.com/                              |\n| Poland Stock Exchange           | XWAR     | Poland         | 1.9           | http://www.gpw.pl                                            |\n| Santiago Stock Exchange         | XSGO     | Chile          | 1.9           | http://inter.bolsadesantiago.com/sitios/en/Paginas/home.aspx |\n| Colombia Securities Exchange    | XBOG     | Colombia       | 1.9           | https://www.bvc.com.co/nueva/index_en.html                   |\n| Mexican Stock Exchange          | XMEX     | Mexico         | 1.9           | https://www.bmv.com.mx                                       |\n| Lima Stock Exchange             | XLIM     | Peru           | 1.9           | https://www.bvl.com.pe                                       |\n| Prague Stock Exchange           | XPRA     | Czech Republic | 1.9           | https://www.pse.cz/en/                                       |\n| Budapest Stock Exchange         | XBUD     | Hungary        | 1.10          | https://bse.hu/                                              |\n| Athens Stock Exchange           | ASEX     | Greece         | 1.10          | http://www.helex.gr/                                         |\n| Istanbul Stock Exchange         | XIST     | Turkey         | 1.10          | https://www.borsaistanbul.com/en/                            |\n| Johannesburg Stock Exchange     | XJSE     | South Africa   | 1.10          | https://www.jse.co.za/z                                      |\n| Malaysia Stock Exchange         | XKLS     | Malaysia       | 1.11          | http://www.bursamalaysia.com/market/                         |\n| Moscow Exchange                 | XMOS     | Russia         | 1.11          | https://www.moex.com/en/                                     |\n| Philippine Stock Exchange       | XPHS     | Philippines    | 1.11          | https://www.pse.com.ph/stockMarket/home.html                 |\n| Stock Exchange of Thailand      | XBKK     | Thailand       | 1.11          | https://www.set.or.th/set/mainpage.do?language=en\u0026country=US |\n| Indonesia Stock Exchange        | XIDX     | Indonesia      | 1.11          | https://www.idx.co.id/                                       |\n| Taiwan Stock Exchange Corp.     | XTAI     | Taiwan         | 1.11          | https://www.twse.com.tw/en/                                  |\n| Buenos Aires Stock Exchange     | XBUE     | Argentina      | 1.11          | https://www.bcba.sba.com.ar/                                 |\n| Pakistan Stock Exchange         | XKAR     | Pakistan       | 1.11          | https://www.psx.com.pk/                                      |\n\n\u003e Note that exchange calendars are defined by their [ISO-10383](https://www.iso20022.org/10383/iso-10383-market-identifier-codes) market identifier code.\n","funding_links":[],"categories":["Python"],"sub_categories":["Calendars"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquantopian%2Ftrading_calendars","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquantopian%2Ftrading_calendars","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquantopian%2Ftrading_calendars/lists"}