ehdtd


Nameehdtd JSON
Version 0.2.36 PyPI version JSON
download
home_pageNone
SummaryEhdtd - cryptoCurrency Exchange history data to database
upload_time2025-07-19 04:16:31
maintainerNone
docs_urlNone
authorRicardo Marcelo Alvarez
requires_python<4.0,>=3.11
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Ehdtd - cryptoCurrency Exchange history data to database
This class retrieves historical data from exchanges and stores it in a database.

Example:
### Install
    ```bash
    pip install ehdtd
    ```
### Use

    ```python
    import time
    from ehdtd import Ehdtd

    exchange = 'binance'
    symbol = 'BTC/USDT'
    interval = '1m'
    limit = 10

    db_data = {
        'db_type': 'postgresql',  # postgresql, mysql
        'db_name': 'ehdtd',
        'db_user': 'ehdtd',
        'db_pass': 'xxxxxxxxx',
        'db_host': '127.0.0.1',
        'db_port': '5432'
    }

    fetch_data = [
        {
            'symbol': symbol,
            'interval': interval
        }
    ]

    ehd = Ehdtd(exchange, fetch_data, db_data)  # Create an instance
    ehd.start()  # Start fetching data

    time.sleep(900)  # First time Wait for available data, for the data to be updated,
                     # you must wait between 90 minutes and 2.5 hours depending on the interval

    for v in fetch_data:
        symbol = v['symbol']
        interval = v['interval']
        start_from = 0
        until_to = None
        return_type = 'pandas'
        data_db = ehd.get_data_from_db(symbol, interval, start_from, until_to, return_type)
        print(data_db)
        print('=========================================================================')
        print('')
        time.sleep(1)

    ehd.stop()  # Stop fetching data
    ```

# How It Works:

## For Binance:

