def cal_moving_average(window=5): try: df = pykorbit.get_ohlc("BTC") close = df['close'] ma = close.rolling(window=window).mean() return ma[-1] except: return None
def cal_target(): try: df = pykorbit.get_ohlc("BTC") yesterday = df.iloc[-1] today_open = yesterday['close'] yesterday_high = yesterday['high'] yesterday_low = yesterday['low'] target = today_open + (yesterday_high - yesterday_low) * 0.5 return target except: return None
def __init__(self): self.history = { "XRP": [], "BTC": [], "BCH": [], "ETC": [], "ETH": [], "LTC": [] } for coin in COINS: df = pykorbit.get_ohlc(symbol=coin, period=5) close = df['close'] if not close.empty: self.history[coin] = [x for x in close] print(self.history)
#----------------------------------------------------------------------------------------------------------------------- # Public API #----------------------------------------------------------------------------------------------------------------------- print(pykorbit.get_current_price("BTC")) print(pykorbit.get_market_detail("BTC")) print(pykorbit.get_orderbook("BTC")) print(pykorbit.get_transaction_data("BTC")) print(pykorbit.get_constants()) #----------------------------------------------------------------------------------------------------------------------- # Private API #----------------------------------------------------------------------------------------------------------------------- f = open("keys.csv") lines = f.readlines() f.close() key = lines[1].split(',')[0] secret = lines[1].split(',')[1] korbit = pykorbit.Korbit("*****@*****.**", "your-pass-word", key, secret) # 주문 제약 조건 print(korbit._get_tick_size("BTC")) print(korbit._get_quantity_min_max("BTC")) print(korbit._get_price_min_max("BTC")) #----------------------------------------------------------------------------------------------------------------------- # history #----------------------------------------------------------------------------------------------------------------------- print(pykorbit.get_ohlc("BTC", start="2018-02-01", end="2018-02-03")) print(pykorbit.get_ohlc("BTC", period=5)) print(pykorbit.get_ohlc("BTC", end="2018-02-03", period=5))
import pykorbit df = pykorbit.get_ohlc("BTC") print(df)