Search in sources :

Example 1 with GateioTrade

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

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

the class GateioTradeService method getTradeHistory.

/**
 * Required parameter: {@link TradeHistoryParamCurrencyPair}
 */
@Override
public UserTrades getTradeHistory(TradeHistoryParams params) throws ExchangeException, IOException {
    CurrencyPair pair = ((TradeHistoryParamCurrencyPair) params).getCurrencyPair();
    List<GateioTrade> userTrades = getGateioTradeHistory(pair).getTrades();
    return GateioAdapters.adaptUserTrades(userTrades);
}
Also used : GateioTrade(org.knowm.xchange.gateio.dto.trade.GateioTrade) 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) DefaultTradeHistoryParamCurrencyPair(org.knowm.xchange.service.trade.params.DefaultTradeHistoryParamCurrencyPair) TradeHistoryParamCurrencyPair(org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair)

Aggregations

GateioTrade (org.knowm.xchange.gateio.dto.trade.GateioTrade)2 BigDecimal (java.math.BigDecimal)1 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)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 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