Search in sources :

Example 1 with BiboxOrderBook

use of org.knowm.xchange.bibox.dto.trade.BiboxOrderBook in project XChange by knowm.

the class BiboxMarketDataService method getOrderBook.

@Override
public OrderBook getOrderBook(CurrencyPair currencyPair, Object... args) throws IOException {
    // default on website
    Integer depth = 16;
    if (args != null && args.length > 0) {
        if (args[0] instanceof Integer && (Integer) args[0] > 0) {
            depth = (Integer) args[0];
        }
    }
    BiboxOrderBook biboxOrderBook = getBiboxOrderBook(currencyPair, depth);
    return BiboxAdapters.adaptOrderBook(biboxOrderBook, currencyPair);
}
Also used : BiboxOrderBook(org.knowm.xchange.bibox.dto.trade.BiboxOrderBook)

Example 2 with BiboxOrderBook

use of org.knowm.xchange.bibox.dto.trade.BiboxOrderBook 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 3 with BiboxOrderBook

use of org.knowm.xchange.bibox.dto.trade.BiboxOrderBook 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 4 with BiboxOrderBook

use of org.knowm.xchange.bibox.dto.trade.BiboxOrderBook in project XChange by knowm.

the class BiboxMarketdataUnmarshalTest method testOrderBookUnmarshal.

@Test
public void testOrderBookUnmarshal() throws IOException {
    BiboxResponse<BiboxOrderBook> response = BiboxTestUtils.getResponse(new TypeReference<BiboxResponse<BiboxOrderBook>>() {
    }, "/org/knowm/xchange/bibox/dto/marketdata/example-order-book.json");
    assertThat(response.getCmd()).isEqualTo("depth");
    BiboxOrderBook orderBook = response.getResult();
    assertThat(orderBook.getPair()).isEqualTo("BIX_BTC");
    assertThat(orderBook.getUpdateTime()).isEqualTo(1518133407425L);
    assertThat(orderBook.getAsks()).hasSize(2);
    assertThat(orderBook.getBids()).hasSize(2);
    assertThat(orderBook.getAsks().get(0).getPrice()).isEqualTo(BigDecimal.valueOf(0.00010202));
    assertThat(orderBook.getAsks().get(0).getVolume()).isEqualTo(BigDecimal.valueOf(100));
    assertThat(orderBook.getBids().get(0).getPrice()).isEqualTo(BigDecimal.valueOf(0.00010179));
    assertThat(orderBook.getBids().get(0).getVolume()).isEqualTo(BigDecimal.valueOf(127.7667));
}
Also used : BiboxOrderBook(org.knowm.xchange.bibox.dto.trade.BiboxOrderBook) BiboxResponse(org.knowm.xchange.bibox.dto.BiboxResponse) Test(org.junit.Test)

Example 5 with BiboxOrderBook

use of org.knowm.xchange.bibox.dto.trade.BiboxOrderBook in project XChange by knowm.

the class BiboxMarketDataDemo method raw.

private static void raw(BiboxMarketDataServiceRaw marketDataService) throws IOException {
    System.out.println("------------RAW-----------");
    BiboxTicker tickerResponse = marketDataService.getBiboxTicker(PAIR);
    System.out.println(tickerResponse);
    List<BiboxMarket> tickersResponse = marketDataService.getAllBiboxMarkets();
    System.out.println(tickersResponse);
    BiboxOrderBook orderBookResponse = marketDataService.getBiboxOrderBook(PAIR, 10);
    System.out.println(orderBookResponse);
}
Also used : BiboxOrderBook(org.knowm.xchange.bibox.dto.trade.BiboxOrderBook) BiboxMarket(org.knowm.xchange.bibox.dto.marketdata.BiboxMarket) BiboxTicker(org.knowm.xchange.bibox.dto.marketdata.BiboxTicker)

Aggregations

BiboxOrderBook (org.knowm.xchange.bibox.dto.trade.BiboxOrderBook)5 BiboxException (org.knowm.xchange.bibox.BiboxException)2 BiboxResponse (org.knowm.xchange.bibox.dto.BiboxResponse)2 BiboxMarket (org.knowm.xchange.bibox.dto.marketdata.BiboxMarket)2 BiboxTicker (org.knowm.xchange.bibox.dto.marketdata.BiboxTicker)2 ExchangeException (org.knowm.xchange.exceptions.ExchangeException)2 IOException (java.io.IOException)1 Collection (java.util.Collection)1 List (java.util.List)1 Objects (java.util.Objects)1 Collectors (java.util.stream.Collectors)1 Test (org.junit.Test)1 Exchange (org.knowm.xchange.Exchange)1 BiboxAdapters (org.knowm.xchange.bibox.dto.BiboxAdapters)1 BiboxAdapters.toBiboxPair (org.knowm.xchange.bibox.dto.BiboxAdapters.toBiboxPair)1 BiboxCommand (org.knowm.xchange.bibox.dto.BiboxCommand)1 BiboxCommands (org.knowm.xchange.bibox.dto.BiboxCommands)1 BiboxMultipleResponses (org.knowm.xchange.bibox.dto.BiboxMultipleResponses)1 BiboxOrderBookCommand (org.knowm.xchange.bibox.dto.marketdata.BiboxOrderBookCommand)1 BiboxDeals (org.knowm.xchange.bibox.dto.trade.BiboxDeals)1