Search in sources :

Example 1 with BinanceMarketDataService

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);
}
Also used : BinanceExchange(org.knowm.xchange.binance.BinanceExchange) Exchange(org.knowm.xchange.Exchange) BinanceMarketDataService(org.knowm.xchange.binance.service.BinanceMarketDataService) MarketDataService(org.knowm.xchange.service.marketdata.MarketDataService)

Example 2 with BinanceMarketDataService

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();
    }
}
Also used : BinanceTradeHistory(com.jessethouin.quant.binance.beans.BinanceTradeHistory) BinanceMarketDataService(org.knowm.xchange.binance.service.BinanceMarketDataService) IOException(java.io.IOException) Date(java.util.Date) CurrencyPair(org.knowm.xchange.currency.CurrencyPair) Session(org.hibernate.Session)

Example 3 with BinanceMarketDataService

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);
    }
}
Also used : AssetDetail(org.knowm.xchange.binance.dto.account.AssetDetail) BinanceMarketDataService(org.knowm.xchange.binance.service.BinanceMarketDataService) BinanceAccountService(org.knowm.xchange.binance.service.BinanceAccountService) ExchangeException(org.knowm.xchange.exceptions.ExchangeException) ExchangeException(org.knowm.xchange.exceptions.ExchangeException)

Example 4 with BinanceMarketDataService

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());
}
Also used : BinanceTradeService(org.knowm.xchange.binance.service.BinanceTradeService) BinanceMarketDataService(org.knowm.xchange.binance.service.BinanceMarketDataService) BinanceAccountService(org.knowm.xchange.binance.service.BinanceAccountService)

Example 5 with BinanceMarketDataService

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());
}
Also used : BinanceTradeService(org.knowm.xchange.binance.service.BinanceTradeService) BinanceUsAccountService(org.knowm.xchange.binance.service.BinanceUsAccountService) BinanceMarketDataService(org.knowm.xchange.binance.service.BinanceMarketDataService)

Aggregations

BinanceMarketDataService (org.knowm.xchange.binance.service.BinanceMarketDataService)7 IOException (java.io.IOException)2 AssetDetail (org.knowm.xchange.binance.dto.account.AssetDetail)2 BinanceAccountService (org.knowm.xchange.binance.service.BinanceAccountService)2 BinanceTradeService (org.knowm.xchange.binance.service.BinanceTradeService)2 BinanceTradeHistory (com.jessethouin.quant.binance.beans.BinanceTradeHistory)1 NoActiveChannelException (info.bitrich.xchangestream.binance.BinanceUserDataChannel.NoActiveChannelException)1 ProductSubscription (info.bitrich.xchangestream.core.ProductSubscription)1 Completable (io.reactivex.Completable)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Session (org.hibernate.Session)1 Exchange (org.knowm.xchange.Exchange)1 BinanceAuthenticated (org.knowm.xchange.binance.BinanceAuthenticated)1 BinanceExchange (org.knowm.xchange.binance.BinanceExchange)1 BinanceUsAccountService (org.knowm.xchange.binance.service.BinanceUsAccountService)1 CurrencyPair (org.knowm.xchange.currency.CurrencyPair)1 ExchangeException (org.knowm.xchange.exceptions.ExchangeException)1 MarketDataService (org.knowm.xchange.service.marketdata.MarketDataService)1