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
data
is not used,
and columnstatus
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.
- 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
ehdtd-0.2.20.tar.gz
(36.3 kB
view details)
Built Distribution
ehdtd-0.2.20-py3-none-any.whl
(52.3 kB
view details)
File details
Details for the file ehdtd-0.2.20.tar.gz
.
File metadata
- Download URL: ehdtd-0.2.20.tar.gz
- Upload date:
- Size: 36.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
bb18da57ed5f28b899ecb947ef2ca827b0543ca58e67dba0f3b05be0d0e30e49
|
|
MD5 |
0d3e8b75588690125252dbda409df31f
|
|
BLAKE2b-256 |
1732275a351d69c787cc9c0348dc94fc2a9a26c27409b22b8be42e2048aa2f7a
|
File details
Details for the file ehdtd-0.2.20-py3-none-any.whl
.
File metadata
- Download URL: ehdtd-0.2.20-py3-none-any.whl
- Upload date:
- Size: 52.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
696cb1deb9af50a889cfc3f93966d4de7fde006b7c30333eb6f18d350c6fa8a0
|
|
MD5 |
24530df3e85c57521e26e9a03d095eda
|
|
BLAKE2b-256 |
a4c57bf7969f81ddfe178dbf82fbe18ff72df45ea689f12310c29304a890c747
|