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);
}
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);
}
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);
}
Aggregations