def timeout(self): cur_time = QTime.currentTime() str_time = cur_time.toString("hh:mm:ss") print(str_time) self.statusBar().showMessage(str_time) price = pykorbit.get_current_price("BTC") self.lineEdit_1.setText(str(price)) price = pykorbit.get_current_price("XRP") self.lineEdit_2.setText(str(price))
def inquiry(self): price = pykorbit.get_current_price("BTC") self.lineEdit.setText(str(price)) tesla = web.get_data_yahoo("TSLA", '2021-04-01') print("조회버튼 클릭") print(str(tesla))
def run(self): # 금액 조회 prices = [] for currency in currency_list: price = pykorbit.get_current_price(currency.lower() + "_krw") prices.append(price) # 일이 끝나면 시그널 emit self.worker_finished.emit(prices)
def set_open_range(self): logging.info("set_open_range") cur_time = QTime.currentTime().toString() self.textEdit.insertPlainText("시가/변동성 갱신 " + cur_time + "\n") low, high, last, vol = pykorbit.get_market_detail("btc_krw") self.range = (high - low) * 0.5 time.sleep(1) # ticker interval self.open = pykorbit.get_current_price("btc_krw") self.target = self.open + self.range
def run(self): now = datetime.datetime.now() sec = 3600 * now.hour + 60 * now.minute + now.second coin_idx = sec % len(COINS) coin_name = COINS[coin_idx] # To avoid ticker rate limit (1/sec) if g_ticker_is_used is False: coin_price = pykorbit.get_current_price(coin_name) if coin_price is not None: self.finished.emit(coin_idx, coin_name, coin_price)
def run(self): # 코인 현재가 price_list = [] rate_list = [] for coin in COIN: price = pykorbit.get_current_price(coin) rate = self.get_rate_24(coin) time.sleep(0.2) price_list.append(price) rate_list.append(rate) # 시그널 발생 self.finished.emit(price_list, rate_list)
def timeout(self): cur_time = QTime.currentTime() str_time = cur_time.toString("hh:mm:ss") self.statusBar().showMessage(str_time) price = pykorbit.get_current_price("BTC") th_price = str(int(price / 1000000)) hu_price = str(int((price / 1000) % 1000)) no_price = str(int(price % 1000)) hu_price = hu_price.zfill(3) no_price = no_price.zfill(3) self.lineEdit.setText(th_price + "," + hu_price + "," + no_price) price = pykorbit.get_current_price("ETH") th_price = str(int(price / 1000000)) hu_price = str(int((price / 1000) % 1000)) no_price = str(int(price % 1000)) hu_price = hu_price.zfill(3) no_price = no_price.zfill(3) self.lineEdit_ETH.setText(th_price + "," + hu_price + "," + no_price)
def get_market_state(currency, window): try: symbol = currency[:3].upper() df = pykorbit.history.get_daily_ohlc(symbol=symbol) ma = df['close'].rolling(window=window).mean() cur_price = pykorbit.get_current_price(currency) ma_price = ma[-1] if cur_price > ma_price: return "상승장" else: return "하락장" except: return "N/A"
def run(self): # 코인 현재가 price_list = [] rate_list = [] state_list = [] # bull market/bear market for coin in COIN: price = pykorbit.get_current_price(coin) rate = self.get_rate_24(coin) state = self.get_market_state(coin, window=5) time.sleep(0.2) price_list.append(price) rate_list.append(rate) state_list.append(state) # 시그널 발생 self.finished.emit(price_list, rate_list, state_list)
def inquiry(self): price = pykorbit.get_current_price("BTC") print(price)
def inquiry(self): price = pykorbit.get_current_price("BTC") self.lineEdit.setText(str(price))
import pykorbit #----------------------------------------------------------------------------------------------------------------------- # 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))
def btn_clicked2(self): price = pykorbit.get_current_price("XRP") self.lineEdit_2.setText(str(price)) print(price)
def btn_clicked1(self): price = pykorbit.get_current_price("BTC") self.lineEdit_1.setText(str(price)) print(price)
def get_btc_price(self): current_time = QTime.currentTime().toString("hh:mm:ss") self.statusBar().showMessage(current_time) # 하단 상태바에 업데이트 시간을 보여줍니다. price = pykorbit.get_current_price("BTC") self.text_show_btc_price.setText(str(price))
def inquiry(self): BTC = pykorbit.get_current_price("BTC") ETH = pykorbit.get_current_price("ETH") self.lineEdit.setText(str(BTC)) self.lineEdit_2.setText(str(ETH))
def run(self): price = pykorbit.get_current_price("BTC") print(price)
while True: now = datetime.datetime.now() logger.info("-" * 80) logger.info("현재시간: {}".format(now)) logger.info("갱신시간: {}".format(refresh_time)) # 30분에 한 번씩 refresh token if (now - refresh_time) > datetime.timedelta(minutes=30): logger.info("코빗 토큰 갱신 (30분): {0}".format(now)) korbit.renew_access_token() refresh_time = now # 09:01:00 ~ 09:01:10 if time1 < now < time2: try_sell(now) target = cal_target() ma5 = cal_moving_average(window=5) time1, time2 = make_times(now) time.sleep(10) price = pykorbit.get_current_price("BTC") logger.info("현재가 : {}".format(price)) logger.info("목표가 : {}".format(target)) logger.info("이동평균: {}".format(ma5)) if price is not None: try_buy(now, price, target, ma5) time.sleep(0.2)
def try_buy(self): logging.info("try_buy {}".format(self.target)) if self.target is not None and self.get_btc_balance() == 0: btc_cur_price = pykorbit.get_current_price("btc_krw") if btc_cur_price is not None and btc_cur_price > self.target: self.buy()
def inquiry(self): price = pykorbit.get_current_price("BTC") self.lineEdit_1.setText(str(price)) price2 = pykorbit.get_current_price("ETH") self.lineEdit_2.setText(str(price2))
def run(self): btc_price = pykorbit.get_current_price("BTC") # 비트코인 현재가 조회 if isinstance(btc_price, float): # 금액 조회가 정상적인 경우에만 self.finished.emit(btc_price) # 일이 끝났음을 알려줌