Binance.API.Csharp.Client icon indicating copy to clipboard operation
Binance.API.Csharp.Client copied to clipboard

error -1100 on posting Order with decimal prices

Open cbernardino81 opened this issue 7 years ago • 6 comments

using the code

var sellOrder = await client.PostNewOrder("trxbtc", 100m, 0.00000500m, OrderSide.SELL,OrderType.LIMIT); the api is send the error : "Api Error Code: -1100 Message: Illegal characters found in parameter 'price'; legal range is '^([0-9]{1,20})(\.[0-9]{1,20})?$'."

If i use int number the same code works fine ex : var sellOrder = await client.PostNewOrder("trxbtc", 100m, 1m, OrderSide.SELL,OrderType.LIMIT);

cbernardino81 avatar Jan 24 '18 10:01 cbernardino81

Same problem here...

kimlage avatar Jan 27 '18 04:01 kimlage

I solved getting the source code and looking at the posted query string. It seams the problem is with the decimal format. When it sends the value with "," (coma) instead of "." (dot). I just replaced it. like below:

public async Task<NewOrder> PostNewOrder(string symbol, decimal quantity, decimal price, OrderSide side, OrderType orderType = OrderType.LIMIT, TimeInForce timeInForce = TimeInForce.GTC, decimal icebergQty = 0m, long recvWindow = 5000) { //Validates that the order is valid. ValidateOrderValue(symbol, orderType, price, quantity, icebergQty);

        var args = $"symbol={symbol.ToUpper()}&side={side}&type={orderType}&quantity={quantity.ToString().Replace(",",".")}"
            + (orderType == OrderType.LIMIT ? $"&timeInForce={timeInForce}" : "")
            + (orderType == OrderType.LIMIT ? $"&price={price.ToString().Replace(",", ".")}" : "")
            + (icebergQty > 0m ? $"&icebergQty={icebergQty}" : "")
            + $"&recvWindow={recvWindow}";
        var result = await _apiClient.CallAsync<NewOrder>(ApiMethod.POST, EndPoints.NewOrder, true, args);

        return result;
    }

Probably not the best solution but it worked... hope it helps...

kimlage avatar Jan 27 '18 13:01 kimlage

A more elegant solution is to change the culture info:

CultureInfo ci = new CultureInfo("en-US"); Thread.CurrentThread.CurrentCulture = ci; Thread.CurrentThread.CurrentUICulture = ci;

kimlage avatar Jan 27 '18 14:01 kimlage

Hi, can you tell me where I need to go to edit the source code as I am having the same issue? I am using VS2017, I am pretty new to this but I have most things working apart from this decimal issue. Also, when you use GetOrderInfo can you retrieve the price of an order? I can get everything but the price... Thanks

mdobson8 avatar Jan 27 '18 23:01 mdobson8

I too need help solving this issue. Is there a different way we can write the numbers? / can someone show an example of how to write e.g: 0.0000087 in a way that doesnt result in this error (signedRequest error: {"code":-1100,"msg":"Illegal characters found in parameter 'price'; legal range is '^([0-9]{1,20})(\.[0-9]{1,20})?$'."}) please.

RobArnold999 avatar Apr 05 '18 11:04 RobArnold999

Hi, guys! I fixed problem by changing of localization:

using System.Threading; using System.Globalization;

Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");

avysotsky avatar Apr 19 '18 17:04 avysotsky