@Override public List<FundingRecord> getFundingHistory(TradeHistoryParams params) { if (!(params instanceof TradeHistoryParamCurrency)) { throw new RuntimeException("You must provide the currency for funding history @ Bibox."); } Currency c = ((TradeHistoryParamCurrency) params).getCurrency(); if (c == null) { throw new RuntimeException("You must provide the currency for funding history @ Bibox."); } boolean deposits = false; boolean withdrawals = false; if (params instanceof HistoryParamsFundingType) { HistoryParamsFundingType typeParams = (HistoryParamsFundingType) params; Type type = typeParams.getType(); deposits = type == null || type == Type.DEPOSIT; withdrawals = type == null || type == Type.WITHDRAWAL; } BiboxFundsCommandBody body = new BiboxFundsCommandBody(c.getCurrencyCode()); ArrayList<FundingRecord> result = new ArrayList<>(); if (deposits) { requestBiboxDeposits(body).getItems().forEach(d -> result.add(BiboxAdapters.adaptDeposit(d))); } if (withdrawals) { requestBiboxWithdrawals(body) .getItems() .forEach(d -> result.add(BiboxAdapters.adaptDeposit(d))); } return result; }
private static void fundingHistory(AccountService accountService) throws IOException { // Get the funds information TradeHistoryParams params = accountService.createFundingHistoryParams(); if (params instanceof TradeHistoryParamsTimeSpan) { final TradeHistoryParamsTimeSpan timeSpanParam = (TradeHistoryParamsTimeSpan) params; timeSpanParam.setStartTime( new Date(System.currentTimeMillis() - (1 * 12 * 30 * 24 * 60 * 60 * 1000L))); } if (params instanceof HistoryParamsFundingType) { ((HistoryParamsFundingType) params).setType(FundingRecord.Type.DEPOSIT); } if (params instanceof TradeHistoryParamCurrencies) { final TradeHistoryParamCurrencies currenciesParam = (TradeHistoryParamCurrencies) params; currenciesParam.setCurrencies(new Currency[] {Currency.BTC, Currency.USD}); } List<FundingRecord> fundingRecords = accountService.getFundingHistory(params); AccountServiceTestUtil.printFundingHistory(fundingRecords); } }
type = ((HistoryParamsFundingType) params).getType();
@Override public List<FundingRecord> getFundingHistory(TradeHistoryParams params) throws IOException { String currency = null; if (params instanceof TradeHistoryParamCurrency && ((TradeHistoryParamCurrency) params).getCurrency() != null) { currency = ((TradeHistoryParamCurrency) params).getCurrency().getCurrencyCode(); } else { // Currency is a required parameter for Huobi funding history query throw new ExchangeException("Currency must be supplied"); } String from = null; if (params instanceof TradeHistoryParamsIdSpan) { from = ((TradeHistoryParamsIdSpan) params).getStartId(); } FundingRecord.Type type = null; if (params instanceof HistoryParamsFundingType && ((HistoryParamsFundingType) params).getType() != null) { type = ((HistoryParamsFundingType) params).getType(); } else { // Funding history type is a required parameter for Huobi funding history query throw new ExchangeException( "Type 'deposit' or 'withdraw' must be supplied using FundingRecord.Type"); } // Adapt type out (replace withdrawal -> withdraw) String fundingRecordType = type == FundingRecord.Type.WITHDRAWAL ? "withdraw" : "deposit"; return HuobiAdapters.adaptFundingHistory( getDepositWithdrawalHistory(currency, fundingRecordType, from)); }
@Override public List<FundingRecord> getFundingHistory(TradeHistoryParams params) throws IOException { if (!(params instanceof TradeHistoryParamPaging) && !(params instanceof TradeHistoryParamCurrency)) { throw new ExchangeException( "You need to provide paging information and currency to get the trade history."); } TradeHistoryParamPaging pagingParams = (TradeHistoryParamPaging) params; TradeHistoryParamCurrency curParams = (TradeHistoryParamCurrency) params; Type type = null; if (params instanceof HistoryParamsFundingType) { HistoryParamsFundingType fundingType = (HistoryParamsFundingType) params; if (fundingType.getType() != null) { type = fundingType.getType(); } } // Paging params are 0-based, Kucoin account balances pages are 1-based KucoinSimpleResponse<KucoinWalletRecords> response = walletRecords( curParams.getCurrency(), type, pagingParams.getPageLength(), pagingParams.getPageNumber() != null ? pagingParams.getPageNumber() + 1 : null); return KucoinAdapters.adaptFundingHistory(response.getData().getRecords()); } }
@Override public List<FundingRecord> getFundingHistory(TradeHistoryParams params) throws IOException { try { String cryptopiaType = ""; Integer limit = DEFAULT_RESULTS_LIMIT; if (params instanceof HistoryParamsFundingType) { final FundingRecord.Type type = ((HistoryParamsFundingType) params).getType(); cryptopiaType = type == FundingRecord.Type.DEPOSIT ? CryptopiaFundingType.Deposit.name() : type == FundingRecord.Type.WITHDRAWAL ? CryptopiaFundingType.Withdraw.name() : null; } if (params instanceof TradeHistoryParamLimit) { limit = ((TradeHistoryParamLimit) params).getLimit(); } return getTransactions(cryptopiaType, limit); } catch (CryptopiaException e) { throw CryptopiaErrorAdapter.adapt(e); } }
final FundingRecord.Type type = ((HistoryParamsFundingType) params).getType(); ledgerType = type == FundingRecord.Type.DEPOSIT
type = ((HistoryParamsFundingType) params).getType();
final FundingRecord.Type type = ((HistoryParamsFundingType) params).getType(); ledgerType = type == FundingRecord.Type.DEPOSIT