cn-stock-holidays


Namecn-stock-holidays JSON
Version 1.10 PyPI version JSON
download
home_pagehttps://github.com/rainx/cn_stock_holidays.git
SummaryA List of china stock exchange holidays
upload_time2022-12-16 06:54:09
maintainer
docs_urlNone
authorrainx
requires_python
licenseMIT
keywords china stock holiday exchange shanghai shenzhen and hongkong
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # cn_stock_holidays

![CI Status](https://github.com/rainx/cn_stock_holidays/actions/workflows/pytest.yml/badge.svg)

## 数据文件 (File Path)

沪深市场

```
cn_stock_holidays/data.txt
```

香港市场

```
cn_stock_holidays/data_hk.txt
```

Fetch Data via URL :

```
wget https://raw.githubusercontent.com/rainx/cn_stock_holidays/master/cn_stock_holidays/data.txt

or

curl https://raw.githubusercontent.com/rainx/cn_stock_holidays/master/cn_stock_holidays/data.txt
```

## 文件内容 ( File Content)

保存除了周六日休市之外,其它休市信息,换行分割

store all (even upcoming) holiday for china stock exchange (without regular market close date on Saturday Day and Sun Day ) , one date per line

## 格式(File Format)

```
YYYYMMDD
```

## Python version

```
pip install cn-stock-holidays
```

or

```
pip install git+https://github.com/rainx/cn_stock_holidays.git
```

### 导入

```python

# 针对沪深
import cn_stock_holidays.data as shsz

# 针对香港
import cn_stock_holidays.data_hk as hkex

```

### Functions

```python
Help on module cn_stock_holidays.data in cn_stock_holidays:

NAME
    cn_stock_holidays.data - Help functions for python to get china stock exchange holidays

FILE
    /Users/rainx/dev/cn_stock_holidays/cn_stock_holidays/data.py

FUNCTIONS
    check_expired()
        check if local or cached data need update
        :return: true/false

    date_to_int(da)

    date_to_str(da)

    get_cache_path()

    get_cached()
        get from cache version , if it is not exising , use txt file in package data
        :return: a list contains all holiday data, element with datatime.date format

    get_local()
        read data from package data file
        :return: a list contains all holiday data, element with datatime.date format

    get_remote_and_cache()
        get newest data file from network and cache on local machine
        :return: a list contains all holiday data, element with datatime.date format

    int_to_date(d)

    str_to_int(s)

    sync_data()


    is_trading_day(dt)
        param dt: datetime.datetime or datetime.date.
        is a trading day or not
        :returns: Bool

    previous_trading_day(dt):
        param dt: datetime.datetime or datetime.date.
        get previous trading day
        :returns: datetime.date

    next_trading_day(dt):
        param dt: datetime.datetime or datetime.date.
        get next trading day
        :returns: datetime.date

    trading_days_between(start, end):

        param start, end: start and end time , datetime.datetime or datetime.date
        get calendar data range
        :returns: a generator for available dates for chinese market included start and end date
```

### about function cache

from version 0.10 on, we used functools.lrucache on `get_cached` for getting more speech,
if needed you can used the following syntax to clear cache.

```python
get_cached.cache_clear()  

```

### Keep it up-to-date

we had a script to check the expired of the data and fetch the data from web.

you could set it up on cron job

```crontab
0 0 * * * /usr/local/bin/cn-stock-holiday-sync > /tmp/cn_stock_holiday_sync.log
```

You could get the absolute path of cn-stock-holiday-sync by which command

沪深

```bash
which cn-stock-holiday-sync
```

香港

```bash
which cn-stock-holiday-sync-hk
```
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/rainx/cn_stock_holidays.git",
    "name": "cn-stock-holidays",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "china stock holiday exchange shanghai,shenzhen and hongkong",
    "author": "rainx",
    "author_email": "i@rainx.cc",
    "download_url": "https://files.pythonhosted.org/packages/0d/18/87e83a5616cd96b5cebbc3b73cea682a1afb41725f0e26865bbfd43899df/cn-stock-holidays-1.10.tar.gz",
    "platform": null,
    "description": "# cn_stock_holidays\n\n![CI Status](https://github.com/rainx/cn_stock_holidays/actions/workflows/pytest.yml/badge.svg)\n\n## \u6570\u636e\u6587\u4ef6 (File Path)\n\n\u6caa\u6df1\u5e02\u573a\n\n```\ncn_stock_holidays/data.txt\n```\n\n\u9999\u6e2f\u5e02\u573a\n\n```\ncn_stock_holidays/data_hk.txt\n```\n\nFetch Data via URL :\n\n```\nwget https://raw.githubusercontent.com/rainx/cn_stock_holidays/master/cn_stock_holidays/data.txt\n\nor\n\ncurl https://raw.githubusercontent.com/rainx/cn_stock_holidays/master/cn_stock_holidays/data.txt\n```\n\n## \u6587\u4ef6\u5185\u5bb9 ( File Content)\n\n\u4fdd\u5b58\u9664\u4e86\u5468\u516d\u65e5\u4f11\u5e02\u4e4b\u5916\uff0c\u5176\u5b83\u4f11\u5e02\u4fe1\u606f\uff0c\u6362\u884c\u5206\u5272\n\nstore all (even upcoming) holiday for china stock exchange (without regular market close date on Saturday Day and Sun Day ) , one date per line\n\n## \u683c\u5f0f(File Format)\n\n```\nYYYYMMDD\n```\n\n## Python version\n\n```\npip install cn-stock-holidays\n```\n\nor\n\n```\npip install git+https://github.com/rainx/cn_stock_holidays.git\n```\n\n### \u5bfc\u5165\n\n```python\n\n# \u9488\u5bf9\u6caa\u6df1\nimport cn_stock_holidays.data as shsz\n\n# \u9488\u5bf9\u9999\u6e2f\nimport cn_stock_holidays.data_hk as hkex\n\n```\n\n### Functions\n\n```python\nHelp on module cn_stock_holidays.data in cn_stock_holidays:\n\nNAME\n    cn_stock_holidays.data - Help functions for python to get china stock exchange holidays\n\nFILE\n    /Users/rainx/dev/cn_stock_holidays/cn_stock_holidays/data.py\n\nFUNCTIONS\n    check_expired()\n        check if local or cached data need update\n        :return: true/false\n\n    date_to_int(da)\n\n    date_to_str(da)\n\n    get_cache_path()\n\n    get_cached()\n        get from cache version , if it is not exising , use txt file in package data\n        :return: a list contains all holiday data, element with datatime.date format\n\n    get_local()\n        read data from package data file\n        :return: a list contains all holiday data, element with datatime.date format\n\n    get_remote_and_cache()\n        get newest data file from network and cache on local machine\n        :return: a list contains all holiday data, element with datatime.date format\n\n    int_to_date(d)\n\n    str_to_int(s)\n\n    sync_data()\n\n\n    is_trading_day(dt)\n        param dt: datetime.datetime or datetime.date.\n        is a trading day or not\n        :returns: Bool\n\n    previous_trading_day(dt):\n        param dt: datetime.datetime or datetime.date.\n        get previous trading day\n        :returns: datetime.date\n\n    next_trading_day(dt):\n        param dt: datetime.datetime or datetime.date.\n        get next trading day\n        :returns: datetime.date\n\n    trading_days_between(start, end):\n\n        param start, end: start and end time , datetime.datetime or datetime.date\n        get calendar data range\n        :returns: a generator for available dates for chinese market included start and end date\n```\n\n### about function cache\n\nfrom version 0.10 on, we used functools.lrucache on `get_cached` for getting more speech,\nif needed you can used the following syntax to clear cache.\n\n```python\nget_cached.cache_clear()  \n\n```\n\n### Keep it up-to-date\n\nwe had a script to check the expired of the data and fetch the data from web.\n\nyou could set it up on cron job\n\n```crontab\n0 0 * * * /usr/local/bin/cn-stock-holiday-sync > /tmp/cn_stock_holiday_sync.log\n```\n\nYou could get the absolute path of cn-stock-holiday-sync by which command\n\n\u6caa\u6df1\n\n```bash\nwhich cn-stock-holiday-sync\n```\n\n\u9999\u6e2f\n\n```bash\nwhich cn-stock-holiday-sync-hk\n```",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A List of china stock exchange holidays",
    "version": "1.10",
    "split_keywords": [
        "china stock holiday exchange shanghai",
        "shenzhen and hongkong"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "97120d1c1726371c93cfa1fa38deed98",
                "sha256": "14fefa6f187c0dc097a355588bc2a52c030cf9e10a01504afda260a4d046adee"
            },
            "downloads": -1,
            "filename": "cn_stock_holidays-1.10-py3.8.egg",
            "has_sig": false,
            "md5_digest": "97120d1c1726371c93cfa1fa38deed98",
            "packagetype": "bdist_egg",
            "python_version": "1.10",
            "requires_python": null,
            "size": 34250,
            "upload_time": "2022-12-16T06:54:11",
            "upload_time_iso_8601": "2022-12-16T06:54:11.772929Z",
            "url": "https://files.pythonhosted.org/packages/a3/93/9efd85ee8d91dd71b0870b17c693d0029e9b12390a0ab8b25d1b26f9dbc1/cn_stock_holidays-1.10-py3.8.egg",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "f90f9c6c6b8a3c9262db5365c21893fd",
                "sha256": "d91d77bf6044ea38ffc23c22a43861c17a390c0be08018a969b9c8223d96175e"
            },
            "downloads": -1,
            "filename": "cn-stock-holidays-1.10.tar.gz",
            "has_sig": false,
            "md5_digest": "f90f9c6c6b8a3c9262db5365c21893fd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 12994,
            "upload_time": "2022-12-16T06:54:09",
            "upload_time_iso_8601": "2022-12-16T06:54:09.762666Z",
            "url": "https://files.pythonhosted.org/packages/0d/18/87e83a5616cd96b5cebbc3b73cea682a1afb41725f0e26865bbfd43899df/cn-stock-holidays-1.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-16 06:54:09",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "rainx",
    "github_project": "cn_stock_holidays.git",
    "lcname": "cn-stock-holidays"
}
        
Elapsed time: 0.01869s