(feat) update pages

This commit is contained in:
cardosofede
2025-07-11 02:57:57 +03:00
parent 91cd3d0365
commit e44fa89283
39 changed files with 6036 additions and 780 deletions

View File

@@ -3,8 +3,7 @@ import datetime
import pandas as pd
import streamlit as st
from backend.services.backend_api_client import BackendAPIClient
from CONFIG import BACKEND_API_HOST, BACKEND_API_PORT
from frontend.st_utils import get_backend_api_client
def get_max_records(days_to_download: int, interval: str) -> int:
@@ -16,12 +15,18 @@ def get_max_records(days_to_download: int, interval: str) -> int:
@st.cache_data
def get_candles(connector_name="binance", trading_pair="BTC-USDT", interval="1m", days=7):
backend_client = BackendAPIClient(BACKEND_API_HOST, BACKEND_API_PORT)
end_time = datetime.datetime.now() - datetime.timedelta(minutes=15)
start_time = end_time - datetime.timedelta(days=days)
df = pd.DataFrame(backend_client.get_historical_candles(connector_name, trading_pair, interval,
start_time=int(start_time.timestamp()),
end_time=int(end_time.timestamp())))
df.index = pd.to_datetime(df.timestamp, unit='s')
backend_client = get_backend_api_client()
# Use the market_data.get_candles_last_days method
candles = backend_client.market_data.get_candles_last_days(
connector_name=connector_name,
trading_pair=trading_pair,
days=days,
interval=interval
)
# Convert the response to DataFrame (response is a list of candles)
df = pd.DataFrame(candles)
if not df.empty and 'timestamp' in df.columns:
df.index = pd.to_datetime(df.timestamp, unit='s')
return df