How to use the pyupbit.get_ohlcv function in pyupbit

To help you get started, weโ€™ve selected a few pyupbit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sharebook-kr / cryptocurrency-trading-bot / upbit / level2 / main.py View on Github external
while True:
    now = datetime.datetime.now()

    # ๋งค๋„ (08:50:00~08:50:10)
    if now.hour == 8 and now.minute == 50 and (0 <= now.second <= 10):
        if hold is True:
            coin_size = upbit.get_balance(TICKER)
            upbit.sell_market_order(TICKER, coin_size)
            hold = False
            break_out_range = None  # ๋‹ค์Œ ๋ชฉํ‘œ๊ฐ€ ๊ฐฑ์‹ ๊นŒ์ง€ ๋งค์ˆ˜๋˜์ง€ ์•Š๋„๋ก

        time.sleep(10)

    # ๋ชฉํ‘œ๊ฐ€ ๊ฐฑ์‹  (09:01:00~09:01:10)
    if now.hour == 9 and now.minute == 1 and (0 <= now.second <= 10):
        df = pyupbit.get_ohlcv(TICKER)
        k = noise.get_average_noise_ratio(df)
        break_out_range = larry.get_break_out_range(df, k)
        betting_ratio = betting.get_betting_ratio(df, break_out_range, NUM_COINS)

        # ์ •์ƒ์ ์œผ๋กœ break out range๋ฅผ ์–ป์€ ๊ฒฝ์šฐ
        if break_out_range is not None and betting_ratio is not None:
            time.sleep(10)

    # ๋งค์ˆ˜ ์‹œ๋„
    cur_price = pyupbit.get_current_price(TICKER)
    if hold is False and cur_price is not None and break_out_range is not None and cur_price >= break_out_range:
        krw_balance = upbit.get_balance(FIAT)
        upbit.buy_market_order(TICKER, krw_balance * betting_ratio)
        hold = True

    # ์ƒํƒœ ์ถœ๋ ฅ
github sharebook-kr / cryptocurrency-trading-bot / upbit / level2 / larry.py View on Github external
if date in df.index:
            today = df.iloc[-1]
            yesterday = df.iloc[-2]
            gap = yesterday['high'] - yesterday['low']
            break_out_range = today['open'] + gap * k
            return break_out_range
        else:
            return None
    except:
        return None


if __name__ == "__main__":
    ticker = "KRW-BTC"
    df = pyupbit.get_ohlcv(ticker)
    break_out_range = get_break_out_range(df)
    print(break_out_range)

pyupbit

python wrapper for Upbit API

Apache-2.0
Latest version published 2 years ago

Package Health Score

48 / 100
Full package analysis