forked from go-numb/go-ftx
/
stats.go
48 lines (38 loc) · 1.13 KB
/
stats.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
package futures
import (
"fmt"
"net/http"
"time"
)
type RequestForStats struct {
ProductCode string `url:"-"`
}
type ResponseForStats Stats
type StatsList []Stats
type Stats struct {
Name string `json:"name,omitempty"`
Volume float64 `json:"volume"`
NextFundingRate float64 `json:"nextFundingRate"`
ExpirationPrice float64 `json:"expirationPrice"`
PredictedExpirationPrice float64 `json:"predictedExpirationPrice"`
StrikePrice float64 `json:"strikePrice"`
OpenInterest float64 `json:"openInterest"`
NextFundingTime time.Time `json:"nextFundingTime"`
}
func (req *RequestForStats) Path() string {
return fmt.Sprintf("/futures/%s/stats", req.ProductCode)
}
func (req *RequestForStats) Method() string {
return http.MethodGet
}
func (req *RequestForStats) Query() string {
return ""
}
func (req *RequestForStats) Payload() []byte {
return nil
}
func (a StatsList) Len() int { return len(a) }
func (a StatsList) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a StatsList) Less(i, j int) bool {
return a[i].NextFundingRate < a[j].NextFundingRate
}