use of org.knowm.xchange.binance.dto.BinanceException in project XChange by knowm.
the class BinanceTradeService method getOpenOrders.
@Override
public OpenOrders getOpenOrders(OpenOrdersParams params) throws IOException {
try {
List<BinanceOrder> binanceOpenOrders;
if (params instanceof OpenOrdersParamCurrencyPair) {
OpenOrdersParamCurrencyPair pairParams = (OpenOrdersParamCurrencyPair) params;
CurrencyPair pair = pairParams.getCurrencyPair();
binanceOpenOrders = super.openOrders(pair);
} else {
binanceOpenOrders = super.openOrders();
}
List<LimitOrder> limitOrders = new ArrayList<>();
List<Order> otherOrders = new ArrayList<>();
binanceOpenOrders.forEach(binanceOrder -> {
Order order = BinanceAdapters.adaptOrder(binanceOrder);
if (order instanceof LimitOrder) {
limitOrders.add((LimitOrder) order);
} else {
otherOrders.add(order);
}
});
return new OpenOrders(limitOrders, otherOrders);
} catch (BinanceException e) {
throw BinanceErrorAdapter.adapt(e);
}
}
use of org.knowm.xchange.binance.dto.BinanceException in project XChange by knowm.
the class BinanceTradeService method placeOrder.
private String placeOrder(OrderType type, Order order, BigDecimal limitPrice, BigDecimal stopPrice, TimeInForce tif) throws IOException {
try {
Long recvWindow = (Long) exchange.getExchangeSpecification().getExchangeSpecificParametersItem("recvWindow");
BinanceNewOrder newOrder = newOrder(order.getCurrencyPair(), BinanceAdapters.convert(order.getType()), type, tif, order.getOriginalAmount(), limitPrice, getClientOrderId(order), stopPrice, null, null);
return Long.toString(newOrder.orderId);
} catch (BinanceException e) {
throw BinanceErrorAdapter.adapt(e);
}
}
use of org.knowm.xchange.binance.dto.BinanceException in project XChange by knowm.
the class BinanceAccountService method getAccountInfo.
@Override
public AccountInfo getAccountInfo() throws IOException {
try {
BinanceAccountInformation acc = account();
List<Balance> balances = acc.balances.stream().map(b -> new Balance(b.getCurrency(), b.getTotal(), b.getAvailable())).collect(Collectors.toList());
return new AccountInfo(new Date(acc.updateTime), Wallet.Builder.from(balances).build());
} catch (BinanceException e) {
throw BinanceErrorAdapter.adapt(e);
}
}
Aggregations