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

Filter failure: PERCENT_PRICE #46

Open
silahian opened this issue Jan 23, 2021 · 2 comments
Open

Filter failure: PERCENT_PRICE #46

silahian opened this issue Jan 23, 2021 · 2 comments

Comments

@silahian
Copy link

silahian commented Jan 23, 2021

Binance is returning the error "Filter failure: PERCENT_PRICE" when sending an order.
We checked on their documentation and the issue is the max allowance for decimal places in your order prices and sizes

Is anyone else having this same issue?
The issue is in "BinaCPP::send_order" when building the post to send the order, the price and size are being converted to string using to_string.... but no way to control the decimal places in there.

@silahian
Copy link
Author

In case this happened to anyone else.... What we ended up doing is the following:
We change the signature of BinaCPP::send_order to
BinaCPP::send_order(
const char *symbol,
const char *side,
const char *type,
const char *timeInForce,
string quantity,
string price,
const char *newClientOrderId,
double stopPrice,
double icebergQty,
long recvWindow,
Json::Value &json_result )

And then we created a function to translate the price and sizes before sending it to BinaCPP::send_order
inline string to_string(double val, int decimalPlaces)
{
std::ostringstream oss;
oss << std::setprecision(decimalPlaces) << std::noshowpoint << val;
return oss.str();

}

Hope this helps. Comments on this are welcome

@carbofos
Copy link

carbofos commented Mar 14, 2021

I confirm the bug. While sending the order quantity 89.8 the result is:

2021-03-14 14:52:12 468030 :BinaCPP::send_order url = |https://api.binance.com/api/v3/order?|, post_data = |symbol=LITUSDT&side=SELL&type=LIMIT&timeInForce=FOK&price=10.869900&quantity=89.799998&...

The problem is std::to_string(double) in BinaCPP::send_order().
The next code did fix it for me:

std::ostringstream out;
out << quantity;
post_data.append( out.str() );

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

No branches or pull requests

2 participants