Search in sources :

Example 1 with LoanInfo

use of org.knowm.xchange.poloniex.dto.LoanInfo in project XChange by knowm.

the class PoloniexAdapters method adaptPoloniexLoans.

public static LoanInfo adaptPoloniexLoans(HashMap<String, PoloniexLoan[]> poloniexLoans) {
    Map<String, List<LoanOrder>> loans = new HashMap<>();
    for (Map.Entry<String, PoloniexLoan[]> item : poloniexLoans.entrySet()) {
        List<LoanOrder> loanOrders = new ArrayList<>();
        for (PoloniexLoan poloniexLoan : item.getValue()) {
            Date date = PoloniexUtils.stringToDate(poloniexLoan.getDate());
            loanOrders.add(new FixedRateLoanOrder(OrderType.ASK, poloniexLoan.getCurrency(), poloniexLoan.getAmount(), poloniexLoan.getRange(), poloniexLoan.getId(), date, // TODO
            poloniexLoan.getRate()));
        }
        loans.put(item.getKey(), loanOrders);
    }
    return new LoanInfo(loans.get("provided"), loans.get("used"));
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) FixedRateLoanOrder(org.knowm.xchange.dto.trade.FixedRateLoanOrder) LoanOrder(org.knowm.xchange.dto.LoanOrder) Date(java.util.Date) FixedRateLoanOrder(org.knowm.xchange.dto.trade.FixedRateLoanOrder) ArrayList(java.util.ArrayList) List(java.util.List) LoanInfo(org.knowm.xchange.poloniex.dto.LoanInfo) HashMap(java.util.HashMap) Map(java.util.Map) PoloniexLoan(org.knowm.xchange.poloniex.dto.account.PoloniexLoan)

Aggregations

ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 LoanOrder (org.knowm.xchange.dto.LoanOrder)1 FixedRateLoanOrder (org.knowm.xchange.dto.trade.FixedRateLoanOrder)1 LoanInfo (org.knowm.xchange.poloniex.dto.LoanInfo)1 PoloniexLoan (org.knowm.xchange.poloniex.dto.account.PoloniexLoan)1