Skip to content

get_balance 메서드의 verbose 옵션에서의 반환 값 이상 #83

@mr-yoo

Description

@mr-yoo

verbose 옵션은 딕셔너리로 서버가 반환하는 값을 그대로 출력해야 한다. get_balance 메서드에서 verbose 옵션으로 리플의 잔고를 조회하는 경우를 살펴 봅시다.

upbit.get_balance(ticker="XRP", verbose=True)

리플을 보유하고 있다면 딕셔너리로 출력되지만 보유하지 않은 경우 0이 반환된다. 내부에서 초기값을 0으로 설정하고 값을 반복문 내부에서 데이터를 채워넣는데, 리플을 보유하고 있지 않아 조건을 충족하지 않으므로 초기값 0이 그대로 반환된다.

balance = 0
for x in balances:
    if x['currency'] == ticker and x['unit_currency'] == fiat:
        if verbose is True:
            balance = x 
        else:
            balance = float(x['balance'])
        break

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions