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:
- Try to retrieve data from a file. Check this link:
Binance Public Data - If the file is not available, try to retrieve data from the API.
- 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
datais not used,
and columnstatuscan 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.
- If
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ehdtd-0.2.37.tar.gz.
File metadata
- Download URL: ehdtd-0.2.37.tar.gz
- Upload date:
- Size: 36.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6afbc4f8cb87d8a3d3a2eca2fdc179d8ac82231b8419f55bbcb48b8865c3983
|
|
| MD5 |
231ea1447f9bff676a24fd48211a20bb
|
|
| BLAKE2b-256 |
69437962eb1ce88ebaf3f393d405c6e387c9b8485e73fd511a276bc2339f9724
|
File details
Details for the file ehdtd-0.2.37-py3-none-any.whl.
File metadata
- Download URL: ehdtd-0.2.37-py3-none-any.whl
- Upload date:
- Size: 53.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1fc3e3564dbc2874b029e041b876b28eefeaa10ff9edff4da90cb1356b374ef7
|
|
| MD5 |
8c0925102779323a8a716fe0774e3e46
|
|
| BLAKE2b-256 |
0017d224bab6c03820b45e80a5fe8a94cf85b3793a7be7a21496b91229b49cc0
|