unterstein / binance-trader

Experimental trading bot for crypto currency on Binance.com
Apache License 2.0
274 stars 144 forks source link

0.9 currency problem #6

Open Jagermeister56 opened 6 years ago

Jagermeister56 commented 6 years ago

Can't trade for any currencies under 1.0 screen shot 2018-01-07 at 11 55 17 pm

unterstein commented 6 years ago

Hey @Jagermeister56,

thank you for reporting. Which parameter do you try to configure to 0.5?

Thanks Johannes

Jagermeister56 commented 6 years ago

for this example i used BTC as Base ETh as trading .06 Trade Amount .7% Profit

bnuccio commented 6 years ago

I came across this too. The coin amount is expecting an integer data type. .06 is a float, so code would need to be changed.

glennoid commented 6 years ago

I solved this in my version by changing the tradeAmount from int to double in BinanceTrader.java, as well as the amount variable in the client API wrapper TradingClient.java. String formatting also needs to be changed from %d to %.8f as applicable. I just starting using this, trading BTC against alts like DGD or others where I need fractional amounts (esp for testing).

Thanks for making this!!!

glennoid commented 6 years ago

.. as an update to my last comment, I realize there needs to be a little more logic in there with respect to trade amounts and balances < 1. I was trading with DGD and amount less than 1.. and after buying, the bot apparently forgot it had bought DGD and didn't sell. I tweaked this modified version a little more, changing the function tradingBalanceAvailable to check for > 0.001 instead of 1. BUT this caused problems when trading with other currencies that don't allow trading of fractional amounts. Not sure yet if there is a Binance function to also check the minimum trade amount for that currency, but if there is, we could use this instead of a hardcoded value.

dengo1905 commented 6 years ago

In class BinanceTrader

I have changed this (there is another check also): ("0".equals("" + tradingBalance.getLocked().charAt(0)) && lastAsk >= currentlyBoughtPrice)

to this:

("0.000".equals("" + tradingBalance.getLocked().substring(0,5)) && lastAsk >= currentlyBoughtPrice)