@Override public List<FundingRecord> getFundingHistory(TradeHistoryParams params) throws IOException { Date start = null; Date end = null; if (params instanceof TradeHistoryParamsTimeSpan) { TradeHistoryParamsTimeSpan timeSpan = (TradeHistoryParamsTimeSpan) params; start = timeSpan.getStartTime(); end = timeSpan.getEndTime(); } GateioDepositsWithdrawals depositsWithdrawals = getDepositsWithdrawals(start, end); return GateioAdapters.adaptDepositsWithdrawals(depositsWithdrawals); } }
private static void generic(AccountService accountService) throws IOException { System.out.println("----------GENERIC----------"); System.out.println(accountService.requestDepositAddress(Currency.BTC)); System.out.println(accountService.getAccountInfo()); System.out.println(accountService.withdrawFunds(Currency.BTC, new BigDecimal("0.03"), "XXX")); final TradeHistoryParams params = accountService.createFundingHistoryParams(); ((TradeHistoryParamsTimeSpan) params) .setStartTime(new Date(System.currentTimeMillis() - 7L * 24 * 60 * 60 * 1000)); final List<FundingRecord> fundingHistory = accountService.getFundingHistory(params); for (FundingRecord fundingRecord : fundingHistory) { System.out.println(fundingRecord); } }
@Override public List<FundingRecord> getFundingHistory(TradeHistoryParams params) throws IOException { Date since = null; Integer limit = 50; if (params instanceof TradeHistoryParamLimit) { limit = ((TradeHistoryParamLimit) params).getLimit(); } if (params instanceof TradeHistoryParamsTimeSpan) { since = ((TradeHistoryParamsTimeSpan) params).getStartTime(); } List<FundingRecord> results = new ArrayList<>(); for (GeminiTransfer transfer : transfers(since, limit)) { results.add(GeminiAdapters.adapt(transfer)); } return results; }
since = timeSpanParam.getStartTime().toInstant().getEpochSecond();
/** Supported parameter types: {@link TradeHistoryParamsTimeSpan} */ @Override public UserTrades getTradeHistory(TradeHistoryParams params) throws IOException { Long from = null; Long to = null; if (params instanceof TradeHistoryParamsTimeSpan) { TradeHistoryParamsTimeSpan p = (TradeHistoryParamsTimeSpan) params; from = DateUtils.toMillisNullSafe(p.getStartTime()); to = DateUtils.toMillisNullSafe(p.getEndTime()); } return getTradeHistory(from, to); }
/** * Optional parameters: start time (default 0 = all) of {@link TradeHistoryParamsTimeSpan} * * <p>Required parameters: none * * <p>Note this method makes 1+N remote calls, where N is the number of returned trades */ @Override public UserTrades getTradeHistory(TradeHistoryParams params) throws IOException { long since = DateUtils.toUnixTime(((TradeHistoryParamsTimeSpan) params).getStartTime()); BTCTradeOrder[] orders = getBTCTradeOrders(since, "all"); BTCTradeOrder[] orderDetails = new BTCTradeOrder[orders.length]; for (int i = 0; i < orders.length; i++) { orderDetails[i] = getBTCTradeOrder(orders[i].getId()); } return BTCTradeAdapters.adaptTrades(orders, orderDetails); }
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 TradeHistoryParamCurrency) { ((TradeHistoryParamCurrency) params).setCurrency(Currency.BTC); } List<FundingRecord> fundingRecords = accountService.getFundingHistory(params); AccountServiceTestUtil.printFundingHistory(fundingRecords); } }
@Override public List<FundingRecord> getFundingHistory(TradeHistoryParams params) throws IOException { try { Date start = null; Date end = null; if (params instanceof TradeHistoryParamsTimeSpan) { start = ((TradeHistoryParamsTimeSpan) params).getStartTime(); end = ((TradeHistoryParamsTimeSpan) params).getEndTime(); } final PoloniexDepositsWithdrawalsResponse poloFundings = returnDepositsWithdrawals(start, end); return PoloniexAdapters.adaptFundingRecords(poloFundings); } catch (PoloniexException e) { throw PoloniexErrorAdapter.adapt(e); } } }
Long since = null; if (params instanceof TradeHistoryParamsTimeSpan) { since = ((TradeHistoryParamsTimeSpan) params).getStartTime().getTime();
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); } }
@Override public UserTrades getTradeHistory(final TradeHistoryParams params) throws IOException { CurrencyPair currencyPair = null; Long startTime = null; Long endTime = null; Integer limit = null; if (params instanceof TradeHistoryParamCurrencyPair) { currencyPair = ((TradeHistoryParamCurrencyPair) params).getCurrencyPair(); } if (params instanceof TradeHistoryParamsTimeSpan) { if (((TradeHistoryParamsTimeSpan) params).getStartTime() != null) { startTime = ((TradeHistoryParamsTimeSpan) params).getStartTime().getTime() / 1000; } if (((TradeHistoryParamsTimeSpan) params).getEndTime() != null) { endTime = ((TradeHistoryParamsTimeSpan) params).getEndTime().getTime() / 1000; } } if (params instanceof TradeHistoryParamLimit) { limit = ((TradeHistoryParamLimit) params).getLimit(); } if (params instanceof LiquiTradeHistoryParams) { return LiquiAdapters.adaptTradesHistory( getTradeHistory(currencyPair, null, null, limit, startTime, endTime)); } throw new LiquiException("Unable to get trade history with the provided params: " + params); }
Date startTime = ((TradeHistoryParamsTimeSpan) params).getStartTime(); timestamp = DateUtils.toUnixTime(startTime); } else {
@Override public List<FundingRecord> getFundingHistory(TradeHistoryParams params) throws IOException { try { Date start = new Date(0); Date end = new Date(); if (params instanceof TradeHistoryParamsTimeSpan) { TradeHistoryParamsTimeSpan tradeHistoryParamsTimeSpan = (TradeHistoryParamsTimeSpan) params; start = tradeHistoryParamsTimeSpan.getStartTime(); end = tradeHistoryParamsTimeSpan.getEndTime(); } Long offset = 0L; if (params instanceof TradeHistoryParamOffset) { offset = ((TradeHistoryParamOffset) params).getOffset(); } Integer limit = 100; if (params instanceof TradeHistoryParamLimit) { limit = ((TradeHistoryParamLimit) params).getLimit(); } List<Map> fundingRaw = funding(start, end, limit, offset); return fundingRaw .stream() .map(LivecoinAdapters::adaptFundingRecord) .collect(Collectors.toList()); } catch (LivecoinException e) { throw LivecoinErrorAdapter.adapt(e); } }
@Override public List<FundingRecord> getFundingHistory(TradeHistoryParams params) throws IOException { Date since = null; Integer limit = 50; if (params instanceof TradeHistoryParamLimit) { limit = ((TradeHistoryParamLimit) params).getLimit(); } if (params instanceof TradeHistoryParamsTimeSpan) { since = ((TradeHistoryParamsTimeSpan) params).getStartTime(); } List<FundingRecord> results = new ArrayList<>(); for (GeminiTransfer transfer : transfers(since, limit)) { results.add(GeminiAdapters.adapt(transfer)); } return results; }
@Override public UserTrades getTradeHistory(TradeHistoryParams params) throws IOException { try { Date start = new Date(0); Date end = new Date(); if (params instanceof TradeHistoryParamsTimeSpan) { TradeHistoryParamsTimeSpan tradeHistoryParamsTimeSpan = (TradeHistoryParamsTimeSpan) params; start = tradeHistoryParamsTimeSpan.getStartTime(); end = tradeHistoryParamsTimeSpan.getEndTime(); } Long offset = 0L; if (params instanceof TradeHistoryParamOffset) { offset = ((TradeHistoryParamOffset) params).getOffset(); } Integer limit = 100; if (params instanceof TradeHistoryParamLimit) { limit = ((TradeHistoryParamLimit) params).getLimit(); } return new UserTrades( tradeHistory(start, end, limit, offset), Trades.TradeSortType.SortByTimestamp); } catch (LivecoinException e) { throw LivecoinErrorAdapter.adapt(e); } }
since = timeSpanParam.getStartTime().toInstant().getEpochSecond();
@Override public UserTrades getTradeHistory(TradeHistoryParams params) throws IOException { String symbol = null; if (params instanceof TradeHistoryParamCurrencyPair) { symbol = BitmexAdapters.adaptCurrencyPairToSymbol( ((TradeHistoryParamCurrencyPair) params).getCurrencyPair()); } Long start = null; if (params instanceof TradeHistoryParamOffset) { start = ((TradeHistoryParamOffset) params).getOffset(); } Date startTime = null; Date endTime = null; if (params instanceof TradeHistoryParamsTimeSpan) { TradeHistoryParamsTimeSpan timeSpan = (TradeHistoryParamsTimeSpan) params; startTime = timeSpan.getStartTime(); endTime = timeSpan.getEndTime(); } List<UserTrade> userTrades = getTradeHistory(symbol, null, null, null, start, false, startTime, endTime) .stream() .map(BitmexAdapters::adoptUserTrade) .filter(Objects::nonNull) .collect(Collectors.toList()); return new UserTrades(userTrades, TradeSortType.SortByTimestamp); } }
/** * Optional parameters: start time (default 0 = all) of {@link TradeHistoryParamsTimeSpan} * * <p>Required parameters: none * * <p>Note this method makes 1+N remote calls, where N is the number of returned trades */ @Override public UserTrades getTradeHistory(TradeHistoryParams params) throws IOException { long since = DateUtils.toUnixTime(((TradeHistoryParamsTimeSpan) params).getStartTime()); BTCTradeOrder[] orders = getBTCTradeOrders(since, "all"); BTCTradeOrder[] orderDetails = new BTCTradeOrder[orders.length]; for (int i = 0; i < orders.length; i++) { orderDetails[i] = getBTCTradeOrder(orders[i].getId()); } return BTCTradeAdapters.adaptTrades(orders, orderDetails); }
@Override public UserTrades getTradeHistory(TradeHistoryParams params) throws IOException { Integer page = 0; Integer pageLength = 50; if (params instanceof TradeHistoryParamPaging) { TradeHistoryParamPaging paramPaging = (TradeHistoryParamPaging) params; page = paramPaging.getPageNumber(); pageLength = paramPaging.getPageLength(); } String transactionId = null; if (params instanceof TradeHistoryParamTransactionId) { transactionId = ((TradeHistoryParamTransactionId) params).getTransactionId(); } Date startTime = null; Date endTime = null; if (params instanceof TradeHistoryParamsTimeSpan) { TradeHistoryParamsTimeSpan tradeHistoryParamsTimeSpan = (TradeHistoryParamsTimeSpan) params; startTime = tradeHistoryParamsTimeSpan.getStartTime(); endTime = tradeHistoryParamsTimeSpan.getEndTime(); } ItBitTradeHistory userTradeHistory = getUserTradeHistory(transactionId, page, pageLength, startTime, endTime); return ItBitAdapters.adaptTradeHistory(userTradeHistory); }
Date startTime = ((TradeHistoryParamsTimeSpan) params).getStartTime(); if (startTime != null) { since = (int) DateUtils.toUnixTime(startTime);