Search in sources :

Example 16 with ExchangeException

use of org.knowm.xchange.exceptions.ExchangeException in project XChange by knowm.

the class BiboxAccountServiceRaw method getBiboxAccountInfo.

public List<BiboxAsset> getBiboxAccountInfo() {
    try {
        BiboxSingleResponse<BiboxAssetsResult> response = bibox.assets(ASSETS_CMD.json(), apiKey, signatureCreator);
        throwErrors(response);
        return response.get().getResult().getAssets_list();
    } catch (BiboxException e) {
        throw new ExchangeException(e.getMessage());
    }
}
Also used : ExchangeException(org.knowm.xchange.exceptions.ExchangeException) BiboxAssetsResult(org.knowm.xchange.bibox.dto.account.BiboxAssetsResult) BiboxException(org.knowm.xchange.bibox.BiboxException)

Example 17 with ExchangeException

use of org.knowm.xchange.exceptions.ExchangeException in project XChange by knowm.

the class BiboxMarketDataServiceRaw method getBiboxOrderBook.

public BiboxOrderBook getBiboxOrderBook(CurrencyPair currencyPair, Integer depth) throws IOException {
    try {
        BiboxResponse<BiboxOrderBook> response = bibox.orderBook(DEPTH_CMD, BiboxAdapters.toBiboxPair(currencyPair), depth);
        throwErrors(response);
        return response.getResult();
    } catch (BiboxException e) {
        throw new ExchangeException(e.getMessage());
    }
}
Also used : BiboxOrderBook(org.knowm.xchange.bibox.dto.trade.BiboxOrderBook) ExchangeException(org.knowm.xchange.exceptions.ExchangeException) BiboxException(org.knowm.xchange.bibox.BiboxException)

Example 18 with ExchangeException

use of org.knowm.xchange.exceptions.ExchangeException in project XChange by knowm.

the class BiboxMarketDataServiceRaw method getBiboxTicker.

public BiboxTicker getBiboxTicker(CurrencyPair currencyPair) throws IOException {
    try {
        BiboxResponse<BiboxTicker> response = bibox.mdata(TICKER_CMD, toBiboxPair(currencyPair));
        throwErrors(response);
        return response.getResult();
    } catch (BiboxException e) {
        throw new ExchangeException(e.getMessage());
    }
}
Also used : ExchangeException(org.knowm.xchange.exceptions.ExchangeException) BiboxTicker(org.knowm.xchange.bibox.dto.marketdata.BiboxTicker) BiboxException(org.knowm.xchange.bibox.BiboxException)

Example 19 with ExchangeException

use of org.knowm.xchange.exceptions.ExchangeException in project XChange by knowm.

the class BiboxMarketDataServiceRaw method getBiboxOrderBooks.

public List<BiboxOrderBook> getBiboxOrderBooks(Integer depth, Collection<CurrencyPair> currencyPairs) {
    try {
        List<BiboxCommand<?>> allCommands = currencyPairs.stream().distinct().filter(Objects::nonNull).map(BiboxAdapters::toBiboxPair).map(pair -> new BiboxOrderBookCommand(pair, depth)).collect(Collectors.toList());
        BiboxMultipleResponses<BiboxOrderBook> response = bibox.orderBooks(BiboxCommands.of(allCommands).json());
        throwErrors(response);
        return response.getResult().stream().map(BiboxResponse::getResult).collect(Collectors.toList());
    } catch (BiboxException e) {
        throw new ExchangeException(e.getMessage());
    }
}
Also used : BiboxOrderBookCommand(org.knowm.xchange.bibox.dto.marketdata.BiboxOrderBookCommand) BiboxOrderBook(org.knowm.xchange.bibox.dto.trade.BiboxOrderBook) BiboxAdapters(org.knowm.xchange.bibox.dto.BiboxAdapters) Collection(java.util.Collection) IOException(java.io.IOException) BiboxMarket(org.knowm.xchange.bibox.dto.marketdata.BiboxMarket) Exchange(org.knowm.xchange.Exchange) BiboxCommand(org.knowm.xchange.bibox.dto.BiboxCommand) Collectors(java.util.stream.Collectors) ExchangeException(org.knowm.xchange.exceptions.ExchangeException) BiboxException(org.knowm.xchange.bibox.BiboxException) BiboxDeals(org.knowm.xchange.bibox.dto.trade.BiboxDeals) Objects(java.util.Objects) List(java.util.List) BiboxCommands(org.knowm.xchange.bibox.dto.BiboxCommands) BiboxResponse(org.knowm.xchange.bibox.dto.BiboxResponse) BiboxAdapters.toBiboxPair(org.knowm.xchange.bibox.dto.BiboxAdapters.toBiboxPair) BiboxMultipleResponses(org.knowm.xchange.bibox.dto.BiboxMultipleResponses) BiboxTicker(org.knowm.xchange.bibox.dto.marketdata.BiboxTicker) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) BiboxOrderBookCommand(org.knowm.xchange.bibox.dto.marketdata.BiboxOrderBookCommand) BiboxOrderBook(org.knowm.xchange.bibox.dto.trade.BiboxOrderBook) BiboxAdapters(org.knowm.xchange.bibox.dto.BiboxAdapters) BiboxCommand(org.knowm.xchange.bibox.dto.BiboxCommand) ExchangeException(org.knowm.xchange.exceptions.ExchangeException) BiboxException(org.knowm.xchange.bibox.BiboxException)

