21jake / Binance-volatility-trading-bot-JS

This Binance trading bot detects the most volatile cryptos to buy and later sell at predefined Take Profit / Stop Loss thresholds.
MIT License
35 stars 6 forks source link

Account with insufficient balance warning is scary #6

Closed daddywookie closed 3 years ago

daddywookie commented 3 years ago

Receiving the following warning is very scary

Error in executing buying volatiles function: "Error in executing buy function: {\"code\":-2010,\"msg\":\"Account has insufficient balance for requested action.\"}"

Maybe this can be caught and replaced with something friendlier?

Tried to buy but there was not enough funds available

21jake commented 3 years ago

The message

{\"code\":-2010,\"msg\":\"Account has insufficient balance for requested action.\"}"

is an original message from Binance API, therefore we should not change it. They might inform this message or a different one, and it would be quite a mistake to assume that the error always comes from the balance having not enough funds. In the future, I or someone might map our own responses accordingly to Binance's status code tho something like

const mapCodeToResponse = {
-2010: "Tried to buy but there was not enough funds available",
-2011: "Another response to another error"
...
}

But for now, the original message would be enough

daddywookie commented 3 years ago

OK, I'll throw this in the "nice to have" pile for later