Search in sources :

Example 1 with OkexOrderDetails

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);
}
Also used : UserTrades(org.knowm.xchange.dto.trade.UserTrades) Currency(org.knowm.xchange.currency.Currency) OkexCurrency(org.knowm.xchange.okex.v5.dto.marketdata.OkexCurrency) ArrayList(java.util.ArrayList) UserTrade(org.knowm.xchange.dto.trade.UserTrade) BigDecimal(java.math.BigDecimal) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Example 2 with OkexOrderDetails

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;
}
Also used : Order(org.knowm.xchange.dto.Order) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) OkexOrderDetails(org.knowm.xchange.okex.v5.dto.trade.OkexOrderDetails) OpenOrdersParamInstrument(org.knowm.xchange.service.trade.params.orders.OpenOrdersParamInstrument) CancelOrderByInstrument(org.knowm.xchange.service.trade.params.CancelOrderByInstrument) TradeHistoryParamInstrument(org.knowm.xchange.service.trade.params.TradeHistoryParamInstrument) OrderQueryParamInstrument(org.knowm.xchange.service.trade.params.orders.OrderQueryParamInstrument) Instrument(org.knowm.xchange.instrument.Instrument) IOException(java.io.IOException) OrderQueryParamInstrument(org.knowm.xchange.service.trade.params.orders.OrderQueryParamInstrument)

Aggregations

IOException (java.io.IOException)1 BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 Currency (org.knowm.xchange.currency.Currency)1 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)1 Order (org.knowm.xchange.dto.Order)1 LimitOrder (org.knowm.xchange.dto.trade.LimitOrder)1 UserTrade (org.knowm.xchange.dto.trade.UserTrade)1 UserTrades (org.knowm.xchange.dto.trade.UserTrades)1 Instrument (org.knowm.xchange.instrument.Instrument)1 OkexCurrency (org.knowm.xchange.okex.v5.dto.marketdata.OkexCurrency)1 OkexOrderDetails (org.knowm.xchange.okex.v5.dto.trade.OkexOrderDetails)1 CancelOrderByInstrument (org.knowm.xchange.service.trade.params.CancelOrderByInstrument)1 TradeHistoryParamInstrument (org.knowm.xchange.service.trade.params.TradeHistoryParamInstrument)1 OpenOrdersParamInstrument (org.knowm.xchange.service.trade.params.orders.OpenOrdersParamInstrument)1 OrderQueryParamInstrument (org.knowm.xchange.service.trade.params.orders.OrderQueryParamInstrument)1