github.com/bitfinexcom/bitfinex-api-go@v0.0.0-20210608095005-9e0b26f200fb/v1/stats.go (about) 1 package bitfinex 2 3 import ( 4 "net/url" 5 "strings" 6 ) 7 8 type StatsService struct { 9 client *Client 10 } 11 12 type Stats struct { 13 Period int64 14 Volume float64 `json:"volume,string"` 15 } 16 17 // All(pair) - Volume stats for specified pair 18 func (s *StatsService) All(pair string, period, volume string) ([]Stats, error) { 19 pair = strings.ToUpper(pair) 20 21 params := url.Values{} 22 if period != "" { 23 params.Add("period", period) 24 } 25 if volume != "" { 26 params.Add("volume", volume) 27 } 28 req, err := s.client.newRequest("GET", "stats/"+strings.ToUpper(pair), params) 29 30 if err != nil { 31 return nil, err 32 } 33 34 var stats []Stats 35 _, err = s.client.do(req, &stats) 36 37 if err != nil { 38 return nil, err 39 } 40 41 return stats, nil 42 }