tradingdate
Manages trade dates.
Installation
$ pip install tradingdate
Requirements
chinesecalendar
Usage
Get a calendar
>>> import tradingdate as td
>>> cal = td.get_calendar("chinese") # by default "chinese"
>>> cal
TradingCalendar(20040102 ~ 20261231, 'chinese')
>>> list(cal)[:3]
[TradingDate(20040102), TradingDate(20040105), TradingDate(20040106)]
Get a trading date
>>> date = td.date(20250116)
>>> date
TradingDate(20250116)
>>> print(date.year, date.month, date.day)
2025 01 16
>>> date - 20
TradingDate(20241218)
>>> date + 100
TradingDate(20250617)
>>> date.week.start, date.week.end
(TradingDate(20250113), TradingDate(20250117))
>>> date.month.start, date.month.end
(TradingDate(20250102), TradingDate(20250127))
>>> date.year.start, date.year.end
(TradingDate(20250102), TradingDate(20251231))
Get iterator of trading dates
>>> list(td.daterange(20250101, 20250107))
[TradingDate(20250102), TradingDate(20250103), TradingDate(20250106)]
Make a new calendar
>>> td.make_calendar("user-defined", [20250101, 20250115, 20250201])
TradingCalendar(20250101 ~ 20250201, 'user-defined')
>>> list(td.daterange(20250101, 20250131, calendar_id="user-defined"))
[TradingDate(20250101), TradingDate(20250115)]
See Also
Github repository
PyPI project
License
This project falls under the BSD 3-Clause License.
History
v0.0.12
- Fixed the returntype of
daterange().
v0.0.11
- New parameters for
daterange():stepandinclude_end. - Removed
get_trading_dates(), usedaterange(include_end=True)instead. - Renamed
get_trading_date()todate(). date(missing = 'use_last')is deprecated, usedate(missing = 'use_before')now.make_calendar()can now receive an iterator of int, str orTradingtateobjects, and the parameterdate_listis renamed todates.
v0.0.10
- New method
DateRange.apply().
v0.0.9
- Updated support for comparison operators and 'in' operators.
v0.0.8
- Bugfix: no longer raises an OutOfCalendarError when the
endparameter forget_trading_dates()is None. - New method
TradingDate.iterate_until(). daterange()returns an instance ofDateRangenow.
v0.0.7
- Updated
make_calendar(): raises ValueError whencalender_idalready exists.
v0.0.6
- New function
daterange().
v0.0.5
- New property
TradingDate.week.
v0.0.4
- Improved effeciency when making a calendar.
- Updated message of NotImplementedError raised by
CalendarEngine.get_chinese_calendar().
v0.0.3
- Updated
make_calendar(): now accepts a date-list as the second positional argument instead of a dict.
v0.0.2
- New function
make_calendar(). - Removed the dependency on
numpy.
v0.0.1
- New methods
TradingCalendar.get_year(),YearCalendar.get_month(),MonthCalendar.get_day(). - Bugfix:
TradingDate.__sub__().
v0.0.0
- Initial release.
Metadata
Release files for tradingdate 0.0.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tradingdate-0.0.12.tar.gz | 12.2 kB | Without provenance | Details for tradingdate-0.0.12.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tradingdate-0.0.12-py3-none-any.whl | Python 3 | none | any | Details for tradingdate-0.0.12-py3-none-any.whl |
Total release size: 24.5 kB
Release files / tradingdate-0.0.12.tar.gz
| Download URL | tradingdate-0.0.12.tar.gz |
|---|---|
| Size | 12.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0eda96301493164e9f1c7c6d8455c051219bf45f74b14108e329204e592ec37c
|
|
BLAKE2b-256 checksum How to use checksums |
d4a5611e93e8874e4cedf9fae3099360b0fa90a60a45e0cd3d87357008fd4546
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.7
|
Release files / tradingdate-0.0.12-py3-none-any.whl
| Download URL | tradingdate-0.0.12-py3-none-any.whl |
|---|---|
| Size | 12.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
06baeccd4cc76c01d3675d726850732df223e8a1adb93f77cdffce8766a9f5d1
|
|
BLAKE2b-256 checksum How to use checksums |
8d4333a1dc8f29de061401711fb415d9ce968e8d63f860bd704ecdfb0ddc9a87
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.7
|
Security for tradingdate 0.0.12
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.