mirror of
https://github.com/aljazceru/hummingbot-dashboard.git
synced 2026-01-21 14:14:28 +01:00
(feat) add method to cache candles
This commit is contained in:
@@ -1,5 +1,18 @@
|
||||
import streamlit as st
|
||||
import pandas as pd
|
||||
|
||||
from CONFIG import BACKEND_API_HOST, BACKEND_API_PORT
|
||||
from backend.services.backend_api_client import BackendAPIClient
|
||||
|
||||
|
||||
def get_max_records(days_to_download: int, interval: str) -> int:
|
||||
conversion = {"s": 1 / 60, "m": 1, "h": 60, "d": 1440}
|
||||
unit = interval[-1]
|
||||
quantity = int(interval[:-1])
|
||||
return int(days_to_download * 24 * 60 / (quantity * conversion[unit]))
|
||||
|
||||
|
||||
@st.cache_data
|
||||
def get_candles(connector_name="binance", trading_pair="BTC-USDT", interval="1m", max_records=5000):
|
||||
backend_client = BackendAPIClient(BACKEND_API_HOST, BACKEND_API_PORT)
|
||||
return pd.DataFrame(backend_client.get_real_time_candles(connector_name, trading_pair, interval, max_records))
|
||||
|
||||
Reference in New Issue
Block a user