Example 20 with ExchangeException

use of org.knowm.xchange.exceptions.ExchangeException in project XChange by knowm.

the class BiboxTradeServiceRaw method getBiboxOrderHistory.

public BiboxOrders getBiboxOrderHistory() {
    try {
        BiboxOrderPendingListCommandBody body = new BiboxOrderPendingListCommandBody(1, // wonder if this actually works
        Integer.MAX_VALUE);
        BiboxOrderHistoryCommand cmd = new BiboxOrderHistoryCommand(body);
        BiboxSingleResponse<BiboxOrders> response = bibox.orderPendingList(BiboxCommands.of(cmd).json(), apiKey, signatureCreator);
        throwErrors(response);
        return response.get().getResult();
    } catch (BiboxException e) {
        throw new ExchangeException(e.getMessage());
    }
}
Also used : BiboxOrderHistoryCommand(org.knowm.xchange.bibox.dto.trade.BiboxOrderHistoryCommand) BiboxOrders(org.knowm.xchange.bibox.dto.trade.BiboxOrders) ExchangeException(org.knowm.xchange.exceptions.ExchangeException) BiboxOrderPendingListCommandBody(org.knowm.xchange.bibox.dto.trade.BiboxOrderPendingListCommandBody) BiboxException(org.knowm.xchange.bibox.BiboxException)

Aggregations

ExchangeException (org.knowm.xchange.exceptions.ExchangeException)138 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)30 IOException (java.io.IOException)17 BiboxException (org.knowm.xchange.bibox.BiboxException)16 NotAvailableFromExchangeException (org.knowm.xchange.exceptions.NotAvailableFromExchangeException)16 TradeHistoryParamCurrencyPair (org.knowm.xchange.service.trade.params.TradeHistoryParamCurrencyPair)16 BigDecimal (java.math.BigDecimal)15 Currency (org.knowm.xchange.currency.Currency)15 LimitOrder (org.knowm.xchange.dto.trade.LimitOrder)15 ArrayList (java.util.ArrayList)13 List (java.util.List)13 OpenOrdersParamCurrencyPair (org.knowm.xchange.service.trade.params.orders.OpenOrdersParamCurrencyPair)13 Exchange (org.knowm.xchange.Exchange)11 CancelOrderByCurrencyPair (org.knowm.xchange.service.trade.params.CancelOrderByCurrencyPair)11 CancelOrderByIdParams (org.knowm.xchange.service.trade.params.CancelOrderByIdParams)11 Collectors (java.util.stream.Collectors)10 DefaultOpenOrdersParamCurrencyPair (org.knowm.xchange.service.trade.params.orders.DefaultOpenOrdersParamCurrencyPair)10 Test (org.junit.Test)9 NotYetImplementedForExchangeException (org.knowm.xchange.exceptions.NotYetImplementedForExchangeException)9 Date (java.util.Date)8