How to use pyupbit - 8 common examples

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 / manager.py View on Github external
def create_instance():
    with open("upbit.txt") as f:
        lines = f.readlines()
        key = lines[0].strip()
        secret = lines[1].strip()

    inst = pyupbit.Upbit(key, secret)
    return inst
github sharebook-kr / cryptocurrency-trading-bot / upbit / simple / manager.py View on Github external
def create_instance():
    with open("upbit.txt") as f:
        lines = f.readlines()
        key = lines[0].strip()
        secret = lines[1].strip()

    inst = pyupbit.Upbit(key, secret)
    return inst
github sharebook-kr / cryptocurrency-trading-bot / upbit / simple / main.py View on Github external
upbit.sell_market_order(TICKER, coin_size)
            hold = False
            break_out_range = None                      # 다음 목표가 갱신까지 매수되지 않도록

        time.sleep(10)

    # 목표가 갱신
    if now.hour == 9 and now.minute == 0 and (0 <= now.second <= 10):
        break_out_range = larry.get_break_out_range(TICKER)

        # 정상적으로 break out range를 얻은 경우
        if break_out_range 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)
        hold = True

    # 상태 출력
    manager.print_status(now, TICKER, hold, break_out_range, cur_price)
    time.sleep(1)
github sharebook-kr / cryptocurrency-trading-bot / upbit / level3 / trade.py View on Github external
def try_buy(upbit, ticker, status):
    cur_price = pyupbit.get_current_price(ticker)

    for hour in range(24):
        hold = status[hour][0]                                  # 해당 시간대 보유 여부
        target = status[hour][1]                                # 해당 시간대 목표가
        betting_ratio = status[hour][2]                         # 해당 시간대 배팅률

        # 해당 시간대에 보유 코인이 없고
        # 해당 시간대에 목표가가 설정되어 있고
        # 현재가 > 해당 시간대의 목표가
        if hold is False and target is not None and cur_price > target:
            remained_krw_balance = upbit.get_balance("KRW")             # 원화잔고 조회
            hold_count = sum([x[0] for x in status.values()])           # 각 시간대별 보유 상태

            krw_balance_for_time_frame = remained_krw_balance / (24-hold_count)                 # 타임 프레임 별 투자 금액
            coin_size = upbit.buy_market_order(ticker, krw_balance_for_time_frame * betting_ratio)
github sharebook-kr / cryptocurrency-trading-bot / upbit / level2 / main.py View on Github external
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

    # 상태 출력
    manager.print_status(now, TICKER, hold, break_out_range, cur_price, betting_ratio)
    time.sleep(1)
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)
github sharebook-kr / cryptocurrency-trading-bot / upbit / level3 / trade.py View on Github external
def set_break_out_range(ticker, status, hour):
    df = pyupbit.get_daily_ohlcv_from_base(ticker, base=hour)
    k = noise.get_average_noise_ratio(df, days=9)
    break_out_range = larry.get_break_out_range(df, k)
    betting_ratio = betting.get_betting_ratio(df, break_out_range, num_coins=1)

    status[hour][1] = break_out_range                           # 해당 시간대 목표가 설정
    status[hour][2] = betting_ratio                             # 해당 시간대 베팅 비율
    time.sleep(10)

pyupbit

python wrapper for Upbit API

Apache-2.0
Latest version published 5 months ago

Package Health Score

64 / 100
Full package analysis