1. Try to retrieve data from a file. Check this link:\
    [Binance Public Data](https://github.com/binance/binance-public-data/#trades-1)
2. If the file is not available, try to retrieve data from the API.
3. Then get data from the WebSocket API using the Ccxw class.

## Database Columns:

- `open_time`, `open_date`, `open_price`, `close_time`, `close_date`, `close_price`, `low`,
    `high`, `volume`, `exchange`, `symbol`, `interval`, `status`, `data`

- Column `data` is not used,\
    and column `status` can have three values: `'__NON_CHECK__'`, `'__OK__'`, `'__ERROR__'`.
    - If `status == '__OK__'`, the file has consistent data.
    - If `status == '__ERROR__'`, the file has inconsistent data.
    - If `status == '__NON_CHECK__'`, the file is not analyzed.

## Retrieving Data from Database:

Use the function `ehd.get_data_from_db(symbol, interval, start_from, until_to, return_type)`:
- If `return_type == 'pandas'`, it returns a Pandas DataFrame.
- If `return_type == 'list'`, it returns a list of dictionaries.

[View License](LICENSE)



            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "ehdtd",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.11",
    "maintainer_email": null,
    "keywords": null,
    "author": "Ricardo Marcelo Alvarez",
    "author_email": "rmalvarezkai@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/fd/31/ab1e684f0bb69c7913dbc423a5a941626f08ff9e3d3a8eacbe663f26776d/ehdtd-0.2.36.tar.gz",
    "platform": null,
    "description": "# Ehdtd - cryptoCurrency Exchange history data to database\nThis class retrieves historical data from exchanges and stores it in a database.\n\nExample:\n### Install\n    ```bash\n    pip install ehdtd\n    ```\n### Use\n\n    ```python\n    import time\n    from ehdtd import Ehdtd\n\n    exchange = 'binance'\n    symbol = 'BTC/USDT'\n    interval = '1m'\n    limit = 10\n\n    db_data = {\n        'db_type': 'postgresql',  # postgresql, mysql\n        'db_name': 'ehdtd',\n        'db_user': 'ehdtd',\n        'db_pass': 'xxxxxxxxx',\n        'db_host': '127.0.0.1',\n        'db_port': '5432'\n    }\n\n    fetch_data = [\n        {\n            'symbol': symbol,\n            'interval': interval\n        }\n    ]\n\n    ehd = Ehdtd(exchange, fetch_data, db_data)  # Create an instance\n    ehd.start()  # Start fetching data\n\n    time.sleep(900)  # First time Wait for available data, for the data to be updated,\n                     # you must wait between 90 minutes and 2.5 hours depending on the interval\n\n    for v in fetch_data:\n        symbol = v['symbol']\n        interval = v['interval']\n        start_from = 0\n        until_to = None\n        return_type = 'pandas'\n        data_db = ehd.get_data_from_db(symbol, interval, start_from, until_to, return_type)\n        print(data_db)\n        print('=========================================================================')\n        print('')\n        time.sleep(1)\n\n    ehd.stop()  # Stop fetching data\n    ```\n\n# How It Works:\n\n## For Binance:\n\n1. Try to retrieve data from a file. Check this link:\\\n    [Binance Public Data](https://github.com/binance/binance-public-data/#trades-1)\n2. If the file is not available, try to retrieve data from the API.\n3. Then get data from the WebSocket API using the Ccxw class.\n\n## Database Columns:\n\n- `open_time`, `open_date`, `open_price`, `close_time`, `close_date`, `close_price`, `low`,\n    `high`, `volume`, `exchange`, `symbol`, `interval`, `status`, `data`\n\n- Column `data` is not used,\\\n    and column `status` can have three values: `'__NON_CHECK__'`, `'__OK__'`, `'__ERROR__'`.\n    - If `status == '__OK__'`, the file has consistent data.\n    - If `status == '__ERROR__'`, the file has inconsistent data.\n    - If `status == '__NON_CHECK__'`, the file is not analyzed.\n\n## Retrieving Data from Database:\n\nUse the function `ehd.get_data_from_db(symbol, interval, start_from, until_to, return_type)`:\n- If `return_type == 'pandas'`, it returns a Pandas DataFrame.\n- If `return_type == 'list'`, it returns a list of dictionaries.\n\n[View License](LICENSE)\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Ehdtd - cryptoCurrency Exchange history data to database",
    "version": "0.2.36",
    "project_urls": {
        "Homepage": "https://github.com/rmalvarezkai/ehdtd"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "68a8e025308be5f5497fdd6ef33592c4672a3e3a7b06bcb3ef965c5eab09126d",
                "md5": "844d0265d029259341dffca21c8ea168",
                "sha256": "9255dead698bcf01fb6f7f099bda6fd9d7c602147209bb36f416bb633b593139"
            },
            "downloads": -1,
            "filename": "ehdtd-0.2.36-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "844d0265d029259341dffca21c8ea168",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.11",
            "size": 53026,
            "upload_time": "2025-07-19T04:16:29",
            "upload_time_iso_8601": "2025-07-19T04:16:29.800006Z",
            "url": "https://files.pythonhosted.org/packages/68/a8/e025308be5f5497fdd6ef33592c4672a3e3a7b06bcb3ef965c5eab09126d/ehdtd-0.2.36-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "fd31ab1e684f0bb69c7913dbc423a5a941626f08ff9e3d3a8eacbe663f26776d",
                "md5": "71e635a887f654f1d49caf458762c832",
                "sha256": "9a14f7fda7338cef42dc0ba9f2e13317bc8ad01f4af5b1b3d4047a7b03d5fbeb"
            },
            "downloads": -1,
            "filename": "ehdtd-0.2.36.tar.gz",
            "has_sig": false,
            "md5_digest": "71e635a887f654f1d49caf458762c832",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.11",
            "size": 36514,
            "upload_time": "2025-07-19T04:16:31",
            "upload_time_iso_8601": "2025-07-19T04:16:31.486917Z",
            "url": "https://files.pythonhosted.org/packages/fd/31/ab1e684f0bb69c7913dbc423a5a941626f08ff9e3d3a8eacbe663f26776d/ehdtd-0.2.36.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-19 04:16:31",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "rmalvarezkai",
    "github_project": "ehdtd",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "ehdtd"
}
        
Elapsed time: 0.87148s