bitfinex.applySpecification(defaultExchangeSpecification);
// get all services
PollingMarketDataService marketDataService = bitfinex.getPollingMarketDataService();
PollingAccountService accout = bitfinex.getPollingAccountService();
PollingTradeService trades = bitfinex.getPollingTradeService();
OrderBook orderBook = marketDataService.getOrderBook(new CurrencyPair("XBT", "USD"));
System.out.println("BIDS: " + orderBook.getBids());
System.out.println("ASKS: " + orderBook.getAsks());
Trades trades2 = marketDataService.getTrades(new CurrencyPair("XBT", "USD"), 22233);
System.out.println("Current trades:" + trades2);
AccountInfo accountInfo = accout.getAccountInfo();
System.out.println(accountInfo);
OpenOrders openOrders = trades.getOpenOrders();
System.out.println("open orders: " + openOrders);
for (LimitOrder o : openOrders.getOpenOrders()) {
System.out.println("Order " + o.getId() + " .. cancelling!");
System.out.println(trades.cancelOrder(o.getId()));
}
String placeLimitOrder1 = trades.placeLimitOrder(new LimitOrder(OrderType.BID, BigDecimal.valueOf(10), new CurrencyPair("XBT", "USD"), "0", new Date(), BigDecimal.valueOf(300)));
String placeLimitOrder2 = trades.placeLimitOrder(new LimitOrder(OrderType.BID, BigDecimal.valueOf(10), new CurrencyPair("XBT", "USD"), "0", new Date(), BigDecimal.valueOf(350)));
String placeLimitOrder3 = trades.placeLimitOrder(new LimitOrder(OrderType.BID, BigDecimal.valueOf(10), new CurrencyPair("XBT", "USD"), "0", new Date(), BigDecimal.valueOf(360)));
String placeLimitOrder4 = trades.placeLimitOrder(new LimitOrder(OrderType.BID, BigDecimal.valueOf(10), new CurrencyPair("XBT", "USD"), "0", new Date(), BigDecimal.valueOf(370)));
System.out.println("limit order id " + placeLimitOrder1);
System.out.println("limit order id " + placeLimitOrder2);
System.out.println("limit order id " + placeLimitOrder3);
System.out.println("limit order id " + placeLimitOrder4);
trades.placeLimitOrder(new LimitOrder(OrderType.ASK, BigDecimal.valueOf(10), new CurrencyPair("XBT", "USD"), "0", new Date(), BigDecimal.valueOf(770)));
System.out.println("Cancelling " + placeLimitOrder1);
trades.cancelOrder(placeLimitOrder1);
Trades tradeHistory = trades.getTradeHistory();
System.out.println("Trade history: " + tradeHistory);
}