tradingdate


Nametradingdate JSON
Version 0.0.7 PyPI version JSON
download
home_pagehttps://github.com/Chitaoji/tradingdate/
SummaryManages trade dates.
upload_time2025-07-31 04:47:48
maintainerNone
docs_urlNone
authorChitaoji
requires_python>=3.12.7
licenseBSD
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# tradingdate
Manages trade dates.

## Installation
```sh
$ pip install tradingdate
```

## Requirements
```txt
chinesecalendar
```
## Usage
### Get a calendar
```py
>>> import tradingdate as td
>>> cal = td.get_calendar("chinese") # by default "chinese"
>>> cal
TradingCalendar(20040102 ~ 20251231, 'chinese')
>>> list(cal)[:3]
[TradingDate(20040102), TradingDate(20040105), TradingDate(20040106)]
```

### Get a trading date
```py
>>> date = td.get_trading_date(20250116)
>>> date
TradingDate(20250116)
>>> print(date.year, date.month, date.day)
2025 01 16
>>> date - 20
TradingDate(20241218)
>>> date + 100
TradingDate(20250617)
>>> date.month.start, date.month.end
(TradingDate(20250102), TradingDate(20250127))
>>> date.year.start, date.year.end
(TradingDate(20250102), TradingDate(20251231))
```

### Get trading dates
```py
>>> list(td.get_trading_dates(20250101, 20250106))
[TradingDate(20250102), TradingDate(20250103), TradingDate(20250106)]
```

### Make a new calendar
```py
>>> td.make_calendar("user-defined", [20250101, 20250115, 20250201])
TradingCalendar(20250101 ~ 20250201, 'user-defined')
>>> list(td.get_trading_dates(20250101, 20250131, calendar_id="user-defined"))
[TradingDate(20250101), TradingDate(20250115)]
```

## See Also
### Github repository
* https://github.com/Chitaoji/tradingdate/

### PyPI project
* https://pypi.org/project/tradingdate/

## License
This project falls under the BSD 3-Clause License.

## History
### v0.0.7
* Updated `make_calendar()`: raises `ValueError` when `calender_id` already 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.


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Chitaoji/tradingdate/",
    "name": "tradingdate",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12.7",
    "maintainer_email": null,
    "keywords": null,
    "author": "Chitaoji",
    "author_email": "2360742040@qq.com",
    "download_url": null,
    "platform": null,
    "description": "\n# tradingdate\nManages trade dates.\n\n## Installation\n```sh\n$ pip install tradingdate\n```\n\n## Requirements\n```txt\nchinesecalendar\n```\n## Usage\n### Get a calendar\n```py\n>>> import tradingdate as td\n>>> cal = td.get_calendar(\"chinese\") # by default \"chinese\"\n>>> cal\nTradingCalendar(20040102 ~ 20251231, 'chinese')\n>>> list(cal)[:3]\n[TradingDate(20040102), TradingDate(20040105), TradingDate(20040106)]\n```\n\n### Get a trading date\n```py\n>>> date = td.get_trading_date(20250116)\n>>> date\nTradingDate(20250116)\n>>> print(date.year, date.month, date.day)\n2025 01 16\n>>> date - 20\nTradingDate(20241218)\n>>> date + 100\nTradingDate(20250617)\n>>> date.month.start, date.month.end\n(TradingDate(20250102), TradingDate(20250127))\n>>> date.year.start, date.year.end\n(TradingDate(20250102), TradingDate(20251231))\n```\n\n### Get trading dates\n```py\n>>> list(td.get_trading_dates(20250101, 20250106))\n[TradingDate(20250102), TradingDate(20250103), TradingDate(20250106)]\n```\n\n### Make a new calendar\n```py\n>>> td.make_calendar(\"user-defined\", [20250101, 20250115, 20250201])\nTradingCalendar(20250101 ~ 20250201, 'user-defined')\n>>> list(td.get_trading_dates(20250101, 20250131, calendar_id=\"user-defined\"))\n[TradingDate(20250101), TradingDate(20250115)]\n```\n\n## See Also\n### Github repository\n* https://github.com/Chitaoji/tradingdate/\n\n### PyPI project\n* https://pypi.org/project/tradingdate/\n\n## License\nThis project falls under the BSD 3-Clause License.\n\n## History\n### v0.0.7\n* Updated `make_calendar()`: raises `ValueError` when `calender_id` already exists.\n\n### v0.0.6\n* New function `daterange()`.\n\n### v0.0.5\n* New property `TradingDate.week`.\n\n### v0.0.4\n* Improved effeciency when making a calendar.\n* Updated message of `NotImplementedError` raised by `CalendarEngine.get_chinese_calendar()`.\n\n### v0.0.3\n* Updated `make_calendar()`: now accepts a date-list as the second positional argument instead of a dict.\n\n### v0.0.2\n* New function `make_calendar()`.\n* Removed the dependency on `numpy`.\n\n### v0.0.1\n* New methods `TradingCalendar.get_year()`, `YearCalendar.get_month()`, `MonthCalendar.get_day()`.\n* Bugfix: `TradingDate.__sub__()`.\n\n### v0.0.0\n* Initial release.\n\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "Manages trade dates.",
    "version": "0.0.7",
    "project_urls": {
        "Homepage": "https://github.com/Chitaoji/tradingdate/"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "435adf90b0cc5b7be4a9ebfddc51062104b38dad5c3203dfcfa3504f7d1cc7fc",
                "md5": "8b43f4a226d3389db944bbbbc644b0fe",
                "sha256": "fd312c6cc4ed1327f7e2f61ba9e6f371ac76e6a2de94b5719ba227177c32859b"
            },
            "downloads": -1,
            "filename": "tradingdate-0.0.7-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8b43f4a226d3389db944bbbbc644b0fe",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.12.7",
            "size": 9067,
            "upload_time": "2025-07-31T04:47:48",
            "upload_time_iso_8601": "2025-07-31T04:47:48.763487Z",
            "url": "https://files.pythonhosted.org/packages/43/5a/df90b0cc5b7be4a9ebfddc51062104b38dad5c3203dfcfa3504f7d1cc7fc/tradingdate-0.0.7-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-31 04:47:48",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Chitaoji",
    "github_project": "tradingdate",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "tradingdate"
}
        
Elapsed time: 1.45205s