Skip to main content

a_trade_calendar

一款简单、纯粹,适用于A股的交易日历工具包。来自[西海岸量化工作室]。

安装

全新安装

pip install a-trade-calendar

升级安装

pip install --upgrade a-trade-calendar

使用

声明:日期范围从2005-01-04起,每年末将自动更新。

1、获取A股最新交易日日期

import a_trade_calendar
latest_trade_dt = a_trade_calendar.get_latest_trade_date()

print(latest_trade_dt)

2、判断某个日期是否是A股交易日

import a_trade_calendar
dt = '2023-09-01'
is_trade_date = a_trade_calendar.is_trade_date(dt)

print(is_trade_date)

3、获取A股前面n个交易日对应的日期

import a_trade_calendar
dt = '2023-09-01'
trade_date = a_trade_calendar.get_pre_trade_date(dt, 3)

print(trade_date)

4、获取A股后面n个交易日对应的日期

import a_trade_calendar
dt = '2023-09-01'
trade_date = a_trade_calendar.get_next_trade_date(dt, 3)

print(trade_date)

5、获取A股两个日期相隔的交易日天数,不包括 from_dt 和 to_dt

import a_trade_calendar

from_dt = '2023-08-21'
to_dt = '2023-09-01'

trade_days = a_trade_calendar.get_trade_days_interval(from_dt, to_dt)

print(trade_days)

6、获取A股两个日期相隔的交易日天数,包括 from_dt 和 to_dt

import a_trade_calendar

from_dt = '2023-08-21'
to_dt = '2023-09-01'

trade_days = a_trade_calendar.get_trade_count(from_dt, to_dt)

print(trade_days)

7、获取A股两个日期相隔的交易日列表,包括 from_dt 和 to_dt

import a_trade_calendar

from_dt = '2023-08-21'
to_dt = '2023-09-01'

trade_days = a_trade_calendar.get_trade_days(from_dt, to_dt)

print(trade_days)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

a_trade_calendar-2028.4.14-py2.py3-none-any.whl (21.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file a_trade_calendar-2028.4.14-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for a_trade_calendar-2028.4.14-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ae792a5a175c31e9323e0c5c8cd0b3f28083bc4d2ed9711c3ef4585e8f7b5205
MD5 9280d861fac74507e4c40272cbfebe03
BLAKE2b-256 71c4c416426969d6feef7f3a0456cfe61b22d4dcb7f167465c14433230d55b12

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page