use of org.knowm.xchange.service.trade.params.DefaultTradeHistoryParamCurrencyPair in project XChange by knowm.
the class GateioTradeDemo method generic.
private static void generic(TradeService tradeService) throws IOException, InterruptedException {
LimitOrder limitOrder = new LimitOrder(OrderType.ASK, new BigDecimal("0.384"), CurrencyPair.LTC_BTC, "", null, new BigDecimal("0.0265"));
String orderId = tradeService.placeLimitOrder(limitOrder);
System.out.println(// Returned order id is currently broken for Gateio, rely on open orders instead//
orderId);
// for demo :(
// wait for Gateio's back-end to propagate the order
Thread.sleep(2000);
OpenOrders openOrders = tradeService.getOpenOrders();
System.out.println(openOrders);
List<LimitOrder> openOrdersList = openOrders.getOpenOrders();
if (!openOrdersList.isEmpty()) {
String existingOrderId = openOrdersList.get(0).getId();
boolean isCancelled = tradeService.cancelOrder(existingOrderId);
System.out.println(isCancelled);
}
// wait for Gateio's back-end to propagate the cancelled order
Thread.sleep(2000);
openOrders = tradeService.getOpenOrders();
System.out.println(openOrders);
Thread.sleep(2000);
Trades tradeHistory = tradeService.getTradeHistory(new DefaultTradeHistoryParamCurrencyPair(CurrencyPair.LTC_BTC));
System.out.println(tradeHistory);
}
use of org.knowm.xchange.service.trade.params.DefaultTradeHistoryParamCurrencyPair 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)));
}
use of org.knowm.xchange.service.trade.params.DefaultTradeHistoryParamCurrencyPair in project XChange by knowm.
the class TradeServiceIntegration method testHgetUserTrades.
@Test
public void testHgetUserTrades() throws Exception {
DefaultTradeHistoryParamCurrencyPair currencyPair = new DefaultTradeHistoryParamCurrencyPair();
currencyPair.setCurrencyPair(CurrencyPair.ETH_BTC);
UserTrades trades = tradeService.getTradeHistory(currencyPair);
logger.info("Response: {}", trades.getUserTrades());
}
Aggregations