Comments (6)
i figured out the problem i had to format the price too cause it had to many numbers
from java-binance-api.
@ThatPersonInTheMirror could you provide full piece of the code for this case please?
from java-binance-api.
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())
{
}
from java-binance-api.
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×tamp=1518667802669 queryToAdd=recvWindow=7000×tamp=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×tamp=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×tamp=1518667804718 queryToAdd=recvWindow=7000×tamp=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×tamp=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×tamp=1518667809428 queryToAdd=recvWindow=7000×tamp=1518667809428
22:10:09.428 [main] DEBUG com.webcerebrium.binance.api.BinanceRequest - GET https://www.binance.com/api/v3/openOrders?symbol=BTCUSDT&recvWindow=7000×tamp=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×tamp=1518667809912 queryToAdd=recvWindow=7000×tamp=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×tamp=1518667809912&signature=248be75e65ef1f1a6a72948e2074aead79712a8b62c4b84b11c0454a7a066b73
22:10:10.430 [main] DEBUG com.webcerebrium.binance.api.BinanceRequest - Response: {"code":-1013,"msg":"Filter failure: PRICE_FILTER"}
from java-binance-api.
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.
from java-binance-api.
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.
from java-binance-api.
Related Issues (20)
- ERROR: -1111, Precision is over the maximum defined for this asset. HOT 2
- Logback HOT 2
- Websocket API depth with level doesn't work
- ERROR: -1013, Filter failure: PRICE_FILTER HOT 3
- BinanceApiException: timestamp for this request is outside of recwindow HOT 1
- UserDataStream disconnecting?
- ORDER_WOULD_TRIGGER_IMMEDIATELY not present in OrderRejectReason
- Binance api update
- Exception throws with the latest Binance update when calling exchangeInfo
- Trade with PAX or TUSD
- Cannot deserialize value of type `java.lang.Long` from String "9534.95000000"
- Get price market into websocket
- Placing a TAKE_PROFIT_LIMIT order
- Guys whats the long value for StartTime/EndTime in Aggtrades call ? is is "secondssince1970' as usual ?
- Use this library on testnet
- What is MIN_NOTIONAL Error
- How to get all historical data from a specific asset?
- getting connection refused Exception using web socket
- MARKET_LOT_SIZE error (code = -1013 HOT 1
- help!
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from java-binance-api.