use of org.knowm.xchange.dto.account.FundingRecord in project XChange by knowm.
the class BitstampAdapters method adaptFundingHistory.
public static List<FundingRecord> adaptFundingHistory(List<BitstampUserTransaction> userTransactions) {
List<FundingRecord> fundingRecords = new ArrayList<>();
for (BitstampUserTransaction trans : userTransactions) {
if (trans.isDeposit() || trans.isWithdrawal() || trans.isSubAccountTransfer()) {
Map.Entry<String, BigDecimal> amount = BitstampAdapters.findNonzeroAmount(trans);
FundingRecord.Type type = FundingRecord.Type.DEPOSIT;
if (trans.isWithdrawal()) {
type = FundingRecord.Type.WITHDRAWAL;
} else {
if (trans.isSubAccountTransfer()) {
if (amount.getValue().compareTo(BigDecimal.ZERO) > 0) {
type = FundingRecord.Type.INTERNAL_DEPOSIT;
} else {
type = FundingRecord.Type.INTERNAL_WITHDRAWAL;
}
}
}
FundingRecord record = new FundingRecord(null, trans.getDatetime(), Currency.getInstance(amount.getKey()), amount.getValue().abs(), String.valueOf(trans.getId()), null, type, FundingRecord.Status.COMPLETE, null, trans.getFee(), null);
fundingRecords.add(record);
}
}
return fundingRecords;
}
use of org.knowm.xchange.dto.account.FundingRecord in project XChange by knowm.
the class OkCoinAccountDemo method fundingHistory.
private static void fundingHistory(AccountService accountService) throws IOException {
// Get the funds information
TradeHistoryParams params = accountService.createFundingHistoryParams();
if (params instanceof TradeHistoryParamPaging) {
TradeHistoryParamPaging pagingParams = (TradeHistoryParamPaging) params;
pagingParams.setPageLength(50);
pagingParams.setPageNumber(1);
}
if (params instanceof TradeHistoryParamCurrencyPair) {
((TradeHistoryParamCurrencyPair) params).setCurrencyPair(CurrencyPair.BTC_CNY);
}
final List<FundingRecord> fundingRecords = accountService.getFundingHistory(params);
AccountServiceTestUtil.printFundingHistory(fundingRecords);
}
use of org.knowm.xchange.dto.account.FundingRecord in project XChange by knowm.
the class KrakenAccountDemo method fundingHistory.
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);
}
use of org.knowm.xchange.dto.account.FundingRecord in project XChange by knowm.
the class AccountServiceIntegration method testWithdrawalHistory.
@Test
public void testWithdrawalHistory() throws Exception {
assumeProduction();
TradeHistoryParams params = accountService.createFundingHistoryParams();
List<FundingRecord> fundingHistory = accountService.getFundingHistory(params);
Assert.assertNotNull(fundingHistory);
fundingHistory.forEach(record -> {
Assert.assertTrue(record.getAmount().compareTo(BigDecimal.ZERO) > 0);
});
}
use of org.knowm.xchange.dto.account.FundingRecord in project XChange by knowm.
the class OkexAccountService method getFundingHistory.
@Override
public List<FundingRecord> getFundingHistory(TradeHistoryParams params) throws IOException {
boolean withdrawals = true, deposits = true;
if (params instanceof HistoryParamsFundingType) {
HistoryParamsFundingType p = (HistoryParamsFundingType) params;
withdrawals = p.getType() == null || p.getType() == Type.WITHDRAWAL;
deposits = p.getType() == null || p.getType() == Type.DEPOSIT;
}
List<FundingRecord> result = new ArrayList<>();
if (withdrawals) {
result.addAll(recentWithdrawalHistory().stream().map(OkexAdaptersV3::adaptFundingRecord).collect(Collectors.toList()));
}
if (deposits) {
result.addAll(recentDepositHistory().stream().map(OkexAdaptersV3::adaptFundingRecord).collect(Collectors.toList()));
}
Collections.sort(result, (r1, r2) -> r1.getDate().compareTo(r2.getDate()));
return result;
}
Aggregations