Skip to main content

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
  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

Metadata

Release files for ehdtd 0.2.45

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ehdtd 0.2.45
File Size Uploaded Provenance Actions
ehdtd-0.2.45.tar.gz 43.1 kB Without provenance Details for ehdtd-0.2.45.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ehdtd 0.2.45
File Interpreter ABI Platform Actions
ehdtd-0.2.45-py3-none-any.whl Python 3 none any Details for ehdtd-0.2.45-py3-none-any.whl

Total release size: 96.3 kB

Release files / ehdtd-0.2.45.tar.gz

Download URL ehdtd-0.2.45.tar.gz
Size 43.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d2287368447180566965ac0bdcbbfaddbc9dfc7700ed2a9ea070efbcc4d1c7cd
BLAKE2b-256 checksum
How to use checksums
746229f1b20d5b681fd5bcf56f7e0e6ec1984a61977c3241fa761491f1475b2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / ehdtd-0.2.45-py3-none-any.whl

Download URL ehdtd-0.2.45-py3-none-any.whl
Size 53.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
82b9f19f3bbac13420d3b85aa927d04db736a3a7e55673d3fee99d83dfa9bfe2
BLAKE2b-256 checksum
How to use checksums
30b8f905925b919e5e9d95eb726d43ff3ad5c2dd6dd3e57d7c4f7a755f81a030
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Security for ehdtd 0.2.45

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.

Release history Release notifications | RSS feed

This release

0.2.45 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page