webcerebrium / java-binance-api

Java Binance API Client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ERROR: -1013, Filter failure: PRICE_FILTER

ryanbishop12 opened this issue · comments

im getting this error when i tried to do eth/btc after doing btc/usdt

@ThatPersonInTheMirror could you provide full piece of the code for this case please?

JSONArray data = new JSONArray(full.getJSONArray("data").toString());
BinanceApi api = new BinanceApi();
DecimalFormat btcusdt = new DecimalFormat("#.######");
DecimalFormat ethusdt = new DecimalFormat("#.#####");
DecimalFormat ethbtc = new DecimalFormat("#.###");
double btc = 50/data.getJSONObject(btc_usdtIndex).getDouble("sell")-(50/data.getJSONObject(btc_usdtIndex).getDouble("sell").001);
double eth = btc/data.getJSONObject(eth_btcIndex).getDouble("sell")-(btc/data.getJSONObject(eth_btcIndex).getDouble("sell")
.001);
double usdt = eth * data.getJSONObject(eth_usdtIndex).getDouble("sell")-(ethdata.getJSONObject(eth_usdtIndex).getDouble("sell").001);
System.out.println(btc + " - " + eth + " - "+ usdt);

		BinanceSymbol symbol = new BinanceSymbol("BTCUSDT");
		BinanceOrderPlacement placement = new BinanceOrderPlacement(symbol, BinanceOrderSide.BUY);
		placement.setType(BinanceOrderType.LIMIT);
		placement.setPrice(BigDecimal.valueOf(data.getJSONObject(btc_usdtIndex).getDouble("sell")));
		placement.setQuantity(BigDecimal.valueOf(Double.parseDouble(btcusdt.format(btc)))); // buy 10000 of asset for 0.00001 BTC
		BinanceOrder order = api.getOrderById(symbol, api.createOrder(placement).get("orderId").getAsLong());
		System.out.println(order.toString());
		
		while(!(new BinanceApi()).openOrders(BinanceSymbol.valueOf("BTCUSDT")).isEmpty())
		{
			
		}
		
		api = new BinanceApi();
		symbol = new BinanceSymbol("ETHBTC");
		placement = new BinanceOrderPlacement(symbol, BinanceOrderSide.BUY);
		placement.setType(BinanceOrderType.LIMIT);
		placement.setPrice(BigDecimal.valueOf(data.getJSONObject(eth_btcIndex).getDouble("sell")));
		placement.setQuantity(BigDecimal.valueOf(Double.parseDouble(ethbtc.format(eth)))); // buy 10000 of asset for 0.00001 BTC
		order = api.getOrderById(symbol, api.createOrder(placement).get("orderId").getAsLong());
		System.out.println(order.toString());
		
		while(!(new BinanceApi()).openOrders(BinanceSymbol.valueOf("ETHBTC")).isEmpty())
		{
			
		}
		
		api = new BinanceApi();
		symbol = new BinanceSymbol("ETHUSDT");
		placement = new BinanceOrderPlacement(symbol, BinanceOrderSide.SELL);
		placement.setType(BinanceOrderType.LIMIT);
		placement.setPrice(BigDecimal.valueOf(data.getJSONObject(eth_usdtIndex).getDouble("buy")));
		placement.setQuantity(BigDecimal.valueOf(Double.parseDouble(ethusdt.format(usdt)))); // buy 10000 of asset for 0.00001 BTC
		order = api.getOrderById(symbol, api.createOrder(placement).get("orderId").getAsLong());
		System.out.println(order.toString());
		
		while(!(new BinanceApi()).openOrders(BinanceSymbol.valueOf("ETHUSDT")).isEmpty())
		{
			
		}

this is as far as it gets

