-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
order.go
58 lines (49 loc) · 1.37 KB
/
order.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
package coincheck
import (
"context"
"net/http"
)
// OrderType represents the order type.
type OrderType string
// String returns the string representation of the OrderType.
func (o OrderType) String() string {
return string(o)
}
const (
// OrderTypeBuy is the order type of buy.
OrderTypeBuy OrderType = "buy"
// OrderTypeSell is the order type of sell.
OrderTypeSell OrderType = "sell"
)
// SellOrderStatus represents the sell order status.
// It has the only two elements.
// e.g. [ "27330", "1.25" ]
type SellOrderStatus []string
// BuyOrderStatus represents the buy order status.
// It has the only two elements.
// e.g. [ "12100", "0.12" ]
type BuyOrderStatus []string
// GetOrderBooksResponse represents the structure of the API response.
type GetOrderBooksResponse struct {
// Asks is the sell order status.
Asks []SellOrderStatus `json:"asks"`
// Bids is the buy order status.
Bids []BuyOrderStatus `json:"bids"`
}
// GetOrderBooks fetch order book information.
// API: GET /api/order_books
// Visibility: Public
func (c *Client) GetOrderBooks(ctx context.Context) (*GetOrderBooksResponse, error) {
req, err := c.createRequest(ctx, createRequestInput{
method: http.MethodGet,
path: "/api/order_books",
})
if err != nil {
return nil, err
}
var output GetOrderBooksResponse
if err := c.do(req, &output); err != nil {
return nil, err
}
return &output, nil
}