-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathloan.go
52 lines (48 loc) · 1.27 KB
/
loan.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package binance
import (
"fmt"
"github.com/shopspring/decimal"
"net/http"
)
type LoanRow struct {
LoanCoin string `json:"loanCoin"`
TotalDebt decimal.Decimal `json:"totalDebt"`
CollateralCoin string `json:"collateralCoin"`
CollateralAmount decimal.Decimal `json:"collateralAmount"`
CurrentLTV decimal.Decimal `json:"currentLTV"`
}
type LoanData struct {
Rows []LoanRow `json:"rows"`
Total int64 `json:"total"`
}
func (bc *Client) GetFlexibleLoanOnGoingOrder(loanCoin, collateralCoin string, page, limit string) (LoanData, error) {
var (
result LoanData
)
requestURL := fmt.Sprintf("%s/sapi/v2/loan/flexible/ongoing/orders", bc.apiBaseURL)
req, err := NewRequestBuilder(http.MethodGet, requestURL, nil)
if err != nil {
return result, err
}
rr := req.WithHeader(apiKeyHeader, bc.apiKey)
if loanCoin != "" {
rr = rr.WithParam("loanCoin", loanCoin)
}
if collateralCoin != "" {
rr = rr.WithParam("collateralCoin", collateralCoin)
}
if page != "" {
rr = rr.WithParam("current", page)
}
if limit != "" {
rr = rr.WithParam("limit", limit)
} else {
rr = rr.WithParam("limit", "100")
}
s := rr.SignedRequest(bc.secretKey)
_, err = bc.doRequest(s, &result)
if err != nil {
return result, err
}
return result, err
}