22:10:02.730 [main] DEBUG com.webcerebrium.binance.api.BinanceRequest - Signature: RequestUrl = https://www.binance.com/api/v3/order?symbol=BTCUSDT&side=BUY&type=LIMIT&quantity=0.005171&timeInForce=GTC&price=9660.0
22:10:02.780 [main] DEBUG com.webcerebrium.binance.api.BinanceRequest - Signature: query to be included = symbol=BTCUSDT&side=BUY&type=LIMIT&quantity=0.005171&timeInForce=GTC&price=9660.0&recvWindow=7000&timestamp=1518667802669 queryToAdd=recvWindow=7000&timestamp=1518667802669
22:10:02.787 [main] DEBUG com.webcerebrium.binance.api.BinanceRequest - POST https://www.binance.com/api/v3/order?symbol=BTCUSDT&side=BUY&type=LIMIT&quantity=0.005171&timeInForce=GTC&price=9660.0&recvWindow=7000&timestamp=1518667802669&signature=5f1a3fe005272ecb263bafcdbea09dd7ef1e7784c4dfa3dda75b16b0048d2b9b
22:10:03.614 [main] DEBUG com.webcerebrium.binance.api.BinanceRequest - Response: {"symbol":"BTCUSDT","orderId":45647551,"clientOrderId":"mji5BPXWrp7ZbC2kX65BIo","transactTime":1518667803074,"price":"9660.00000000","origQty":"0.00517100","executedQty":"0.00517100","status":"FILLED","timeInForce":"GTC","type":"LIMIT","side":"BUY"}
22:10:04.719 [main] DEBUG com.webcerebrium.binance.api.BinanceRequest - Signature: RequestUrl = https://www.binance.com/api/v3/order?symbol=BTCUSDT&orderId=45647551
22:10:04.719 [main] DEBUG com.webcerebrium.binance.api.BinanceRequest - Signature: query to be included = symbol=BTCUSDT&orderId=45647551&recvWindow=7000&timestamp=1518667804718 queryToAdd=recvWindow=7000&timestamp=1518667804718
22:10:04.720 [main] DEBUG com.webcerebrium.binance.api.BinanceRequest - GET https://www.binance.com/api/v3/order?symbol=BTCUSDT&orderId=45647551&recvWindow=7000&timestamp=1518667804718&signature=4128502c9211d25e202a530ac5854cc650cdf5d9a81a6cfc891ea800d77701b1
22:10:05.024 [main] DEBUG com.webcerebrium.binance.api.BinanceRequest - Response: {"symbol":"BTCUSDT","orderId":45647551,"clientOrderId":"mji5BPXWrp7ZbC2kX65BIo","price":"9660.00000000","origQty":"0.00517100","executedQty":"0.00517100","status":"FILLED","timeInForce":"GTC","type":"LIMIT","side":"BUY","stopPrice":"0.00000000","icebergQty":"0.00000000","time":1518667803074,"isWorking":true}
BinanceOrder(symbol=BTCUSDT, orderId=45647551, clientOrderId=mji5BPXWrp7ZbC2kX65BIo, price=9660.00000000, origQty=0.00517100, executedQty=0.00517100, status=FILLED, timeInForce=GTC, type=LIMIT, side=BUY, stopPrice=0E-8, icebergQty=0E-8, time=1518667803074)
22:10:09.428 [main] DEBUG com.webcerebrium.binance.api.BinanceRequest - Signature: RequestUrl = https://www.binance.com/api/v3/openOrders?symbol=BTCUSDT
22:10:09.428 [main] DEBUG com.webcerebrium.binance.api.BinanceRequest - Signature: query to be included = symbol=BTCUSDT&recvWindow=7000&timestamp=1518667809428 queryToAdd=recvWindow=7000&timestamp=1518667809428
22:10:09.428 [main] DEBUG com.webcerebrium.binance.api.BinanceRequest - GET https://www.binance.com/api/v3/openOrders?symbol=BTCUSDT&recvWindow=7000&timestamp=1518667809428&signature=ff3ad12db8dd98867a91734f0c3ce6f979e7a6d9e28ff3d205c9a04d330b7d4c
22:10:09.816 [main] DEBUG com.webcerebrium.binance.api.BinanceRequest - Response: []
22:10:09.912 [main] DEBUG com.webcerebrium.binance.api.BinanceRequest - Signature: RequestUrl = https://www.binance.com/api/v3/order?symbol=ETHBTC&side=BUY&type=LIMIT&quantity=0.054&timeInForce=GTC&price=0.09600012
22:10:09.912 [main] DEBUG com.webcerebrium.binance.api.BinanceRequest - Signature: query to be included = symbol=ETHBTC&side=BUY&type=LIMIT&quantity=0.054&timeInForce=GTC&price=0.09600012&recvWindow=7000&timestamp=1518667809912 queryToAdd=recvWindow=7000&timestamp=1518667809912
22:10:09.913 [main] DEBUG com.webcerebrium.binance.api.BinanceRequest - POST https://www.binance.com/api/v3/order?symbol=ETHBTC&side=BUY&type=LIMIT&quantity=0.054&timeInForce=GTC&price=0.09600012&recvWindow=7000&timestamp=1518667809912&signature=248be75e65ef1f1a6a72948e2074aead79712a8b62c4b84b11c0454a7a066b73
22:10:10.430 [main] DEBUG com.webcerebrium.binance.api.BinanceRequest - Response: {"code":-1013,"msg":"Filter failure: PRICE_FILTER"}

The issue seems to be related to the number of decimals in the price. It seems you must adjust explicitly the number of decimals in the second request.

This is the explanation that I've found on reddit regarding that issue, may be it could be helpful for you for resolving that:
https://www.reddit.com/r/BinanceExchange/comments/7ucllm/binance_api_error_1013_filter_failure_price_filter/

If you will find the solution that can help improving Order Placement part of this API wrapper, please do not hesitate to make Pull Requests.

But wouldn't that be the LOT_SIZE error, thats what im doing with the

DecimalFormat btcusdt = new DecimalFormat("#.######");
DecimalFormat ethusdt = new DecimalFormat("#.#####");
DecimalFormat ethbtc = new DecimalFormat("#.###");

i have it in the right format for the trade.

i figured out the problem i had to format the price too cause it had to many numbers