Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Illegal characters found in parameter #8

Closed
sanchoflat opened this issue Dec 25, 2017 · 2 comments
Closed

Illegal characters found in parameter #8

sanchoflat opened this issue Dec 25, 2017 · 2 comments
Assignees
Labels

Comments

@sanchoflat
Copy link

sanchoflat commented Dec 25, 2017

Hi.
I wrote some programm, it works for me on win10 and VS2017. But my friend can't launch it. He uses win10 and VS2017 too. When i use something like this,

var res = api.PlaceAsync(new LimitOrder(user)
            {
                Symbol = Symbol.BTC_USDT,
                Side = OrderSide.Buy,
                Quantity = 0.0001m,
                Price = 11500

            }).Result;

I fails with exception:

Inner Exception 1:
BinanceHttpException: [BadRequest]: 'Bad Request' - Illegal characters found in parameter 'quantity'; legal range is '^([0-9]{1,20})(\.[0-9]{1,20})?$'. (-1100)

What could it be? Thanks!

@sanchoflat
Copy link
Author

sanchoflat commented Dec 26, 2017

I'm trying to run it on Win8 and VS2017 and I have the same problem. I start debugging and found some difference in request parameters:
This is my request and it works.

{Method: POST, RequestUri: '/api/v3/order?symbol=BTCUSDT&side=BUY&type=LIMIT&newOrderRespType=RESULT&quantity=0.0001&price=11500&timeInForce=GTC&timestamp=1514277360683&signature=FA4F1C101303FE8ABF5268DDB4FD6B8B00938A4BA079E9F11BFA6D71211D0403', Version: 1.1, Content: <null>, Headers:
{
  X-MBX-APIKEY: ...
}}

This is request on win8 and win10 on another PC:

{Method: POST, RequestUri: 'https://www.binance.com/api/v3/order?symbol=BTCUSDT&side=BUY&type=LIMIT&newOrderRespType=RESULT&quantity=0,0001&price=11500&timeInForce=GTC&timestamp=1514277175548&signature=845D9A211F2336E4A80E9FDCEF66C3BD8F8D5BE898FEF07CB34D607B5936453C', Version: 1.1, Content: <null>, Headers:
{
  X-MBX-APIKEY: ...
  User-Agent: Binance/1.0.0
  User-Agent: (.NET; +https://github.com/sonvister/Binance)
}}

And it fails. The reason was in quantity=0,0001. The problem was in ",". And I replace
request.AddParameter("quantity", quantity);
to
request.AddParameter("quantity", quantity.ToString().Replace(",", "."));

What can you say about? Thx.

@sonvister sonvister self-assigned this Dec 26, 2017
@sonvister
Copy link
Owner

The issue is the decimal to string conversion with ToString() that uses CurrentCulture.NumberFormat with a NumberDecimalSeparator property value of "," rather than "." depending upon location. I'll specify CultureInfo.InvariantCulture (which uses ".") in the decimal to string conversion to fix this. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants