Search in sources :

Example 1 with CoingiException

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);
    }
}
Also used : DefaultWithdrawFundsParams(org.knowm.xchange.service.trade.params.DefaultWithdrawFundsParams) CoingiException(org.knowm.xchange.coingi.dto.CoingiException) CoingiWithdrawalRequest(org.knowm.xchange.coingi.dto.account.CoingiWithdrawalRequest) NotYetImplementedForExchangeException(org.knowm.xchange.exceptions.NotYetImplementedForExchangeException)

Example 2 with CoingiException

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);
    }
}
Also used : CoingiException(org.knowm.xchange.coingi.dto.CoingiException) CoingiOrderBook(org.knowm.xchange.coingi.dto.marketdata.CoingiOrderBook)

Example 3 with CoingiException

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);
    }
}
Also used : CoingiCancelOrderRequest(org.knowm.xchange.coingi.dto.trade.CoingiCancelOrderRequest) CoingiException(org.knowm.xchange.coingi.dto.CoingiException)

Example 4 with CoingiException

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);
    }
}
Also used : CoingiOrder(org.knowm.xchange.coingi.dto.trade.CoingiOrder) Order(org.knowm.xchange.dto.Order) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) MarketOrder(org.knowm.xchange.dto.trade.MarketOrder) CoingiException(org.knowm.xchange.coingi.dto.CoingiException) CoingiGetOrderRequest(org.knowm.xchange.coingi.dto.trade.CoingiGetOrderRequest) ArrayList(java.util.ArrayList) CoingiOrder(org.knowm.xchange.coingi.dto.trade.CoingiOrder) LimitOrder(org.knowm.xchange.dto.trade.LimitOrder) Date(java.util.Date) DefaultOpenOrdersParamCurrencyPair(org.knowm.xchange.service.trade.params.orders.DefaultOpenOrdersParamCurrencyPair) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Example 5 with CoingiException

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);
    }
}
Also used : CoingiGetOrderHistoryRequest(org.knowm.xchange.coingi.dto.trade.CoingiGetOrderHistoryRequest) CoingiException(org.knowm.xchange.coingi.dto.CoingiException) CoingiOrdersList(org.knowm.xchange.coingi.dto.trade.CoingiOrdersList)

Aggregations

CoingiException (org.knowm.xchange.coingi.dto.CoingiException)7 CoingiGetOrderHistoryRequest (org.knowm.xchange.coingi.dto.trade.CoingiGetOrderHistoryRequest)2 CoingiOrdersList (org.knowm.xchange.coingi.dto.trade.CoingiOrdersList)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 CoingiWithdrawalRequest (org.knowm.xchange.coingi.dto.account.CoingiWithdrawalRequest)1 CoingiOrderBook (org.knowm.xchange.coingi.dto.marketdata.CoingiOrderBook)1 CoingiCancelOrderRequest (org.knowm.xchange.coingi.dto.trade.CoingiCancelOrderRequest)1 CoingiGetOrderRequest (org.knowm.xchange.coingi.dto.trade.CoingiGetOrderRequest)1 CoingiOrder (org.knowm.xchange.coingi.dto.trade.CoingiOrder)1 CoingiTransactionHistoryRequest (org.knowm.xchange.coingi.dto.trade.CoingiTransactionHistoryRequest)1 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)1 Order (org.knowm.xchange.dto.Order)1 LimitOrder (org.knowm.xchange.dto.trade.LimitOrder)1 MarketOrder (org.knowm.xchange.dto.trade.MarketOrder)1 NotYetImplementedForExchangeException (org.knowm.xchange.exceptions.NotYetImplementedForExchangeException)1 DefaultWithdrawFundsParams (org.knowm.xchange.service.trade.params.DefaultWithdrawFundsParams)1 DefaultOpenOrdersParamCurrencyPair (org.knowm.xchange.service.trade.params.orders.DefaultOpenOrdersParamCurrencyPair)1