Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
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)
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)