0

I send an order to buy binance, an error arrives in response:

{"code":-1111,"msg":"Precision is over the maximum defined for this asset."}

Here's how the quanity is calculated:

string  quanyty = Convert.ToString(Math.Round(Balance()/PriceCTSIBTC(),8));//balance/Price = 10.5673824567

The request looks like this:

var request = new RestRequest("/api/v3/order", Method.POST);
                request.AddHeader("X-MBX-APIKEY", apikey);
                request.AddQueryParameter("symbol", "CTSIBTC");
                request.AddQueryParameter("side", "BUY");
                request.AddQueryParameter("type", "STOP_LOSS_LIMIT");
                request.AddQueryParameter("timeInForce", "GTC");
                request.AddQueryParameter("quantity", quanyty);
                request.AddQueryParameter("price", price);
                request.AddQueryParameter("timestamp", timestamp);
                request.AddQueryParameter("signature", CreateSignature(request.Parameters, secret));
                request.AddQueryParameter("stopPrice", stopPrice);
                var response = client.Get(request);

At first I was rounding with Math.Floor() , then implemented through Math.Round(). The error did not go away.

Keks
  • 1
  • If the field is defined in the database as a number than you should not convert results to a string. – jdweng May 08 '21 at 09:32
  • Убрал преобразования , появилась ошибка `Argument 2: cannot convert from 'decimal' to 'string' ` – Keks May 08 '21 at 09:35
  • See following : https://stackoverflow.com/questions/32643093/difference-between-restsharp-methods-addparameter-and-addqueryparameter-using-ht – jdweng May 08 '21 at 09:44

1 Answers1

1

You need to use the correct precision for the prices and the quantity for the pair you are trading. For example, ETHUSD uses 2 decimal places on price and 5 decimal places on quantity. You can use syntax like this to format your numbers the way the API expects them

"{:0.0{}f}".format(1.2345, 2)

You can also use the API to look up the quantity precision which is called the stepSize under the LOT_SIZE filters.

StevenWhite
  • 5,907
  • 3
  • 21
  • 46