Binance.API.Csharp.Client
Binance.API.Csharp.Client copied to clipboard
error -1100 on posting Order with decimal prices
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);
Same problem here...
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...
A more elegant solution is to change the culture info:
CultureInfo ci = new CultureInfo("en-US"); Thread.CurrentThread.CurrentCulture = ci; Thread.CurrentThread.CurrentUICulture = ci;
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
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.
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");