-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ticker.go
82 lines (74 loc) · 2.33 KB
/
ticker.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package coincheck
import (
"context"
"net/http"
)
// Pair represents the pair of the currency.
type Pair string
// String returns the string representation of the pair.
func (p Pair) String() string {
return string(p)
}
const (
// PairBTCJPY is the pair of Bitcoin and Japanese Yen.
PairBTCJPY Pair = "btc_jpy"
// PairETCJPY is the pair of Ethereum Classic and Japanese Yen.
PairETCJPY Pair = "etc_jpy"
// PairLskJPY is the pair of Lisk and Japanese Yen.
PairLskJPY Pair = "lsk_jpy"
// PairMonaJPY is the pair of MonaCoin and Japanese Yen.
PairMonaJPY Pair = "mona_jpy"
// PairPltJPY is the pair of Palette Token and Japanese Yen.
PairPltJPY Pair = "plt_jpy"
// PairFnctJPY is the pair of FiNANCiE and Japanese Yen.
PairFnctJPY Pair = "fnct_jpy"
// PairDaiJPY is the pair of DAI and Japanese Yen.
PairDaiJPY Pair = "dai_jpy"
// PairWbtcJPY is the pair of Wrapped Bitcoin and Japanese Yen.
PairWbtcJPY Pair = "wbtc_jpy"
// PairBrilJPY is the pair of Brilliantcrypto and Japanese Yen.
PairBrilJPY Pair = "bril_jpy"
)
// GetTickerInput represents the input parameter for GetTicker.
type GetTickerInput struct {
// Pair is the pair of the currency. e.g. btc_jpy.
Pair Pair
}
// GetTickerResponse represents the output from GetTicker.
type GetTickerResponse struct {
// Last is latest quote.
Last float64 `json:"last"`
// Bid is current highest buying order.
Bid float64 `json:"bid"`
// Ask is current lowest selling order.
Ask float64 `json:"ask"`
// High is highest price in last 24 hours.
High float64 `json:"high"`
// Low is lowest price in last 24 hours.
Low float64 `json:"low"`
// Volume is trading Volume in last 24 hours.
Volume float64 `json:"volume"`
// Timestamp is current time. It's Unix Timestamp.
Timestamp float64 `json:"timestamp"`
}
// GetTicker check latest ticker information.
// API: GET /api/ticker
// Visibility: Public
// If pair is not specified, you can get the information of btc_jpy.
func (c *Client) GetTicker(ctx context.Context, input GetTickerInput) (*GetTickerResponse, error) {
req, err := c.createRequest(ctx, createRequestInput{
method: http.MethodGet,
path: "/api/ticker",
queryParam: map[string]string{
"pair": string(input.Pair),
},
})
if err != nil {
return nil, err
}
var output GetTickerResponse
if err := c.do(req, &output); err != nil {
return nil, err
}
return &output, nil
}