File size: 519 Bytes
ce3b1e8
 
 
 
c91aea2
 
 
 
 
 
ce3b1e8
 
 
c91aea2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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)