Skip to main content

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

Project description

a_trade_calendar

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

安装

全新安装

pip install a-trade-calendar

升级安装

pip install --upgrade a-trade-calendar

使用

声明:日期范围从2005.1.1期 到2025-08-15 日止。 将来日期后续会保持更新,日期将到会自动提示更新。

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)

Project details


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-2027.10.27.1-py2.py3-none-any.whl (15.9 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

File hashes

Hashes for a_trade_calendar-2027.10.27.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 323bf58dd607fa3489c865683c63e31fb3d54097092e459cbac601ffe948e534
MD5 fc5316ebd1befb5f0e43af7ae67e49a8
BLAKE2b-256 e1a126b6e4f9e19255170790be914d6b63e94b14722050b2086e6354aa1328b4

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