Skip to content

Commit

Permalink
Merge pull request thrasher-corp#32 from if1live/feature/poloniex-len…
Browse files Browse the repository at this point in the history
…ding-history

Implement Poloniex API wrapper, returnLendingHistory
  • Loading branch information
thrasher- authored Jun 27, 2017
2 parents 5c195b0 + c527cd6 commit 50f2e06
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
21 changes: 21 additions & 0 deletions exchanges/poloniex/poloniex.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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))
Expand Down
13 changes: 13 additions & 0 deletions exchanges/poloniex/poloniex_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

0 comments on commit 50f2e06

Please sign in to comment.