Skip to main content

Trade day handling utilities for A-share market

Project description

kepler-pulse

由于开源数据不稳定,现改为需要自行注入

安装

pip install kepler-pulse

交易日处理函数

from sangreal_calenadr import *
# 获取历史交易日
tmp_series = get_xxx() -> pd.Series
CALENDAR.inject(tmp_series)

# 获取交易日列表
get_trade_dts(begin_dt='20180101', end_dt='20180201')
['20180102', '20180103', ..., '20180201']
# 获取交易日DataFrame
get_trade_dts(begin_dt='20180101', end_dt='20180201', astype='pd')
      trade_dt
6613  20180102
6614  20180103
6615  20180104
6616  20180105
6617  20180108
# 调整非交易日至之前的最近一个交易日
adjust_trade_dt('20180101')
'20171229'
# 调整非交易日至之前的最后一个交易日
adjust_trade_dt('20180101', 'next')
'20180102'
# 往后step 1个交易日
# 注意,对于非交易日的输入,会自动将其adjust至之后的最近一个交易日
# 本质上是 step_trade_dt('20180102', 1)
step_trade_dt('20180101', 1)
'20180103'
# 往后step 1个交易日
step_trade_dt('20180101', -1)
'20171229'
# 计算两个日期间的交易日长度
delta_trade_dt('20180101', '20180305')
40

时间频率处理函数

支持weekly biweekly monthly quarterly reportly halfyearly yearly

以weekly为例

# 返回每周的第一个交易日
# 格式为Series 及 datetime
Weekly(1).get('20180101', '20190101')
6613   20180102
6617   20180108
6622   20180115
6627   20180122
6632   20180129
6637   20180205

# 返回每周的最后一个交易日
Weekly(-1).get('20180101', '20190101')
6621   20180112
6626   20180119
6631   20180126
6636   20180202
6641   20180209
6644   20180214

# 返回每周的第一个及最后一个交易日
Weekly(1, -1).get('20180101', '20190101')
6613   20180102
6617   20180108
6621   20180112
6622   20180115
6626   20180119
6627   20180122

Monthly() BiWeekly() Quarterly() ....

Project details


Download files

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

Source Distribution

kepler_pulse-0.1.8.tar.gz (21.4 kB view details)

Uploaded Source

Built Distribution

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

kepler_pulse-0.1.8-py3-none-any.whl (20.6 kB view details)

Uploaded Python 3

File details

Details for the file kepler_pulse-0.1.8.tar.gz.

File metadata

  • Download URL: kepler_pulse-0.1.8.tar.gz
  • Upload date:
  • Size: 21.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.7

File hashes

Hashes for kepler_pulse-0.1.8.tar.gz
Algorithm Hash digest
SHA256 f57b045849191ead0769e22b502ca2f28d13d9b567acae91fca29c2bf3474fae
MD5 a0fe7dcd2753d22b3c94a7fd5281514a
BLAKE2b-256 6c83fb7245a48c40e74738e6cc7fe64b9bb4181fc16ac088c16b3253cf436f80

See more details on using hashes here.

File details

Details for the file kepler_pulse-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: kepler_pulse-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 20.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.7

File hashes

Hashes for kepler_pulse-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 a617bec93bd4697707b097a34b51a45c0fc58af127bd79e50bd1413164066693
MD5 7b25638ff454b292df023a96dca06eae
BLAKE2b-256 2532d03d3fabbff1222fb67c1b9baf4ea79a177c1ea1dfb3329fd7fd894f4221

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