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

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.42
File Size Uploaded
ehdtd-0.2.42.tar.gz 43.0 kB Details

Built distribution (wheel)

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

Total release size: 96.3 kB

Release files / ehdtd-0.2.42.tar.gz

Download URL ehdtd-0.2.42.tar.gz
Size 43.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b18cfedadf00c09a9129e3d968fba6ed809d64a818368762797ae35f4605a283
BLAKE2b-256 checksum
How to use checksums
a83f5f0e6e35c91fd207907fc6db5a1f6758daabcb28e290ac00ae287888831e
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.42-py3-none-any.whl

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

Release history Release notifications | RSS feed

0.2.43

2 release files

This release

0.2.42 This release

2 release files

0.2.41

2 release files

0.2.39

2 release files

0.2.38

2 release files

0.2.37

2 release files

0.2.36

2 release files

0.2.35

2 release files

0.2.34

2 release files

0.2.30

2 release files

0.2.29

2 release files

0.2.28

2 release files

0.2.26

2 release files

0.2.25

2 release files

0.2.20

2 release files

0.2.19

2 release files

0.2.18

2 release files

0.2.14

2 release files

0.2.12

2 release files

0.2.11

2 release files

0.2.10

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.5

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

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