use of org.knowm.xchange.coingi.dto.CoingiException in project XChange by knowm.
the class CoingiAccountService method withdrawFunds.
@Override
public String withdrawFunds(WithdrawFundsParams p) throws IOException, NotAvailableFromExchangeException, NotYetImplementedForExchangeException {
try {
if (p instanceof DefaultWithdrawFundsParams) {
DefaultWithdrawFundsParams params = (DefaultWithdrawFundsParams) p;
CoingiWithdrawalRequest request = new CoingiWithdrawalRequest().setAddress(params.address).setAmount(params.amount).setCurrency(params.currency.getCurrencyCode().toUpperCase());
return withdraw(request).toString();
}
throw new NotYetImplementedForExchangeException();
} catch (CoingiException e) {
throw CoingiErrorAdapter.adapt(e);
}
}
use of org.knowm.xchange.coingi.dto.CoingiException in project XChange by knowm.
the class CoingiMarketDataService method getOrderBook.
@Override
public OrderBook getOrderBook(CurrencyPair currencyPair, Object... args) throws IOException {
try {
int maxAskCount = 100;
int maxBidCount = 100;
int maxDepthRangeCount = 32;
if (args.length > 0) {
maxAskCount = (int) args[0];
if (args.length > 1)
maxBidCount = (int) args[1];
if (args.length > 2)
maxDepthRangeCount = (int) args[2];
if (args.length > 3)
throw new IllegalArgumentException("getOrderBook() accepts up to 3 optional arguments, but " + args.length + " were passed!");
}
CoingiOrderBook orderBook = getCoingiOrderBook(currencyPair, maxAskCount, maxBidCount, maxDepthRangeCount);
return CoingiAdapters.adaptOrderBook(orderBook);
} catch (CoingiException e) {
throw CoingiErrorAdapter.adapt(e);
}
}
use of org.knowm.xchange.coingi.dto.CoingiException in project XChange by knowm.
the class CoingiTradeService method cancelOrder.
@Override
public boolean cancelOrder(String orderId) throws IOException {
try {
// if it doesn't return an error and CoingiOrder is returned, then the cancellation is
// successful
CoingiCancelOrderRequest request = new CoingiCancelOrderRequest();
request.setOrderId(orderId);
return cancelCoingiOrder(request) != null;
} catch (CoingiException e) {
throw CoingiErrorAdapter.adapt(e);
}
}
use of org.knowm.xchange.coingi.dto.CoingiException 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.coingi.dto.CoingiException in project XChange by knowm.
the class CoingiTradeService method getOpenOrders.
@Override
public OpenOrders getOpenOrders(OpenOrdersParams params) throws IOException {
try {
CoingiGetOrderHistoryRequest orderHistoryRequest = new CoingiGetOrderHistoryRequest();
orderHistoryRequest.setStatus(0);
orderHistoryRequest.setPageNumber(1);
orderHistoryRequest.setPageSize(50);
CoingiOrdersList list = getCoingiOrderHistory(orderHistoryRequest);
return CoingiAdapters.adaptOpenOrders(list);
} catch (CoingiException e) {
throw CoingiErrorAdapter.adapt(e);
}
}
Aggregations