forked from Gerifield/gobitpanda
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmarketticker.go
More file actions
42 lines (32 loc) · 979 Bytes
/
marketticker.go
File metadata and controls
42 lines (32 loc) · 979 Bytes
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
package gobitpanda
import (
"errors"
"fmt"
)
// GetMarketTicker returns statistics on all available instruments
func (c *Client) GetMarketTicker() (*[]MarketTick, error) {
marketTicks := &[]MarketTick{}
req, err := c.NewRequest("GET", fmt.Sprintf("%s%s", c.APIBase, "/v1/market-ticker"), nil)
if err != nil {
return marketTicks, err
}
if err = c.Send(req, marketTicks); err != nil {
return marketTicks, err
}
return marketTicks, nil
}
// GetMarketTickerByCode gets statistics on a single market
func (c *Client) GetMarketTickerByCode(instrumentCode string) (*MarketTick, error) {
if instrumentCode == "" {
return nil, errors.New("instrumentCode can not be empty")
}
marketTick := &MarketTick{}
req, err := c.NewRequest("GET", fmt.Sprintf("%s%s%s", c.APIBase, "/v1/market-ticker/", instrumentCode), nil)
if err != nil {
return marketTick, err
}
if err = c.Send(req, marketTick); err != nil {
return marketTick, err
}
return marketTick, nil
}