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)

Metadata

Release files for a-trade-calendar 2028.4.15

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for a-trade-calendar 2028.4.15
File Interpreter ABI Platform Actions
a_trade_calendar-2028.4.15-py2.py3-none-any.whl Python 3, Python 2 none any Details for a_trade_calendar-2028.4.15-py2.py3-none-any.whl

Release files / a_trade_calendar-2028.4.15-py2.py3-none-any.whl

Download URL a_trade_calendar-2028.4.15-py2.py3-none-any.whl
Size 22.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
d59bd64c4531117cddf7e8b857a585f33682e56dbd2db1c1a4aa3ff0c174bf68
BLAKE2b-256 checksum
How to use checksums
090366c2432a99454c71da059dce2db64286b349129ab46f435c16e50cd2ce62
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.8.20

Security for a-trade-calendar 2028.4.15

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2028.4.15 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page