use of org.knowm.xchange.currency.Currency in project XChange by knowm.
the class OkExManualExample method main.
public static void main(String[] args) {
StreamingExchange exchange = StreamingExchangeFactory.INSTANCE.createExchange(OkExStreamingExchange.class);
exchange.connect().blockingAwait();
CurrencyPair btcUsdt = new CurrencyPair(new Currency("BTC"), new Currency("USDT"));
exchange.getStreamingMarketDataService().getOrderBook(btcUsdt).subscribe(orderBook -> {
LOG.info("First ask: {}", orderBook.getAsks().get(0));
LOG.info("First bid: {}", orderBook.getBids().get(0));
}, throwable -> LOG.error("ERROR in getting order book: ", throwable));
exchange.getStreamingMarketDataService().getTicker(btcUsdt).subscribe(ticker -> {
LOG.info("TICKER: {}", ticker);
}, throwable -> LOG.error("ERROR in getting ticker: ", throwable));
exchange.getStreamingMarketDataService().getTrades(btcUsdt).subscribe(trade -> {
LOG.info("TRADE: {}", trade);
}, throwable -> LOG.error("ERROR in getting trades: ", throwable));
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
use of org.knowm.xchange.currency.Currency in project XChange by knowm.
the class TheRockAccountService method getFundingHistory.
@Override
public List<FundingRecord> getFundingHistory(TradeHistoryParams params) throws IOException {
Currency currency = null;
Date after = null;
Date before = null;
FundingRecord.Type type = null;
if (params instanceof TradeHistoryParamCurrency) {
TradeHistoryParamCurrency tradeHistoryParamCurrency = (TradeHistoryParamCurrency) params;
currency = tradeHistoryParamCurrency.getCurrency();
}
if (params instanceof TradeHistoryParamsTimeSpan) {
TradeHistoryParamsTimeSpan tradeHistoryParamsTimeSpan = (TradeHistoryParamsTimeSpan) params;
after = tradeHistoryParamsTimeSpan.getStartTime();
before = tradeHistoryParamsTimeSpan.getEndTime();
}
if (params instanceof HistoryParamsFundingType) {
HistoryParamsFundingType historyParamsFundingType = (HistoryParamsFundingType) params;
type = historyParamsFundingType.getType();
}
List<FundingRecord> all = new ArrayList<>();
if (type == null || type == FundingRecord.Type.DEPOSIT) {
int page = 1;
while (true) {
TheRockTransactions txns = deposits(currency, after, before, page++);
if (txns.getTransactions().length == 0)
break;
for (TheRockTransaction txn : txns.getTransactions()) {
all.add(adapt(txn, FundingRecord.Type.DEPOSIT));
}
}
}
if (type == null || type == FundingRecord.Type.WITHDRAWAL) {
int page = 1;
while (true) {
TheRockTransactions txns = withdrawls(currency, after, before, page++);
if (txns.getTransactions().length == 0)
break;
for (TheRockTransaction txn : txns.getTransactions()) {
all.add(adapt(txn, FundingRecord.Type.WITHDRAWAL));
}
}
}
return all;
}
use of org.knowm.xchange.currency.Currency in project XChange by knowm.
the class AscendexAdapters method adaptAccountInfo.
public static AccountInfo adaptAccountInfo(List<AscendexCashAccountBalanceDto> ascendexCashAccountBalanceDtoList) {
List<Balance> balances = new ArrayList<>(ascendexCashAccountBalanceDtoList.size());
ascendexCashAccountBalanceDtoList.forEach(ascendexCashAccountBalanceDto -> balances.add(new Balance.Builder().currency(new Currency(ascendexCashAccountBalanceDto.getAsset())).available(ascendexCashAccountBalanceDto.getAvailableBalance()).total(ascendexCashAccountBalanceDto.getTotalBalance()).frozen(ascendexCashAccountBalanceDto.getTotalBalance().subtract(ascendexCashAccountBalanceDto.getAvailableBalance())).build()));
return new AccountInfo(Wallet.Builder.from(balances).id("spot").features(new HashSet<>(Collections.singletonList(Wallet.WalletFeature.TRADING))).build());
}
use of org.knowm.xchange.currency.Currency in project XChange by knowm.
the class BleutradeAccountServiceIntegration method shouldGetAccountInfo.
@Test
public void shouldGetAccountInfo() throws IOException {
// given
BleutradeBalancesReturn balancesReturn = new BleutradeBalancesReturn();
balancesReturn.setSuccess(true);
balancesReturn.setMessage("test message");
balancesReturn.setResult(expectedBleutradeAccountInfo());
when(bleutrade.getBalances(eq(SPECIFICATION_API_KEY), any(ParamsDigest.class), any(SynchronizedValueFactory.class))).thenReturn(balancesReturn);
final Balance[] expectedAccountBalances = expectedAccountBalances();
// when
AccountInfo accountInfo = accountService.getAccountInfo();
// then
assertThat(accountInfo.getWallets()).hasSize(1);
Map<Currency, Balance> balances = accountInfo.getWallet().getBalances();
assertThat(balances).hasSize(3);
BleutradeAssert.assertEquals(balances.get(Currency.AUD), expectedAccountBalances[0]);
BleutradeAssert.assertEquals(balances.get(Currency.BTC), expectedAccountBalances[1]);
BleutradeAssert.assertEquals(balances.get(Currency.getInstance("BLEU")), expectedAccountBalances[2]);
}
use of org.knowm.xchange.currency.Currency in project XChange by knowm.
the class BleutradeAdapters method adaptToExchangeMetaData.
public static ExchangeMetaData adaptToExchangeMetaData(List<BleutradeCurrency> bleutradeCurrencies, List<BleutradeMarket> bleutradeMarkets) {
Map<CurrencyPair, CurrencyPairMetaData> marketMetaDataMap = new HashMap<>();
Map<Currency, CurrencyMetaData> currencyMetaDataMap = new HashMap<>();
for (BleutradeCurrency bleutradeCurrency : bleutradeCurrencies) {
// the getTxFee parameter is the withdrawal charge in the currency in question
currencyMetaDataMap.put(Currency.getInstance(bleutradeCurrency.getCurrency()), new CurrencyMetaData(8, null));
}
// https://bleutrade.com/help/fees_and_deadlines 11/25/2015 all == 0.25%
BigDecimal txFee = new BigDecimal("0.0025");
for (BleutradeMarket bleutradeMarket : bleutradeMarkets) {
CurrencyPair currencyPair = CurrencyPairDeserializer.getCurrencyPairFromString(bleutradeMarket.getMarketName());
CurrencyPairMetaData marketMetaData = new CurrencyPairMetaData(txFee, bleutradeMarket.getMinTradeSize(), null, 8, null);
marketMetaDataMap.put(currencyPair, marketMetaData);
}
return new ExchangeMetaData(marketMetaDataMap, currencyMetaDataMap, null, null, null);
}
Aggregations