Search in sources :

Example 16 with OpenOrders

use of org.knowm.xchange.dto.trade.OpenOrders in project XChange by knowm.

the class TradeServiceIntegrationTransactionsCreateOrder method printOpenOrders.

private static void printOpenOrders(TradeService tradeService, OpenOrdersParams openOrdersParams) throws IOException {
    OpenOrders openOrders = tradeService.getOpenOrders(openOrdersParams);
    System.out.printf("Open Orders for %s: %s%n", openOrdersParams, openOrders);
}
Also used : OpenOrders(org.knowm.xchange.dto.trade.OpenOrders)

Example 17 with OpenOrders

use of org.knowm.xchange.dto.trade.OpenOrders in project XChange by knowm.

the class PoloniexTradeDemo method printOpenOrders.

private static void printOpenOrders(TradeService tradeService) throws Exception {
    TimeUnit.SECONDS.sleep(2);
    final OpenOrdersParamCurrencyPair params = (OpenOrdersParamCurrencyPair) tradeService.createOpenOrdersParams();
    OpenOrders openOrders = tradeService.getOpenOrders(params);
    System.out.printf("All open Orders: %s%n", openOrders);
    params.setCurrencyPair(currencyPair);
    openOrders = tradeService.getOpenOrders(params);
    System.out.printf("Open Orders for %s: %s%n: ", params, openOrders);
    params.setCurrencyPair(REP_ETH);
    openOrders = tradeService.getOpenOrders(params);
    System.out.printf("Open Orders for %s: %s%n: ", params, openOrders);
}
Also used : OpenOrders(org.knowm.xchange.dto.trade.OpenOrders) OpenOrdersParamCurrencyPair(org.knowm.xchange.service.trade.params.orders.OpenOrdersParamCurrencyPair)

Example 18 with OpenOrders

use of org.knowm.xchange.dto.trade.OpenOrders in project XChange by knowm.

the class DragonexTradeService method getOpenOrders.

@Override
public OpenOrders getOpenOrders(OpenOrdersParams params) throws IOException {
    if (!(params instanceof OpenOrdersParamCurrencyPair)) {
        throw new ExchangeException("You need to provide the currency pair.");
    }
    OpenOrdersParamCurrencyPair pairParams = (OpenOrdersParamCurrencyPair) params;
    if (pairParams.getCurrencyPair() == null) {
        throw new ExchangeException("You need to provide the currency pair.");
    }
    long symbolId = exchange.symbolId(pairParams.getCurrencyPair());
    OrderHistoryRequest req = new OrderHistoryRequest(symbolId, null, null, 1000, 1);
    OrderHistory orderHistory = super.orderHistory(exchange.getOrCreateToken().token, req);
    List<LimitOrder> openOrders = orderHistory.getList().stream().map(o -> new LimitOrder(o.orderType == 1 ? OrderType.BID : OrderType.ASK, o.volume, exchange.pair(o.symbolId), Long.toString(o.orderId), o.getTimestamp(), o.price)).collect(Collectors.toList());
    return new OpenOrders(openOrders);
}
Also used : TradeHistoryParams(org.knowm.xchange.service.trade.params.TradeHistoryParams) OrderType(org.knowm.xchange.dto.Order.OrderType) CancelOrderByCurrencyPair(org.knowm.xchange.service.trade.params.CancelOrderByCurrencyPair) DefaultTradeHistoryParamCurrencyPair(org.knowm.xchange.service.trade.params.DefaultTradeHistoryParamCurrencyPair) Exchange(org.knowm.xchange.Exchange) OrderHistory(org.knowm.xchange.dragonex.dto.trade.OrderHistory) TradeSortType(org.knowm.xchange.dto.marketdata.Trades.TradeSortType) DealHistoryRequest(org.knowm.xchange.dragonex.dto.trade.DealHistoryRequest) OrderHistoryRequest(org.knowm.xchange.dragonex.dto.trade.OrderHistoryRequest) CancelOrderByIdParams(org.knowm.xchange.service.trade.params.CancelOrderByIdParams) OpenOrders(org.knowm.xchange.dto.trade.OpenOrders) OpenOrdersParamCurrencyPair(org.knowm.xchange.service.trade.params.orders.OpenOrdersParamCurrencyPair) DealHistory(org.knowm.xchange.dragonex.dto.trade.DealHistory) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) DefaultOpenOrdersParamCurrencyPair(org.knowm.xchange.service.trade.params.orders.DefaultOpenOrdersParamCurrencyPair) IOException(java.io.IOException) UserTrades(org.knowm.xchange.dto.trade.UserTrades) OrderReference(org.knowm.xchange.dragonex.dto.trade.OrderReference) UserTrade(org.knowm.xchange.dto.trade.UserTrade) Collectors(java.util.stream.Collectors) ExchangeException(org.knowm.xchange.exceptions.ExchangeException) UserOrder(org.knowm.xchange.dragonex.dto.trade.UserOrder) OrderPlacement(org.knowm.xchange.dragonex.dto.trade.OrderPlacement) List(java.util.List) Order(org.knowm.xchange.service.trade.params.TradeHistoryParamsSorted.Order) TradeService(org.knowm.xchange.service.trade.TradeService) TradeHistoryParamsSorted(org.knowm.xchange.service.trade.params.TradeHistoryParamsSorted) OpenOrdersParams(org.knowm.xchange.service.trade.params.orders.OpenOrdersParams) CancelOrderParams(org.knowm.xchange.service.trade.params.CancelOrderParams) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) TradeHistoryParamCurrencyPair(org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair) OrderHistoryRequest(org.knowm.xchange.dragonex.dto.trade.OrderHistoryRequest) ExchangeException(org.knowm.xchange.exceptions.ExchangeException) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) OpenOrders(org.knowm.xchange.dto.trade.OpenOrders) OrderHistory(org.knowm.xchange.dragonex.dto.trade.OrderHistory) OpenOrdersParamCurrencyPair(org.knowm.xchange.service.trade.params.orders.OpenOrdersParamCurrencyPair) DefaultOpenOrdersParamCurrencyPair(org.knowm.xchange.service.trade.params.orders.DefaultOpenOrdersParamCurrencyPair)

