yasinkuyu / binance-trader

💰 Cryptocurrency Trading Bot for Binance (Experimental)
2.53k stars 830 forks source link

Possible to check balance to sell remains #217

Closed Maathouse closed 6 years ago

Maathouse commented 6 years ago

Hi!

Does someone know a part of code to check the balance of the currency you're trading? It happens to me sometimes that the bot is too late to cancel an buy order so it gets filled but it won't sell it again (due to server lag?)

What I would like to do:

I can figure out how to do the last two parts but I don't know how to check the current free balance. Any suggestions?

Thanks in advance!

Maathouse

Maathouse commented 6 years ago

Found it! I created by own balance checker from the get_balance code in 'Orders.py':

#balance checker
@staticmethod
def get_balance_symbol(symbolbalance):
    try:

        balances = client.get_account()
        balances['balances'] = {item['asset']: item for item in balances['balances']}

        return balances['balances'][symbolbalance]['free']

    except Exception as e:
        print ('gb: %s' % (e))

To let it work, you should add symbolbalance as an parser argument in the trader.py. And add the variable 'symbolbalance'

Good luck for the ones who need it!

pitxels commented 6 years ago

@Maathouse I think what you suggest would make a nice loop Can you share the changes you did in the code?

Thanks

Maathouse commented 6 years ago

I still have to do that but the above code can be used to check your balance. Also add:

parser.add_argument('--symbolbalance', type=str, help='Market Symbol (Ex: INS)', default=symbolbalance)

to the trader.py file and replace 'symbolbalance' by the symbol you want to check the balance from like INS as stated above.

78bash commented 3 years ago

Could we please have this written up for a pull request by someone?