Binance API: APIError(code=-1111): Precision Is Over The Maximum Defined For This Asset. || Python
I have a trading bot which operates in 'ADAUSDT' with dynamic quantities for buying and selling, being my whole USDT balance the initial quantity, and trading with that same balance + profits or losses (it basically trades and keeps trading with the whole USDT balance over and over again). Here's some code:
from binance.client import Client import Keys #personal api keys client = Client(Keys.b_keys, Keys.b_secret) infoa = client.get_account() bal= infoa['balances'] i_o = float(bal["free"]) v_min = v_min #some value of ADA, for example: 1.2 order = client.create_order( symbol = "ADAUSDT" , side=SIDE_BUY , type=ORDER_TYPE_LIMIT , timeInForce = TIME_IN_FORCE_GTC , quantity = float(round((i_o) , 8)) , price = v_min , )
I know that the precision required both for the quoteAsset and for the baseAsset is 8, hence the usage of the
round() function in the quantity value for the order itself, but even after that, the API still throws me the error "Precision is over the maximum defined for this asset". Please help me :c
Edit: i_o is my "USDT" balance, which in theory should change with each trade, hence the usage of this variable instead of a plain number for the quantity of each order.
Note: I'm pretty noob at Python lol I just learned some basics a week ago, so it would be amazing if you could elaborate :D
Based on your code and a bit of familiarity with trading crypto I am assuming that the 'balance' you are calculating is your USDT balance and not your ADA balance via
i_o = float(bal["free"]) which would mean that you are placing a buy order for an amount of ADA equal to your current USDT balance (rounded) -- are you sure that's what you want to be doing?
To more directly answer your question as to why you are getting that error, I can only deduce that you must be calculating the price at which you would like to buy using a function that includes division and that your resultant
v_min is ending up being something like 1.32578935987532098325 and not 1.2.
Therefore, you would like to also round it, for your convenience:
price = float(round(v_min,8)) ,
- → What are the pluses/minuses of different ways to configure GPIOs on the Beaglebone Black?
- → Django, code inside <script> tag doesn't work in a template
- → React - Django webpack config with dynamic 'output'
- → GAE Python app - Does URL matter for SEO?
- → Put a Rendered Django Template in Json along with some other items
- → session disappears when request is sent from fetch
- → Python Shopify API output formatted datetime string in django template
- → Shopify app: adding a new shipping address via webhook
- → Shopify + Python library: how to create new shipping address
- → shopify python api: how do add new assets to published theme?
- → Access 'HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT' with Python Shopify Module