econ-datareader


Nameecon-datareader JSON
Version 1.0.5 PyPI version JSON
download
home_pagehttps://github.com/WYChoi1995/econ-datareader
SummaryDownload Econ Data - Macro and Finance
upload_time2024-11-01 21:56:54
maintainerNone
docs_urlNone
authorWyChoi1995
requires_python>=3.6
licenseNone
keywords finance economics
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Econ DataReader

<div align="right">

[![Pypi Package Ver.](https://img.shields.io/pypi/v/econ-datareader.svg)](https://pypi.org/project/econ-datareader/)
[![License](https://img.shields.io/pypi/l/ansicolortags.svg)](https://img.shields.io/pypi/l/ansicolortags.svg)

<div align="left">

**Econ DataReader** is a Python library designed to easily fetch economic and financial data from various sources, including the Bank of Korea, FRED (Federal Reserve Economic Data), domestic and international financial market data, and cryptocurrency prices. This tool simplifies data collection and can be seamlessly integrated into data science workflows.

## Key Features

- Fetch economic data from various sources such as:
    - Trad-Fi market data (stocks, bonds, etc.)
    - Cryptocurrencies: Upbit spot prices, Binance spot/futures prices
    - FRED
    - Bank of Korea (BOK)

## Installation

You can easily install econ-datareader via pip.

```bash
pip install econ-datareader
```

## Usage
Here are some examples of how to use econ-datareader.

### Trad-Fi and Cryptocurrency
```python
from econdatareader.finance import FinanceDownloader

downloader = FinanceDownloader()
data = downloader.download_data('CRYPTO_SPOT_BINANCE', ['BTCUSDT', 'ETHUSDT'], '1m', 202407240000, 202408050000)
```
The arguments for the `download_data` method are as follows:
  - Data Type: Choose from `KOREA_STOCK`, `GLOBAL_FINANCE`, `CRYPTO_SPOT_BINANCE`, `CRYPTO_FUTURES_BINANCE`, `CRYPTO_SPOT_UPBIT`
  - Ticker: Enter as `['Ticker1', 'Ticker2']`
  - Time Interval: Enter as a string like `1m`, `1h`, `1d`, `1M`
  - Start Time: Enter as `YYYYMMddHHmm` format (`int` type)
  - End Time: Same format as Start Time

To retrieve data, you can use the following. For instance, to get ETHUSDT data from the example above:
```python
eth_data = data['ETHUSDT']
```
For `KOREA_STOCK`, intraday data is only available for up to 7 business days from the current date. For `GLOBAL_FINANCE`, minute-level intraday data is available for up to 30 days, while hourly data is available for up to 730 days.

### FRED
```python
from econdatareader.fred import FredDownloader

downloader = FredDownloader(api_key='your_api_key')
id_table = downloader.search_series_by_keyword('core consumer price index')
data = downloader.download_data(['Code1', 'Code2'], '2011-01-01', '2024-08-01')
```
To download FRED data, you need to obtain an API_KEY from FRED. You can sign up and get your API_KEY from the following link:
  - https://fred.stlouisfed.org/
  
The arguments for the `search_series_by_keyword` method are as follows:
  - keyword: Enter as a `str` type. For example, to find the id of the Core CPI, you might input `core consumer price index`.

The arguments for the `download_data` method are as follows:
  - Data IDs: Enter as `['Code1', 'Code2']`
  - Start Time: Enter as `YYYY-mm-dd` format (`str` type)
  - End Time: Same format as Start Time

Each data series has a unique ID that can be found through keyword search on FRED. For example, the daily US Dollar Index ID is `DTWEXBGS`.

To retrieve data, you can use the following. For instance, to get the Dollar Index data from the example above:
```python
dollar_index_data = data['DTWEXBGS']
```

### Bank of Korea (BOK)
```python
from econdatareader.bok import BokDownloader

downloader = BokDownloader(api_key='your_api_key')
id_table = downloader.search_stat_code_by_keyword('소비자물가')
data = downloader.download_data(
  [('StatCode1', 'A', '2013', '2024', 'ItemCode1', '', '', ''), 
  ('StatCode2', 'Q', '2015Q1', '2024Q2', 'ItemCode2-1', 'ItemCode2-2', '', ''),
  ('StatCode3', 'M', '201501', '202407' 'ItemCode3-1', 'ItemCode3-2', 'ItemCode3-3', 'ItemCode3-4'),
  ('Statcode4', 'D', '20110101', '20240101', 'ItemCode4-1', 'ItemCode4-2', 'ItemCode4-3', '')]
)
```
To download data from the Bank of Korea's economic statistics system, you need to obtain an API_KEY. You can sign up and get your API_KEY from the following link:
 - https://ecos.bok.or.kr/api/#/

The arguments for the `search_stat_code_by_keyword` method are as follows:
  - keyword: Enter as a `str` type. For example, to find the STAT_CODE for the Consumer Price Index, you might input `소비자물가지수`.

The arguments for the `download_data` method are as follows:
  - `(Data ID, Time Interval, Start Time, End Time, Data Sub ID)` in the order shown above (refer to the code example)
  - Time Interval: Choose from `D`, `M`, `Q`, `A`
  - Start Time and End Time
    - For `D`, enter as `YYYYMMDD` format
    - For `M`, enter as `YYYYMM` format
    - For `Q`, enter as `YYYYQd` format (`d=1,2,3,4`)
    - For `A`, enter as `YYYY` format
 - Data ID and Data Sub ID can be referenced from the Bank of Korea's economic statistics system. (Sub IDs can be up to 4)

To retrieve data, you can use the following. For instance, to get the data for `Statcode1` from the example above:
```python
stat1_data = data['StatCode1-ItemCode1'] 
```

## License
This project is licensed under the MIT License. See the LICENSE file for more details.

## Contact
If you have any questions or suggestions, please contact `wydanielchoi@gmail.com`.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/WYChoi1995/econ-datareader",
    "name": "econ-datareader",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "finance, economics",
    "author": "WyChoi1995",
    "author_email": "wydanielchoi@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/00/ed/8e6fef61372f620d7f121161401fbaafaf63edadb7d13031f07193b3bd0d/econ-datareader-1.0.5.tar.gz",
    "platform": null,
    "description": "# Econ DataReader\r\n\r\n<div align=\"right\">\r\n\r\n[![Pypi Package Ver.](https://img.shields.io/pypi/v/econ-datareader.svg)](https://pypi.org/project/econ-datareader/)\r\n[![License](https://img.shields.io/pypi/l/ansicolortags.svg)](https://img.shields.io/pypi/l/ansicolortags.svg)\r\n\r\n<div align=\"left\">\r\n\r\n**Econ DataReader** is a Python library designed to easily fetch economic and financial data from various sources, including the Bank of Korea, FRED (Federal Reserve Economic Data), domestic and international financial market data, and cryptocurrency prices. This tool simplifies data collection and can be seamlessly integrated into data science workflows.\r\n\r\n## Key Features\r\n\r\n- Fetch economic data from various sources such as:\r\n    - Trad-Fi market data (stocks, bonds, etc.)\r\n    - Cryptocurrencies: Upbit spot prices, Binance spot/futures prices\r\n    - FRED\r\n    - Bank of Korea (BOK)\r\n\r\n## Installation\r\n\r\nYou can easily install econ-datareader via pip.\r\n\r\n```bash\r\npip install econ-datareader\r\n```\r\n\r\n## Usage\r\nHere are some examples of how to use econ-datareader.\r\n\r\n### Trad-Fi and Cryptocurrency\r\n```python\r\nfrom econdatareader.finance import FinanceDownloader\r\n\r\ndownloader = FinanceDownloader()\r\ndata = downloader.download_data('CRYPTO_SPOT_BINANCE', ['BTCUSDT', 'ETHUSDT'], '1m', 202407240000, 202408050000)\r\n```\r\nThe arguments for the `download_data` method are as follows:\r\n  - Data Type: Choose from `KOREA_STOCK`, `GLOBAL_FINANCE`, `CRYPTO_SPOT_BINANCE`, `CRYPTO_FUTURES_BINANCE`, `CRYPTO_SPOT_UPBIT`\r\n  - Ticker: Enter as `['Ticker1', 'Ticker2']`\r\n  - Time Interval: Enter as a string like `1m`, `1h`, `1d`, `1M`\r\n  - Start Time: Enter as `YYYYMMddHHmm` format (`int` type)\r\n  - End Time: Same format as Start Time\r\n\r\nTo retrieve data, you can use the following. For instance, to get ETHUSDT data from the example above:\r\n```python\r\neth_data = data['ETHUSDT']\r\n```\r\nFor `KOREA_STOCK`, intraday data is only available for up to 7 business days from the current date. For `GLOBAL_FINANCE`, minute-level intraday data is available for up to 30 days, while hourly data is available for up to 730 days.\r\n\r\n### FRED\r\n```python\r\nfrom econdatareader.fred import FredDownloader\r\n\r\ndownloader = FredDownloader(api_key='your_api_key')\r\nid_table = downloader.search_series_by_keyword('core consumer price index')\r\ndata = downloader.download_data(['Code1', 'Code2'], '2011-01-01', '2024-08-01')\r\n```\r\nTo download FRED data, you need to obtain an API_KEY from FRED. You can sign up and get your API_KEY from the following link:\r\n  - https://fred.stlouisfed.org/\r\n  \r\nThe arguments for the `search_series_by_keyword` method are as follows:\r\n  - keyword: Enter as a `str` type. For example, to find the id of the Core CPI, you might input `core consumer price index`.\r\n\r\nThe arguments for the `download_data` method are as follows:\r\n  - Data IDs: Enter as `['Code1', 'Code2']`\r\n  - Start Time: Enter as `YYYY-mm-dd` format (`str` type)\r\n  - End Time: Same format as Start Time\r\n\r\nEach data series has a unique ID that can be found through keyword search on FRED. For example, the daily US Dollar Index ID is `DTWEXBGS`.\r\n\r\nTo retrieve data, you can use the following. For instance, to get the Dollar Index data from the example above:\r\n```python\r\ndollar_index_data = data['DTWEXBGS']\r\n```\r\n\r\n### Bank of Korea (BOK)\r\n```python\r\nfrom econdatareader.bok import BokDownloader\r\n\r\ndownloader = BokDownloader(api_key='your_api_key')\r\nid_table = downloader.search_stat_code_by_keyword('\uc18c\ube44\uc790\ubb3c\uac00')\r\ndata = downloader.download_data(\r\n  [('StatCode1', 'A', '2013', '2024', 'ItemCode1', '', '', ''), \r\n  ('StatCode2', 'Q', '2015Q1', '2024Q2', 'ItemCode2-1', 'ItemCode2-2', '', ''),\r\n  ('StatCode3', 'M', '201501', '202407' 'ItemCode3-1', 'ItemCode3-2', 'ItemCode3-3', 'ItemCode3-4'),\r\n  ('Statcode4', 'D', '20110101', '20240101', 'ItemCode4-1', 'ItemCode4-2', 'ItemCode4-3', '')]\r\n)\r\n```\r\nTo download data from the Bank of Korea's economic statistics system, you need to obtain an API_KEY. You can sign up and get your API_KEY from the following link:\r\n - https://ecos.bok.or.kr/api/#/\r\n\r\nThe arguments for the `search_stat_code_by_keyword` method are as follows:\r\n  - keyword: Enter as a `str` type. For example, to find the STAT_CODE for the Consumer Price Index, you might input `\uc18c\ube44\uc790\ubb3c\uac00\uc9c0\uc218`.\r\n\r\nThe arguments for the `download_data` method are as follows:\r\n  - `(Data ID, Time Interval, Start Time, End Time, Data Sub ID)` in the order shown above (refer to the code example)\r\n  - Time Interval: Choose from `D`, `M`, `Q`, `A`\r\n  - Start Time and End Time\r\n    - For `D`, enter as `YYYYMMDD` format\r\n    - For `M`, enter as `YYYYMM` format\r\n    - For `Q`, enter as `YYYYQd` format (`d=1,2,3,4`)\r\n    - For `A`, enter as `YYYY` format\r\n - Data ID and Data Sub ID can be referenced from the Bank of Korea's economic statistics system. (Sub IDs can be up to 4)\r\n\r\nTo retrieve data, you can use the following. For instance, to get the data for `Statcode1` from the example above:\r\n```python\r\nstat1_data = data['StatCode1-ItemCode1'] \r\n```\r\n\r\n## License\r\nThis project is licensed under the MIT License. See the LICENSE file for more details.\r\n\r\n## Contact\r\nIf you have any questions or suggestions, please contact `wydanielchoi@gmail.com`.\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Download Econ Data - Macro and Finance",
    "version": "1.0.5",
    "project_urls": {
        "Homepage": "https://github.com/WYChoi1995/econ-datareader"
    },
    "split_keywords": [
        "finance",
        " economics"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8fc409962d3a7f0988a437abf8b5f47210f8d9303ef4ed1cfc7841cab111160e",
                "md5": "683ef47ebb60c1306c0c49a268cc4ad4",
                "sha256": "02c6c2cc59aec5a72cc3b1be5ce9773666e0fb5c7f8105bfd492005544d2d38b"
            },
            "downloads": -1,
            "filename": "econ_datareader-1.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "683ef47ebb60c1306c0c49a268cc4ad4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 11080,
            "upload_time": "2024-11-01T21:56:51",
            "upload_time_iso_8601": "2024-11-01T21:56:51.659130Z",
            "url": "https://files.pythonhosted.org/packages/8f/c4/09962d3a7f0988a437abf8b5f47210f8d9303ef4ed1cfc7841cab111160e/econ_datareader-1.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "00ed8e6fef61372f620d7f121161401fbaafaf63edadb7d13031f07193b3bd0d",
                "md5": "43fd34200c8f48b1f3cd162d83af4add",
                "sha256": "6692c9b781db39c0526dcd83e072590c8846e3aae85aced1fb4ec15070a6388b"
            },
            "downloads": -1,
            "filename": "econ-datareader-1.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "43fd34200c8f48b1f3cd162d83af4add",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 9285,
            "upload_time": "2024-11-01T21:56:54",
            "upload_time_iso_8601": "2024-11-01T21:56:54.783201Z",
            "url": "https://files.pythonhosted.org/packages/00/ed/8e6fef61372f620d7f121161401fbaafaf63edadb7d13031f07193b3bd0d/econ-datareader-1.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-01 21:56:54",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "WYChoi1995",
    "github_project": "econ-datareader",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "econ-datareader"
}
        
Elapsed time: 0.34897s