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)

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)

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-2028.4.12.2-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.12.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for a_trade_calendar-2028.4.12.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 75cd3241b160f24007dd25ba2b69c96cf4bd4b99286ec5e287fe9321e512f80d
MD5 7a2576abec20cfcfed53e84073388e75
BLAKE2b-256 c3ea4d23d6e55e03a8fdd98d80361c9dd16008b38d7e5df2d901b1fb10b4ed7e

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