use of org.knowm.xchange.binance.service.BinanceMarketDataService in project XChange by knowm.
the class BinanceMarketDataDemo method main.
public static void main(String[] args) throws IOException {
Exchange exchange = BinanceDemoUtils.createExchange();
/* create a data service from the exchange */
MarketDataService marketDataService = exchange.getMarketDataService();
generic(exchange, marketDataService);
raw((BinanceExchange) exchange, (BinanceMarketDataService) marketDataService);
// rawAll((BinanceExchange) exchange, (BinanceMarketDataService) marketDataService);
}
use of org.knowm.xchange.binance.service.BinanceMarketDataService in project quant by jessethouin.
the class BinanceCaptureHistory method doCapture.
public static void doCapture(long now) {
CurrencyPair currencyPair = CurrencyPair.BTC_USDT;
try {
BinanceMarketDataService marketDataService = (BinanceMarketDataService) BinanceLive.INSTANCE.getBinanceExchange().getMarketDataService();
Session session = Database.getSession();
session.beginTransaction();
for (int i = CONFIG.getBacktestQty(); i > -1; i -= 500) {
marketDataService.klines(currencyPair, KlineInterval.m1, 500, now - MINUTES.toMillis(i), now - MINUTES.toMillis(Math.max(i - 500, 0))).forEach(binanceKline -> {
BinanceTradeHistory binanceTradeHistory = BinanceTradeHistory.builder().timestamp(new Date(binanceKline.getCloseTime())).ma1(BigDecimal.ZERO).ma2(BigDecimal.ZERO).l(BigDecimal.ZERO).h(BigDecimal.ZERO).p(binanceKline.getClosePrice()).build();
session.persist(binanceTradeHistory);
});
LOG.info(i);
}
session.getTransaction().commit();
} catch (IOException e) {
e.printStackTrace();
}
}
use of org.knowm.xchange.binance.service.BinanceMarketDataService in project XChange by knowm.
the class BinanceExchange method remoteInit.
@Override
public void remoteInit() {
try {
BinanceMarketDataService marketDataService = (BinanceMarketDataService) this.marketDataService;
exchangeInfo = marketDataService.getExchangeInfo();
BinanceAccountService accountService = (BinanceAccountService) getAccountService();
Map<String, AssetDetail> assetDetailMap = null;
if (!usingSandbox() && isAuthenticated()) {
// not available in sndbox
assetDetailMap = accountService.getAssetDetails();
}
postInit(assetDetailMap);
} catch (Exception e) {
throw new ExchangeException("Failed to initialize: " + e.getMessage(), e);
}
}
use of org.knowm.xchange.binance.service.BinanceMarketDataService in project XChange by knowm.
the class BinanceExchange method initServices.
@Override
protected void initServices() {
this.binance = ExchangeRestProxyBuilder.forInterface(BinanceAuthenticated.class, getExchangeSpecification()).build();
this.timestampFactory = new BinanceTimestampFactory(binance, getExchangeSpecification().getResilience(), getResilienceRegistries());
this.marketDataService = new BinanceMarketDataService(this, binance, getResilienceRegistries());
this.tradeService = new BinanceTradeService(this, binance, getResilienceRegistries());
this.accountService = new BinanceAccountService(this, binance, getResilienceRegistries());
}
use of org.knowm.xchange.binance.service.BinanceMarketDataService in project XChange by knowm.
the class BinanceUsExchange method initServices.
@Override
protected void initServices() {
this.binance = ExchangeRestProxyBuilder.forInterface(BinanceAuthenticated.class, getExchangeSpecification()).build();
this.timestampFactory = new BinanceTimestampFactory(binance, getExchangeSpecification().getResilience(), getResilienceRegistries());
this.marketDataService = new BinanceMarketDataService(this, binance, getResilienceRegistries());
this.tradeService = new BinanceTradeService(this, binance, getResilienceRegistries());
this.accountService = new BinanceUsAccountService(this, binance, getResilienceRegistries());
}
Aggregations