forked from go-numb/go-ftx
/
place-order.go
63 lines (51 loc) · 1.42 KB
/
place-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
59
60
61
62
63
package orders
import (
"net/http"
"time"
jsoniter "github.com/json-iterator/go"
)
var json = jsoniter.ConfigCompatibleWithStandardLibrary
type RequestForPlaceOrder struct {
ClientID string `json:"clientId,omitempty"`
Type string `json:"type"`
Market string `json:"market"`
Side string `json:"side"`
Price float64 `json:"price"`
Size float64 `json:"size"`
ReduceOnly bool `json:"reduceOnly,omitempty"`
Ioc bool `json:"ioc,omitempty"`
PostOnly bool `json:"postOnly,omitempty"`
}
type ResponseForPlaceOrder struct {
ClientID string `json:"clientId"`
Status string `json:"status"`
Type string `json:"type"`
Future string `json:"future"`
Market string `json:"market"`
Side string `json:"side"`
Price float64 `json:"price"`
Size float64 `json:"size"`
RemainingSize float64 `json:"remainingSize"`
FilledSize float64 `json:"filledSize"`
ID int `json:"id"`
Ioc bool `json:"ioc"`
PostOnly bool `json:"postOnly"`
ReduceOnly bool `json:"reduceOnly"`
CreatedAt time.Time `json:"createdAt"`
}
func (req *RequestForPlaceOrder) Path() string {
return "/orders"
}
func (req *RequestForPlaceOrder) Method() string {
return http.MethodPost
}
func (req *RequestForPlaceOrder) Query() string {
return ""
}
func (req *RequestForPlaceOrder) Payload() []byte {
b, err := json.Marshal(req)
if err != nil {
return nil
}
return b
}