use of org.knowm.xchange.okex.v5.dto.trade.OkexOrderDetails in project XChange by knowm.
the class OkexAdapters method adaptUserTrades.
public static UserTrades adaptUserTrades(List<OkexOrderDetails> okexTradeHistory) {
List<UserTrade> userTradeList = new ArrayList<>();
okexTradeHistory.forEach(okexOrderDetails -> {
userTradeList.add(new UserTrade.Builder().originalAmount(new BigDecimal(okexOrderDetails.getAmount())).instrument(new CurrencyPair(okexOrderDetails.getInstrumentId())).currencyPair(new CurrencyPair(okexOrderDetails.getInstrumentId())).price(new BigDecimal(okexOrderDetails.getAverageFilledPrice())).type(adaptOkexOrderSideToOrderType(okexOrderDetails.getSide())).id(okexOrderDetails.getOrderId()).orderId(okexOrderDetails.getOrderId()).timestamp(Date.from(Instant.ofEpochMilli(Long.parseLong(okexOrderDetails.getUpdateTime())))).feeAmount(new BigDecimal(okexOrderDetails.getFee())).feeCurrency(new Currency(okexOrderDetails.getFeeCurrency())).orderUserReference(okexOrderDetails.getClientOrderId()).build());
});
return new UserTrades(userTradeList, Trades.TradeSortType.SortByTimestamp);
}
use of org.knowm.xchange.okex.v5.dto.trade.OkexOrderDetails in project XChange by knowm.
the class OkexTradeService method getOrder.
public Order getOrder(OrderQueryParams orderQueryParams) throws IOException {
Order result = null;
if (orderQueryParams instanceof OrderQueryParamInstrument) {
Instrument instrument = ((OrderQueryParamInstrument) orderQueryParams).getInstrument();
String orderId = orderQueryParams.getOrderId();
List<OkexOrderDetails> orderResults = getOkexOrder(OkexAdapters.adaptInstrumentId(instrument), orderId).getData();
if (!orderResults.isEmpty()) {
result = OkexAdapters.adaptOrder(orderResults.get(0));
}
} else {
throw new IOException("OrderQueryParams must implement OrderQueryParamInstrument interface.");
}
return result;
}
Aggregations