-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorder.go
106 lines (94 loc) · 2.96 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package hitbtc
import (
"github.com/google/go-querystring/query"
)
type CancelOrder struct {
ClientOrderId string `url:"clientOrderId"` //Yes string Order ID, the same as in cancelling order, from 8 to 32 characters
CancelRequestClientOrderId string `url:"cancelRequestClientOrderId"` //No string Unqiue ID generated by client, from 8 to 32 characters
Symbol string `url:"symbol"` //No string Currency symbol, the same as in cancelling order
Side Side `url:"side"` //No buy or sell Side of a trade, the same as in cancelling order
}
type CancelOrders struct {
Symbol string `url:"symbol"` //No string Currency symbol, the same as in cancelling order
Side Side `url:"side"` //No buy or sell Side of a trade, the same as in cancelling order
}
/*
{"CancelReject":{"clientOrderId":"giwSASrcCGVoGcuTaLzoPGAzcssEWeRs",
"cancelRequestClientOrderId":"0cdcca37ff320b9385f88199a3823019",
"rejectReasonCode":"orderNotFound"}}*/
type CancelOrderRejected struct {
CancelReject struct {
ClientOrderId string `json:"clientOrderId"`
CancelRequestClientOrderId string `json:"cancelRequestClientOrderId"`
RejectReasonCode string `json:"rejectReasonCode"`
} `json:"CancelReject"`
}
type CancelOrderResponse struct {
}
func (t *CancelOrder) String() string {
v, _ := query.Values(t)
if t.CancelRequestClientOrderId == "" {
v.Del("cancelRequestClientOrderId")
}
if t.Symbol == "" {
v.Del("symbol")
}
if t.Side == "" {
v.Del("side")
}
return v.Encode()
}
func (t *CancelOrders) String() string {
v, _ := query.Values(t)
if t.Symbol == "" {
v.Del("symbol")
}
if t.Side == "" {
v.Del("Side")
}
return v.Encode()
}
func NewCancelOrders(pair string) *CancelOrders {
return &CancelOrders{
Symbol: pair,
}
}
func NewCancelOrder(clientOrderId string) *CancelOrder {
return &CancelOrder{
ClientOrderId: clientOrderId,
}
}
func NewQueryOrder(clientOrderId string) *CancelOrder {
return &CancelOrder{
ClientOrderId: clientOrderId,
}
}
type oneQueryOrder struct {
OrderId int64 `json:"orderId"`
OrderStatus string `json:"orderStatus"`
LastTimestamp int64 `json:"lastTimestamp"`
OrderPrice float64 `json:"orderPrice,string"`
OrderQuantity float64 `json:"orderQuantity"`
AvgPrice float64 `json:"avgPrice,string"`
QuantityLeaves float64 `json:"quantityLeaves"`
Type string `json:"type"`
TimeInForce string `json:"timeInForce"`
CumQuantity float64 `json:"cumQuantity"`
ClientOrderId string `json:"clientOrderId"`
Symbol string `json:"symbol"`
Side string `json:"side"`
ExecQuantity float64 `json:"execQuantity"`
}
type queryOrders struct {
Orders []oneQueryOrder `json:"orders"`
}
type OneQueryOrder struct {
OrderId string
Symbol string
DealAmount float64
RemainAmount float64
AvgPrice float64
}
type QueryOrder struct {
Orders []OneQueryOrder
}