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);
}
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"));
}
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);
}
Aggregations