Search in sources :

Example 1 with HitbtcMarketDataService

use of org.knowm.xchange.hitbtc.v2.service.HitbtcMarketDataService in project XChange by knowm.

the class HitbtcCandlesDemo method getCandles.

private static void getCandles(HitbtcMarketDataServiceRaw hitbtcMarketDataService) throws IOException, ParseException {
    CurrencyPair currencyPair = new CurrencyPair("BTC/USD");
    int limit = 10;
    String sort = "ASC";
    String period = "M15";
    int offset = 10;
    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
    LocalDateTime end = LocalDateTime.parse("2019-01-24 00:00", formatter);
    LocalDateTime start = LocalDateTime.parse("2019-01-23 00:00", formatter);
    Date from = Date.from(start.atZone(ZoneId.systemDefault()).toInstant());
    Date till = Date.from(end.atZone(ZoneId.systemDefault()).toInstant());
    // default is latest candles sorted ASC
    System.out.println("Default");
    List<HitbtcCandle> candles = hitbtcMarketDataService.getHitbtcCandles(currencyPair, limit, period);
    printCandles(candles);
    // sorted
    sort = "ASC";
    System.out.println("Sorted " + sort);
    candles = hitbtcMarketDataService.getHitbtcCandles(currencyPair, limit, period, sort);
    printCandles(candles);
    sort = "DESC";
    System.out.println("Sorted " + sort);
    candles = hitbtcMarketDataService.getHitbtcCandles(currencyPair, limit, period, sort);
    printCandles(candles);
    // sorted with date range
    System.out.println("Filtered from " + from + " to " + till + " and sort " + sort);
    candles = hitbtcMarketDataService.getHitbtcCandles(currencyPair, limit, period, from, till, "ASC");
    printCandles(candles);
    // using offset
    System.out.println("Using offset " + offset + " and sort " + sort);
    candles = hitbtcMarketDataService.getHitbtcCandles(currencyPair, limit, period, offset, sort);
    printCandles(candles);
}
Also used : LocalDateTime(java.time.LocalDateTime) HitbtcCandle(org.knowm.xchange.hitbtc.v2.dto.HitbtcCandle) DateTimeFormatter(java.time.format.DateTimeFormatter) Date(java.util.Date) CurrencyPair(org.knowm.xchange.currency.CurrencyPair)

Example 2 with HitbtcMarketDataService

use of org.knowm.xchange.hitbtc.v2.service.HitbtcMarketDataService in project XChange by knowm.

the class HitbtcCandlesDemo method main.

public static void main(String[] args) throws Exception {
    Exchange hitbtcExchange = HitbtcExampleUtils.createExchange();
    hitbtcExchange.remoteInit();
    System.out.println("Market metadata: " + hitbtcExchange.getExchangeMetaData().getCurrencyPairs().toString());
    MarketDataService marketDataService = hitbtcExchange.getMarketDataService();
    HitbtcMarketDataServiceRaw hitbtcMarketDataService = (HitbtcMarketDataServiceRaw) hitbtcExchange.getMarketDataService();
    getCandles(hitbtcMarketDataService);
}
Also used : Exchange(org.knowm.xchange.Exchange) HitbtcMarketDataServiceRaw(org.knowm.xchange.hitbtc.v2.service.HitbtcMarketDataServiceRaw) MarketDataService(org.knowm.xchange.service.marketdata.MarketDataService)

Example 3 with HitbtcMarketDataService

use of org.knowm.xchange.hitbtc.v2.service.HitbtcMarketDataService in project XChange by knowm.

the class HitbtcExchange method initServices.

@Override
protected void initServices() {
    marketDataService = new HitbtcMarketDataService(this);
    tradeService = new HitbtcTradeService(this);
    accountService = new HitbtcAccountService(this);
}
Also used : HitbtcTradeService(org.knowm.xchange.hitbtc.v2.service.HitbtcTradeService) HitbtcMarketDataService(org.knowm.xchange.hitbtc.v2.service.HitbtcMarketDataService) HitbtcAccountService(org.knowm.xchange.hitbtc.v2.service.HitbtcAccountService)

Aggregations

LocalDateTime (java.time.LocalDateTime)1 DateTimeFormatter (java.time.format.DateTimeFormatter)1 Date (java.util.Date)1 Exchange (org.knowm.xchange.Exchange)1 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)1 HitbtcCandle (org.knowm.xchange.hitbtc.v2.dto.HitbtcCandle)1 HitbtcAccountService (org.knowm.xchange.hitbtc.v2.service.HitbtcAccountService)1 HitbtcMarketDataService (org.knowm.xchange.hitbtc.v2.service.HitbtcMarketDataService)1 HitbtcMarketDataServiceRaw (org.knowm.xchange.hitbtc.v2.service.HitbtcMarketDataServiceRaw)1 HitbtcTradeService (org.knowm.xchange.hitbtc.v2.service.HitbtcTradeService)1 MarketDataService (org.knowm.xchange.service.marketdata.MarketDataService)1