use of org.knowm.xchange.service.trade.TradeService 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.TradeService in project XChange by knowm.
the class CoindirectTradeDemo method main.
public static void main(String[] args) throws IOException {
Exchange exchange = CoindirectDemoUtils.createExchange();
/* create a data service from the exchange */
TradeService tradeService = exchange.getTradeService();
generic(exchange, tradeService);
raw((CoindirectExchange) exchange, (CoindirectTradeService) tradeService);
}
use of org.knowm.xchange.service.trade.TradeService in project XChange by knowm.
the class TradeServiceIntegrationTransactionsCreateOrder method getOrder.
// getOrder(String... orderIds)
// trades
private static void getOrder() throws IOException {
String apiKey = "00af0b38-11fb-4aab-bf19-45edd44a4adc";
String secretKey = "fa3f0510-155f-4567-a3b3-3f386080efa3";
Exchange coinsuper = ExchangeFactory.INSTANCE.createExchange(CoinsuperExchange.class);
ExchangeSpecification exchangeSpecification = coinsuper.getExchangeSpecification();
exchangeSpecification.setApiKey(apiKey);
exchangeSpecification.setSecretKey(secretKey);
coinsuper.applySpecification(exchangeSpecification);
TradeService tradeService = coinsuper.getTradeService();
try {
String orderNoList = "1608661340536594433,1608661662038384641";
Collection<Order> openOrders = tradeService.getOrder(orderNoList);
System.out.printf("Open Orders for %s: %s%n", orderNoList, openOrders);
} catch (IOException e) {
e.printStackTrace();
}
}
use of org.knowm.xchange.service.trade.TradeService in project XChange by knowm.
the class TradeServiceIntegrationTransactionsCreateOrder method createMarketOrder.
private static void createMarketOrder() throws IOException {
String apiKey = "00af0b38-11fb-4aab-bf19-45edd44a4adc";
String secretKey = "fa3f0510-155f-4567-a3b3-3f386080efa3";
Exchange coinsuper = ExchangeFactory.INSTANCE.createExchange(CoinsuperExchange.class);
ExchangeSpecification exchangeSpecification = coinsuper.getExchangeSpecification();
exchangeSpecification.setApiKey(apiKey);
exchangeSpecification.setSecretKey(secretKey);
coinsuper.applySpecification(exchangeSpecification);
TradeService tradeService = coinsuper.getTradeService();
try {
// place a limit buy order
MarketOrder marketOrder = new MarketOrder((OrderType.BID), new BigDecimal("30513299.8408"), CurrencyPair.XRP_BTC, null, null, null, null, null, null);
String result = tradeService.placeMarketOrder(marketOrder);
System.out.println("createMarketOrder return value: " + result);
} catch (IOException e) {
e.printStackTrace();
}
}
use of org.knowm.xchange.service.trade.TradeService in project XChange by knowm.
the class TradeServiceIntegrationTransactionsCreateOrder method cancelOrder.
private static void cancelOrder() throws IOException {
String apiKey = "00af0b38-11fb-4aab-bf19-45edd44a4adc";
String secretKey = "fa3f0510-155f-4567-a3b3-3f386080efa3";
Exchange coinsuper = ExchangeFactory.INSTANCE.createExchange(CoinsuperExchange.class);
ExchangeSpecification exchangeSpecification = coinsuper.getExchangeSpecification();
exchangeSpecification.setApiKey(apiKey);
exchangeSpecification.setSecretKey(secretKey);
coinsuper.applySpecification(exchangeSpecification);
TradeService tradeService = coinsuper.getTradeService();
try {
// Cancel the added order
String orderId = "1608586238226747393";
boolean cancelResult = tradeService.cancelOrder(orderId);
System.out.println("Canceling returned " + cancelResult);
} catch (IOException e) {
e.printStackTrace();
}
}
Aggregations