crypto-walk / services /market.py
pymmdrza's picture
Update services/market.py
c91aea2 verified
raw
history blame contribute delete
519 Bytes
import time
from api.kucoin import KuCoinClient
def get_market_data(symbol: str, timeframe: str, session) -> "MarketData":
granularity_map = {"15m": 15, "1h": 60, "4h": 240, "1d": 1440}
granularity = granularity_map.get(timeframe, 15)
now = int(time.time() * 1000)
start = now - (2 * 24 * 60 * 60 * 1000)
return KuCoinClient(session).get_kline_data(symbol, granularity, start, now)
def get_current_price(symbol: str, session) -> float:
return KuCoinClient(session).get_current_price(symbol)