Skip to main content

Ehdtd - cryptoCurrency Exchange history data to database

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ehdtd-0.2.39.tar.gz (42.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ehdtd-0.2.39-py3-none-any.whl (53.0 kB view details)

Uploaded Python 3

File details

Details for the file ehdtd-0.2.39.tar.gz.

File metadata

  • Download URL: ehdtd-0.2.39.tar.gz
  • Upload date:
  • Size: 42.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for ehdtd-0.2.39.tar.gz
Algorithm Hash digest
SHA256 0f36eaf21d36d2a4612c3b9eefafe9d7b52d1ca88d113e787cc0e623bd10f8f2
MD5 0ec07162b7507045459c2d4d4e476bda
BLAKE2b-256 7a1986099b5abd01e3f9d6a7d0f3ea8707f6a2c45aa0a50ef543a0295dcffe27

See more details on using hashes here.

File details

Details for the file ehdtd-0.2.39-py3-none-any.whl.

File metadata

  • Download URL: ehdtd-0.2.39-py3-none-any.whl
  • Upload date:
  • Size: 53.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for ehdtd-0.2.39-py3-none-any.whl
Algorithm Hash digest
SHA256 6ec702030478444a6aa04e1b39e744bf3f87f432104accd6dc370ec2e47a52f6
MD5 43e29453ba788c6384c0ff73f76a6aa6
BLAKE2b-256 cdff5c6f108067c0c66ba37e761db71bfdb0cc817ab673691b06d94894c18125

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page