Search in sources :

Example 1 with GateioOpenOrders

use of org.knowm.xchange.gateio.dto.trade.GateioOpenOrders 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)

Example 2 with GateioOpenOrders

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

the class GateioAdapterTest method testAdaptOpenOrders.

@Test
public void testAdaptOpenOrders() throws IOException {
    // Read in the JSON from the example resources
    InputStream is = GateioAdapterTest.class.getResourceAsStream("/org/knowm/xchange/gateio/dto/trade/example-order-list-data.json");
    // Use Jackson to parse it
    ObjectMapper mapper = new ObjectMapper();
    GateioOpenOrders openOrders = mapper.readValue(is, GateioOpenOrders.class);
    OpenOrders adaptedOpenOrders = GateioAdapters.adaptOpenOrders(openOrders, currencyPairs);
    List<LimitOrder> adaptedOrderList = adaptedOpenOrders.getOpenOrders();
    assertThat(adaptedOrderList).hasSize(2);
    LimitOrder adaptedOrder = adaptedOrderList.get(0);
    assertThat(adaptedOrder.getType()).isEqualTo(OrderType.ASK);
    assertThat(adaptedOrder.getOriginalAmount()).isEqualTo(new BigDecimal("100000"));
    assertThat(adaptedOrder.getCurrencyPair()).isEqualTo(CurrencyPair.ETH_BTC);
    assertThat(adaptedOrder.getId()).isEqualTo("0");
    assertThat(adaptedOrder.getLimitPrice()).isEqualTo(new BigDecimal("0.0693"));
}
Also used : GateioOpenOrders(org.knowm.xchange.gateio.dto.trade.GateioOpenOrders) InputStream(java.io.InputStream) OpenOrders(org.knowm.xchange.dto.trade.OpenOrders) GateioOpenOrders(org.knowm.xchange.gateio.dto.trade.GateioOpenOrders) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 3 with GateioOpenOrders

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

the class GateioTradeService method getOpenOrders.

@Override
public OpenOrders getOpenOrders(OpenOrdersParams params) throws IOException {
    GateioOpenOrders openOrders = super.getGateioOpenOrders();
    Collection<CurrencyPair> currencyPairs = exchange.getExchangeSymbols();
    return GateioAdapters.adaptOpenOrders(openOrders, currencyPairs);
}
Also used : GateioOpenOrders(org.knowm.xchange.gateio.dto.trade.GateioOpenOrders) CancelOrderByCurrencyPair(org.knowm.xchange.service.trade.params.CancelOrderByCurrencyPair) DefaultTradeHistoryParamCurrencyPair(org.knowm.xchange.service.trade.params.DefaultTradeHistoryParamCurrencyPair) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) TradeHistoryParamCurrencyPair(org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair)

Aggregations

GateioOpenOrders (org.knowm.xchange.gateio.dto.trade.GateioOpenOrders)3 BigDecimal (java.math.BigDecimal)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 InputStream (java.io.InputStream)1 Test (org.junit.Test)1 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)1 LimitOrder (org.knowm.xchange.dto.trade.LimitOrder)1 OpenOrders (org.knowm.xchange.dto.trade.OpenOrders)1 GateioOpenOrder (org.knowm.xchange.gateio.dto.trade.GateioOpenOrder)1 GateioOrderStatus (org.knowm.xchange.gateio.dto.trade.GateioOrderStatus)1 GateioTrade (org.knowm.xchange.gateio.dto.trade.GateioTrade)1 CancelOrderByCurrencyPair (org.knowm.xchange.service.trade.params.CancelOrderByCurrencyPair)1 DefaultTradeHistoryParamCurrencyPair (org.knowm.xchange.service.trade.params.DefaultTradeHistoryParamCurrencyPair)1 TradeHistoryParamCurrencyPair (org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair)1