가상화폐 자동매매

 반복문과 조합하면 200일 이상의 데이터를 쉽게 얻어올 수 있습니다. 다음은 1000개의 데이터를 얻어옵니다.

import pandas as pd
import time

date = None
dfs = [ ]

for i in range(5):
    df = pyupbit.get_ohlcv("KRW-BTC", to=date)
    dfs.append(df)

    date = df.index[0]
    time.sleep(0.1)

df = pd.concat(dfs).sort_index()
print(len(df))

잔고 조회

get_balance 메서드는 입력받은 티커의 보유 수량 정보를 조회합니다.

print(upbit.get_balance("KRW-XRP"))     # KRW-XRP 조회
print(upbit.get_balance("KRW"))         # 보유 현금 조회

get_balances 메서드는 보유 중인 모든 암호화폐의 잔고 및 단가 정보를 딕셔너리로 조회합니다.

print(upbit.get_balances())
[{'currency': 'KRW',
  'balance': '0.34689181',
  'locked': '0.0',
  'avg_buy_price': '0',
  'avg_buy_price_modified': True,
  'unit_currency': 'KRW'},
 {'currency': 'BTC',
  'balance': '0.00174304',
  'locked': '0.0',
  'avg_buy_price': '64387000',
  'avg_buy_price_modified': False,
  'unit_currency': 'KRW'},]

Comments

Popular posts from this blog

Embracing Authentic Calm

Cultivating Emotional Resilience

The Power of Mindfulness