Example 19 with OpenOrders

use of org.knowm.xchange.dto.trade.OpenOrders in project XChange by knowm.

the class DVChainAdapters method adaptOpenOrders.

public static OpenOrders adaptOpenOrders(List<DVChainTrade> orders) {
    List<LimitOrder> openOrders = new ArrayList<>(orders.size());
    for (DVChainTrade order : orders) {
        CurrencyPair currencyPair = new CurrencyPair(order.getAsset(), "USD");
        Order.OrderType orderType = order.getSide().equals("buy") ? Order.OrderType.BID : Order.OrderType.ASK;
        LimitOrder limitOrder = new LimitOrder(orderType, order.getQuantity(), order.getQuantity(), currencyPair, order.getId(), Date.from(order.getCreatedAt()), order.getLimitPrice());
        openOrders.add(limitOrder);
    }
    return new OpenOrders(openOrders);
}
Also used : LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) Order(org.knowm.xchange.dto.Order) DVChainTrade(org.knowm.xchange.dvchain.dto.trade.DVChainTrade) ArrayList(java.util.ArrayList) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) OpenOrders(org.knowm.xchange.dto.trade.OpenOrders) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Example 20 with OpenOrders

use of org.knowm.xchange.dto.trade.OpenOrders in project XChange by knowm.

the class HuobiAdapters method adaptOpenOrders.

public static OpenOrders adaptOpenOrders(HuobiOrder[] openOrders) {
    List<LimitOrder> limitOrders = new ArrayList<>();
    for (HuobiOrder openOrder : openOrders) {
        if (openOrder.isLimit()) {
            LimitOrder order = (LimitOrder) adaptOrder(openOrder);
            limitOrders.add(order);
        }
    }
    return new OpenOrders(limitOrders);
}
Also used : ArrayList(java.util.ArrayList) HuobiOrder(org.knowm.xchange.huobi.dto.trade.HuobiOrder) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) OpenOrders(org.knowm.xchange.dto.trade.OpenOrders)

Aggregations

OpenOrders (org.knowm.xchange.dto.trade.OpenOrders)117 LimitOrder (org.knowm.xchange.dto.trade.LimitOrder)79 Test (org.junit.Test)40 BigDecimal (java.math.BigDecimal)36 ArrayList (java.util.ArrayList)33 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)31 TradeService (org.knowm.xchange.service.trade.TradeService)26 Date (java.util.Date)23 Order (org.knowm.xchange.dto.Order)21 OrderType (org.knowm.xchange.dto.Order.OrderType)20 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)16 MarketOrder (org.knowm.xchange.dto.trade.MarketOrder)15 UserTrades (org.knowm.xchange.dto.trade.UserTrades)14 OpenOrdersParamCurrencyPair (org.knowm.xchange.service.trade.params.orders.OpenOrdersParamCurrencyPair)14 Exchange (org.knowm.xchange.Exchange)13 DefaultOpenOrdersParamCurrencyPair (org.knowm.xchange.service.trade.params.orders.DefaultOpenOrdersParamCurrencyPair)12 TradeHistoryParamCurrencyPair (org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair)10 InputStream (java.io.InputStream)9 List (java.util.List)9 StopOrder (org.knowm.xchange.dto.trade.StopOrder)8