From c527cd6fda37ead7ecf53b364900bda8310e199f Mon Sep 17 00:00:00 2001 From: if1live Date: Mon, 26 Jun 2017 21:25:33 +0900 Subject: [PATCH] implement returnLendingHistory --- exchanges/poloniex/poloniex.go | 21 +++++++++++++++++++++ exchanges/poloniex/poloniex_types.go | 13 +++++++++++++ 2 files changed, 34 insertions(+) diff --git a/exchanges/poloniex/poloniex.go b/exchanges/poloniex/poloniex.go index 0cb695af..0db968a2 100644 --- a/exchanges/poloniex/poloniex.go +++ b/exchanges/poloniex/poloniex.go @@ -42,6 +42,7 @@ const ( POLONIEX_CANCEL_LOAN_OFFER = "cancelLoanOffer" POLONIEX_OPEN_LOAN_OFFERS = "returnOpenLoanOffers" POLONIEX_ACTIVE_LOANS = "returnActiveLoans" + POLONIEX_LENDING_HISTORY = "returnLendingHistory" POLONIEX_AUTO_RENEW = "toggleAutoRenew" ) @@ -705,6 +706,26 @@ func (p *Poloniex) GetActiveLoans() (PoloniexActiveLoans, error) { return result, nil } +func (p *Poloniex) GetLendingHistory(start, end string) ([]PoloniexLendingHistory, error) { + vals := url.Values{} + + if start != "" { + vals.Set("start", start) + } + + if end != "" { + vals.Set("end", end) + } + + resp := []PoloniexLendingHistory{} + err := p.SendAuthenticatedHTTPRequest("POST", POLONIEX_LENDING_HISTORY, vals, &resp) + + if err != nil { + return nil, err + } + return resp, nil +} + func (p *Poloniex) ToggleAutoRenew(orderNumber int64) (bool, error) { values := url.Values{} values.Set("orderNumber", strconv.FormatInt(orderNumber, 10)) diff --git a/exchanges/poloniex/poloniex_types.go b/exchanges/poloniex/poloniex_types.go index 76c6e71c..013ba5d1 100644 --- a/exchanges/poloniex/poloniex_types.go +++ b/exchanges/poloniex/poloniex_types.go @@ -218,3 +218,16 @@ type PoloniexActiveLoans struct { Provided []PoloniexLoanOffer `json:"provided"` Used []PoloniexLoanOffer `json:"used"` } + +type PoloniexLendingHistory struct { + ID int64 `json:"id"` + Currency string `json:"currency"` + Rate float64 `json:"rate,string"` + Amount float64 `json:"amount,string"` + Duration float64 `json:"duration,string"` + Interest float64 `json:"interest,string"` + Fee float64 `json:"fee,string"` + Earned float64 `json:"earned,string"` + Open string `json:"open"` + Close string `json:"close"` +}