use of org.knowm.xchange.service.trade.params.orders.DefaultOpenOrdersParamCurrencyPair in project XChange by knowm.
the class CoinbeneTradeDemo method generic.
public static void generic(Exchange exchange) throws IOException {
CurrencyPair pair = CurrencyPair.BTC_USDT;
TradeService tradeService = exchange.getTradeService();
// Get open orders
OpenOrders orders = tradeService.getOpenOrders(new DefaultOpenOrdersParamCurrencyPair(pair));
LimitOrder order = orders.getOpenOrders().stream().collect(StreamUtils.singletonCollector());
if (order != null) {
System.out.println(order);
}
}
use of org.knowm.xchange.service.trade.params.orders.DefaultOpenOrdersParamCurrencyPair in project XChange by knowm.
the class TradeServiceIntegration method testCgetOpenOrdersByMarketTest.
@Test
public void testCgetOpenOrdersByMarketTest() throws Exception {
DefaultOpenOrdersParamCurrencyPair currencyPair = new DefaultOpenOrdersParamCurrencyPair();
currencyPair.setCurrencyPair(CurrencyPair.ETH_BTC);
OpenOrders openOrders = tradeService.getOpenOrders(currencyPair);
logger.info("Response: {}", openOrders);
}
use of org.knowm.xchange.service.trade.params.orders.DefaultOpenOrdersParamCurrencyPair in project XChange by knowm.
the class GeminiTradeServiceTest method openOrdersByCurrencyPairTest.
@Test
public void openOrdersByCurrencyPairTest() throws Exception {
stubFor(post(urlPathEqualTo("/v1/orders")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBodyFile(ORDERS_FILE_NAME)));
DefaultOpenOrdersParamCurrencyPair defaultOpenOrdersParamCurrencyPair = new DefaultOpenOrdersParamCurrencyPair(CurrencyPair.BTC_USD);
OpenOrders openOrders = classUnderTest.getOpenOrders(defaultOpenOrdersParamCurrencyPair);
assertThat(openOrders).isNotNull();
assertThat(openOrders.getOpenOrders().size()).isEqualTo(1);
LimitOrder firstOrder = openOrders.getOpenOrders().get(0);
assertThat(firstOrder).isNotNull();
assertThat(firstOrder.getOriginalAmount()).isNotNull().isPositive();
assertThat(firstOrder.getId()).isNotBlank();
assertThat(firstOrder.getInstrument()).isEqualTo(CurrencyPair.BTC_USD);
}
use of org.knowm.xchange.service.trade.params.orders.DefaultOpenOrdersParamCurrencyPair in project XChange by knowm.
the class CoinbaseProTradeServiceTest method openOrdersByProductTest.
@Test
public void openOrdersByProductTest() throws Exception {
final ObjectMapper mapper = new ObjectMapper();
JsonNode jsonRoot = mapper.readTree(this.getClass().getResource("/" + WIREMOCK_FILES_PATH + "/" + OPENORDERS_FILE_NAME));
stubFor(get(urlPathEqualTo("/orders")).withQueryParam("status", equalTo("open")).withQueryParam("product_id", equalTo("BTC-USD")).willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json").withBodyFile("openOrders.json")));
DefaultOpenOrdersParamCurrencyPair defaultOpenOrdersParamCurrencyPair = new DefaultOpenOrdersParamCurrencyPair(CurrencyPair.BTC_USD);
OpenOrders openOrders = classUnderTest.getOpenOrders(defaultOpenOrdersParamCurrencyPair);
assertThat(openOrders).isNotNull();
assertThat(openOrders.getOpenOrders()).hasSize(jsonRoot.size());
LimitOrder firstOrder = openOrders.getOpenOrders().get(0);
assertThat(firstOrder).isNotNull();
assertThat(firstOrder.getOriginalAmount()).isNotNull().isPositive();
assertThat(firstOrder.getId()).isNotBlank();
assertThat(firstOrder.getInstrument()).isEqualTo(CurrencyPair.BTC_USD);
}
use of org.knowm.xchange.service.trade.params.orders.DefaultOpenOrdersParamCurrencyPair in project XChange by knowm.
the class BithumbTradeDemo method generic.
private static void generic(TradeService tradeService) throws IOException, InterruptedException {
log.debug("{}", "----------GENERIC----------");
final OpenOrdersParams openOrders = new DefaultOpenOrdersParamCurrencyPair(CURRENCY_PAIR);
try {
log.debug("{}", tradeService.getOpenOrders(openOrders));
} catch (ExchangeException e) {
log.debug("", e);
}
final TradeHistoryParams tradeHistoryParams = new DefaultTradeHistoryParamCurrencyPair(CURRENCY_PAIR);
log.debug("{}", tradeService.getTradeHistory(tradeHistoryParams));
final LimitOrder limitOrderBuy = new LimitOrder.Builder(Order.OrderType.BID, CURRENCY_PAIR).originalAmount(BigDecimal.valueOf(10)).limitPrice(BigDecimal.valueOf(100)).build();
log.debug("{}", tradeService.placeLimitOrder(limitOrderBuy));
// wait for order to propagate
Thread.sleep(3000);
final LimitOrder limitOrderSell = new LimitOrder.Builder(Order.OrderType.ASK, CURRENCY_PAIR).originalAmount(BigDecimal.valueOf(10)).limitPrice(BigDecimal.valueOf(600)).build();
log.debug("{}", tradeService.placeLimitOrder(limitOrderSell));
// wait for order to propagate
Thread.sleep(3000);
tradeService.getOpenOrders(openOrders).getOpenOrders().stream().map(Order::getId).map(orderId -> new CancelOrderByPairAndIdParams() {
@Override
public String getOrderId() {
return orderId;
}
@Override
public CurrencyPair getCurrencyPair() {
return CURRENCY_PAIR;
}
}).forEach(param -> {
try {
log.debug("{}", tradeService.cancelOrder(param));
} catch (IOException ignored) {
}
});
// log.debug("{}",tradeService.placeMarketOrder(new MarketOrder(Order.OrderType.ASK,
// BigDecimal.valueOf(10), CURRENCY_PAIR)));
}
Aggregations