forked from thrasher-corp/gocryptotrader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
okex_types.go
257 lines (226 loc) · 7.85 KB
/
okex_types.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
package okex
import "encoding/json"
// ContractPrice holds date and ticker price price for contracts.
type ContractPrice struct {
Date string `json:"date"`
Ticker struct {
Buy float64 `json:"buy"`
ContractID float64 `json:"contract_id"`
High float64 `json:"high"`
Low float64 `json:"low"`
Last float64 `json:"last"`
Sell float64 `json:"sell"`
UnitAmount float64 `json:"unit_amount"`
Vol float64 `json:"vol"`
} `json:"ticker"`
Result bool `json:"result"`
Error interface{} `json:"error_code"`
}
type MultiStreamData struct {
Channel string `json:"channel"`
Data json.RawMessage `json:"data"`
}
type TickerStreamData struct {
Buy string `json:"buy"`
Change string `json:"change"`
High string `json:"high"`
Low string `json:"low"`
Last string `json:"last"`
Sell string `json:"sell"`
DayLow string `json:"dayLow"`
DayHigh string `json:"dayHigh"`
Timestamp float64 `json:"timestamp"`
Vol string `json:"vol"`
}
type DealsStreamData = [][]string
type KlineStreamData = [][]string
type DepthStreamData struct {
Asks [][]string `json:"asks"`
Bids [][]string `json:"bids"`
Timestamp float64 `json:"timestamp"`
}
// ContractDepth response depth
type ContractDepth struct {
Asks []interface{} `json:"asks"`
Bids []interface{} `json:"bids"`
Result bool `json:"result"`
Error interface{} `json:"error_code"`
}
// ActualContractDepth better manipulated structure to return
type ActualContractDepth struct {
Asks []struct {
Price float64
Volume float64
}
Bids []struct {
Price float64
Volume float64
}
}
// ActualContractTradeHistory holds contract trade history
type ActualContractTradeHistory struct {
Amount float64 `json:"amount"`
DateInMS float64 `json:"date_ms"`
Date float64 `json:"date"`
Price float64 `json:"price"`
TID float64 `json:"tid"`
Type string `json:"buy"`
}
// CandleStickData holds candlestick data
type CandleStickData struct {
Timestamp float64 `json:"timestamp"`
Open float64 `json:"open"`
High float64 `json:"high"`
Low float64 `json:"low"`
Close float64 `json:"close"`
Volume float64 `json:"volume"`
Amount float64 `json:"amount"`
}
// Info holds individual information
type Info struct {
AccountRights float64 `json:"account_rights"`
KeepDeposit float64 `json:"keep_deposit"`
ProfitReal float64 `json:"profit_real"`
ProfitUnreal float64 `json:"profit_unreal"`
RiskRate float64 `json:"risk_rate"`
}
// UserInfo holds a collection of user data
type UserInfo struct {
Info struct {
BTC Info `json:"btc"`
LTC Info `json:"ltc"`
} `json:"info"`
Result bool `json:"result"`
}
// HoldData is a sub type for FuturePosition
type HoldData struct {
BuyAmount float64 `json:"buy_amount"`
BuyAvailable float64 `json:"buy_available"`
BuyPriceAvg float64 `json:"buy_price_avg"`
BuyPriceCost float64 `json:"buy_price_cost"`
BuyProfitReal float64 `json:"buy_profit_real"`
ContractID float64 `json:"contract_id"`
ContractType string `json:"contract_type"`
CreateDate int `json:"create_date"`
LeverRate float64 `json:"lever_rate"`
SellAmount float64 `json:"sell_amount"`
SellAvailable float64 `json:"sell_available"`
SellPriceAvg float64 `json:"sell_price_avg"`
SellPriceCost float64 `json:"sell_price_cost"`
SellProfitReal float64 `json:"sell_profit_real"`
Symbol string `json:"symbol"`
}
// FuturePosition contains an array of holding types
type FuturePosition struct {
ForceLiquidationPrice float64 `json:"force_liqu_price"`
Holding []HoldData `json:"holding"`
}
// FutureTradeHistory will contain futures trade data
type FutureTradeHistory struct {
Amount float64 `json:"amount"`
Date int `json:"date"`
Price float64 `json:"price"`
TID float64 `json:"tid"`
Type string `json:"type"`
}
// SpotPrice holds date and ticker price price for contracts.
type SpotPrice struct {
Date string `json:"date"`
Ticker struct {
Buy float64 `json:"buy,string"`
ContractID float64 `json:"contract_id"`
High float64 `json:"high,string"`
Low float64 `json:"low,string"`
Last float64 `json:"last,string"`
Sell float64 `json:"sell,string"`
UnitAmount float64 `json:"unit_amount,string"`
Vol float64 `json:"vol,string"`
} `json:"ticker"`
Result bool `json:"result"`
Error interface{} `json:"error_code"`
}
// SpotDepth response depth
type SpotDepth struct {
Asks []interface{} `json:"asks"`
Bids []interface{} `json:"bids"`
Result bool `json:"result"`
Error interface{} `json:"error_code"`
}
// ActualSpotDepthRequestParams represents Klines request data.
type ActualSpotDepthRequestParams struct {
Symbol string `json:"symbol"` // Symbol; example ltc_btc
Size int `json:"size"` // value: 1-200
}
// ActualSpotDepth better manipulated structure to return
type ActualSpotDepth struct {
Asks []struct {
Price float64
Volume float64
}
Bids []struct {
Price float64
Volume float64
}
}
// ActualSpotTradeHistoryRequestParams represents Klines request data.
type ActualSpotTradeHistoryRequestParams struct {
Symbol string `json:"symbol"` // Symbol; example ltc_btc
Since int `json:"since"` // TID; transaction record ID (return data does not include the current TID value, returning up to 600 items)
}
// ActualSpotTradeHistory holds contract trade history
type ActualSpotTradeHistory struct {
Amount float64 `json:"amount"`
DateInMS float64 `json:"date_ms"`
Date float64 `json:"date"`
Price float64 `json:"price"`
TID float64 `json:"tid"`
Type string `json:"buy"`
}
// SpotUserInfo holds the spot user info
type SpotUserInfo struct {
Result bool `json:"result"`
Info map[string]map[string]map[string]string `json:"info"`
}
// SpotNewOrderRequestParams holds the params for making a new spot order
type SpotNewOrderRequestParams struct {
Amount float64 `json:"amount"` // Order quantity
Price float64 `json:"price"` // Order price
Symbol string `json:"symbol"` // Symbol; example btc_usdt, eth_btc......
Type SpotNewOrderRequestType `json:"type"` // Order type (see below)
}
// SpotNewOrderRequestType order type
type SpotNewOrderRequestType string
var (
// SpotNewOrderRequestTypeBuy buy order
SpotNewOrderRequestTypeBuy = SpotNewOrderRequestType("buy")
// SpotNewOrderRequestTypeSell sell order
SpotNewOrderRequestTypeSell = SpotNewOrderRequestType("sell")
// SpotNewOrderRequestTypeBuyMarket buy market order
SpotNewOrderRequestTypeBuyMarket = SpotNewOrderRequestType("buy_market")
// SpotNewOrderRequestTypeSellMarket sell market order
SpotNewOrderRequestTypeSellMarket = SpotNewOrderRequestType("sell_market")
)
// KlinesRequestParams represents Klines request data.
type KlinesRequestParams struct {
Symbol string // Symbol; example btcusdt, bccbtc......
Type TimeInterval // Kline data time interval; 1min, 5min, 15min......
Size int // Size; [1-2000]
Since int64 // Since timestamp, return data after the specified timestamp (for example, 1417536000000)
}
// TimeInterval represents interval enum.
type TimeInterval string
// vars for time intervals
var (
TimeIntervalMinute = TimeInterval("1min")
TimeIntervalThreeMinutes = TimeInterval("3min")
TimeIntervalFiveMinutes = TimeInterval("5min")
TimeIntervalFifteenMinutes = TimeInterval("15min")
TimeIntervalThirtyMinutes = TimeInterval("30min")
TimeIntervalHour = TimeInterval("1hour")
TimeIntervalFourHours = TimeInterval("4hour")
TimeIntervalSixHours = TimeInterval("6hour")
TimeIntervalTwelveHours = TimeInterval("12hour")
TimeIntervalDay = TimeInterval("1day")
TimeIntervalThreeDays = TimeInterval("3day")
TimeIntervalWeek = TimeInterval("1week")
)