cnfuyu / python-binance-api

A Python 2/3 client for the Binance REST and WebSocket APIs
https://www.binance.com/restapipub.html
MIT License
34 stars 14 forks source link

function to get balance return [] ? #7

Open pabloapdz opened 4 years ago

pabloapdz commented 4 years ago

I'm trying get my BTC asset balance, but not works... I'm using this code:

from binance.client import BinanceRESTAPI, BinanceWebSocketAPI
from binance.models import DepthCache

api_key = 'f9....4Ml4TxO4'
secret_key = 'tm.....S5RrfzC9GvHDYf'

rest_client = BinanceRESTAPI(api_key, secret_key)
ws_client = BinanceWebSocketAPI(api_key)

account = rest_client.account()
for balance in account.balances:
    print(balance.asset, balance.free, balance.locked)

Which was supposed to return me all my balances, right? But nothing happens ... account.balances = []

What is going wrong? (And how would you return only from the BTC wallet?)

Note: I tried both python 3.6 and python 3.8

oliver-zehentleitner commented 4 years ago

This repo is unmaintained and binance changed the protocol a few weeks ago. i am not shure, that this repo is still working.

Anyway, for the REST API I recommend using python-binance: https://github.com/sammchardy/python-binance

For the Websocket API I recommend unicorn-binance-websocket-api: https://github.com/oliver-zehentleitner/unicorn-binance-websocket-api