This commit is contained in:
Adrian Gallagher
2017-06-27 17:03:43 +10:00
2 changed files with 50 additions and 20 deletions

View File

@@ -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))

View File

@@ -1,9 +1,5 @@
package poloniex
import (
"time"
)
type PoloniexTicker struct {
Last float64 `json:"last,string"`
LowestAsk float64 `json:"lowestAsk,string"`
@@ -92,24 +88,24 @@ type PoloniexDepositAddresses struct {
type PoloniexDepositsWithdrawals struct {
Deposits []struct {
Currency string `json:"currency"`
Address string `json:"address"`
Amount float64 `json:"amount,string"`
Confirmations int `json:"confirmations"`
TransactionID string `json:"txid"`
Timestamp time.Time `json:"timestamp"`
Status string `json:"string"`
Currency string `json:"currency"`
Address string `json:"address"`
Amount float64 `json:"amount,string"`
Confirmations int `json:"confirmations"`
TransactionID string `json:"txid"`
Timestamp int64 `json:"timestamp"`
Status string `json:"status"`
} `json:"deposits"`
Withdrawals []struct {
WithdrawalNumber int64 `json:"withdrawalNumber"`
Currency string `json:"currency"`
Address string `json:"address"`
Amount float64 `json:"amount,string"`
Confirmations int `json:"confirmations"`
TransactionID string `json:"txid"`
Timestamp time.Time `json:"timestamp"`
Status string `json:"string"`
IPAddress string `json:"ipAddress"`
WithdrawalNumber int64 `json:"withdrawalNumber"`
Currency string `json:"currency"`
Address string `json:"address"`
Amount float64 `json:"amount,string"`
Confirmations int `json:"confirmations"`
TransactionID string `json:"txid"`
Timestamp int64 `json:"timestamp"`
Status string `json:"status"`
IPAddress string `json:"ipAddress"`
} `json:"withdrawals"`
}
@@ -222,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"`
}