use of org.knowm.xchange.dto.trade.LimitOrder in project XChange by knowm.
the class CoinfloorOrderBookIntegration method fetchOrderBookTest.
@Test
public void fetchOrderBookTest() throws IOException {
Exchange exchange = ExchangeFactory.INSTANCE.createExchange(CoinfloorExchange.class);
MarketDataService service = exchange.getMarketDataService();
OrderBook orderBook = service.getOrderBook(CurrencyPair.BTC_GBP);
assertThat(orderBook.getBids()).isNotEmpty();
assertThat(orderBook.getAsks()).isNotEmpty();
LimitOrder order = orderBook.getBids().get(0);
assertThat(order.getCurrencyPair()).isEqualTo(CurrencyPair.BTC_GBP);
assertThat(order.getOriginalAmount()).isGreaterThan(BigDecimal.ZERO);
assertThat(order.getLimitPrice()).isGreaterThan(BigDecimal.ZERO);
}
use of org.knowm.xchange.dto.trade.LimitOrder in project XChange by knowm.
the class CoingiTradeService method getOrder.
@Override
public Collection<Order> getOrder(String... orderIds) throws IOException {
try {
Collection<Order> orders = new ArrayList<>();
for (String orderId : orderIds) {
CoingiGetOrderRequest request = new CoingiGetOrderRequest().setOrderId(orderId);
CoingiOrder coingiOrder;
coingiOrder = getCoingiOrder(request);
CurrencyPair currencyPair = CoingiAdapters.adaptCurrency(coingiOrder.getCurrencyPair());
Date date = new Date(coingiOrder.getTimestamp() * 1000);
Order order = new LimitOrder(coingiOrder.getType() == 0 ? Order.OrderType.BID : Order.OrderType.ASK, coingiOrder.getOriginalBaseAmount(), currencyPair, coingiOrder.getId(), date, coingiOrder.getPrice());
order.setOrderStatus(CoingiAdapters.adaptOrderStatus(coingiOrder.getStatus()));
orders.add(order);
}
return orders;
} catch (CoingiException e) {
throw CoingiErrorAdapter.adapt(e);
}
}
use of org.knowm.xchange.dto.trade.LimitOrder in project XChange by knowm.
the class MercadoBitcoinTradeDemo method generic.
private static void generic(TradeService tradeService) throws IOException, InterruptedException {
printOpenOrders(tradeService);
// place a limit buy order
LimitOrder limitOrder = new LimitOrder((Order.OrderType.ASK), new BigDecimal("0.01"), CurrencyPair.BTC_BRL, "", null, new BigDecimal("9000.00"));
String limitOrderReturnValue = tradeService.placeLimitOrder(limitOrder);
System.out.println("Limit Order return value: " + limitOrderReturnValue);
printOpenOrders(tradeService);
// Cancel the added order
boolean cancelResult = tradeService.cancelOrder(limitOrderReturnValue);
System.out.println("Canceling returned " + cancelResult);
printOpenOrders(tradeService);
}
use of org.knowm.xchange.dto.trade.LimitOrder in project XChange by knowm.
the class KrakenCancelOrderDemo method raw.
private static void raw(Exchange krakenExchange) throws IOException {
KrakenTradeServiceRaw tradeService = (KrakenTradeServiceRaw) krakenExchange.getTradeService();
System.out.println("Open Orders: " + tradeService.getKrakenOpenOrders());
// place a limit buy order
LimitOrder limitOrder = new LimitOrder((OrderType.ASK), new BigDecimal(".01"), CurrencyPair.BTC_LTC, "", null, new BigDecimal("51.25"));
KrakenOrderResponse limitOrderReturnValue = tradeService.placeKrakenLimitOrder(limitOrder);
System.out.println("Limit Order return value: " + limitOrderReturnValue);
Map<String, KrakenOrder> openOrders = tradeService.getKrakenOpenOrders();
System.out.println("Open Orders: " + openOrders);
// Cancel the added order
List<String> transactionIds = limitOrderReturnValue.getTransactionIds();
if (transactionIds != null && !transactionIds.isEmpty()) {
KrakenCancelOrderResponse cancelResult = tradeService.cancelKrakenOrder(transactionIds.get(0));
System.out.println("Canceling returned " + cancelResult);
System.out.println("Open Orders: " + tradeService.getKrakenOpenOrders());
}
}
use of org.knowm.xchange.dto.trade.LimitOrder in project XChange by knowm.
the class KrakenLimitOrderDemo method raw.
private static void raw(Exchange krakenExchange) throws IOException {
KrakenTradeServiceRaw tradeService = (KrakenTradeServiceRaw) krakenExchange.getTradeService();
OrderType orderType = (OrderType.ASK);
BigDecimal tradeableAmount = new BigDecimal("0.01");
BigDecimal price = new BigDecimal("65.25");
LimitOrder limitOrder = new LimitOrder(orderType, tradeableAmount, CurrencyPair.BTC_LTC, "", null, price);
KrakenOrderResponse orderResponse = tradeService.placeKrakenLimitOrder(limitOrder);
System.out.println("Limit Order response: " + orderResponse);
}
Aggregations