Search in sources :

Example 1 with GateioOrderStatus

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

the class GateioTradeDemo method raw.

private static void raw(GateioTradeServiceRaw tradeService) throws IOException, InterruptedException {
    String placedOrderId = tradeService.placeGateioLimitOrder(CurrencyPair.LTC_BTC, GateioOrderType.SELL, new BigDecimal("0.0265"), new BigDecimal("0.384"));
    System.out.println(placedOrderId);
    // wait for Gateio's back-end to propagate the order
    Thread.sleep(2000);
    GateioOpenOrders openOrders = tradeService.getGateioOpenOrders();
    System.out.println(openOrders);
    List<GateioOpenOrder> openOrdersList = openOrders.getOrders();
    if (!openOrdersList.isEmpty()) {
        String existingOrderId = openOrdersList.get(0).getId();
        GateioOrderStatus orderStatus = tradeService.getGateioOrderStatus(existingOrderId, CurrencyPair.LTC_BTC);
        System.out.println(orderStatus);
        boolean isCancelled = tradeService.cancelOrder(existingOrderId, CurrencyPairDeserializer.getCurrencyPairFromString(openOrdersList.get(0).getCurrencyPair()));
        System.out.println(isCancelled);
    }
    // wait for Gateio's back-end to propagate the cancelled order
    Thread.sleep(2000);
    openOrders = tradeService.getGateioOpenOrders();
    System.out.println(openOrders);
    List<GateioTrade> tradeHistory = tradeService.getGateioTradeHistory(CurrencyPair.LTC_BTC).getTrades();
    System.out.println(tradeHistory);
}
Also used : GateioOpenOrders(org.knowm.xchange.gateio.dto.trade.GateioOpenOrders) GateioTrade(org.knowm.xchange.gateio.dto.trade.GateioTrade) GateioOpenOrder(org.knowm.xchange.gateio.dto.trade.GateioOpenOrder) GateioOrderStatus(org.knowm.xchange.gateio.dto.trade.GateioOrderStatus) BigDecimal(java.math.BigDecimal)

Aggregations

BigDecimal (java.math.BigDecimal)1 GateioOpenOrder (org.knowm.xchange.gateio.dto.trade.GateioOpenOrder)1 GateioOpenOrders (org.knowm.xchange.gateio.dto.trade.GateioOpenOrders)1 GateioOrderStatus (org.knowm.xchange.gateio.dto.trade.GateioOrderStatus)1 GateioTrade (org.knowm.xchange.gateio.dto.trade.GateioTrade)1