forked from thrasher-corp/gocryptotrader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kraken_types.go
310 lines (280 loc) · 8.37 KB
/
kraken_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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
package kraken
// TimeResponse type
type TimeResponse struct {
Unixtime int64 `json:"unixtime"`
Rfc1123 string `json:"rfc1123"`
}
// Asset holds asset information
type Asset struct {
Altname string `json:"altname"`
AclassBase string `json:"aclass_base"`
Decimals int `json:"decimals"`
DisplayDecimals int `json:"display_decimals"`
}
// AssetPairs holds asset pair information
type AssetPairs struct {
Altname string `json:"altname"`
AclassBase string `json:"aclass_base"`
Base string `json:"base"`
AclassQuote string `json:"aclass_quote"`
Quote string `json:"quote"`
Lot string `json:"lot"`
PairDecimals int `json:"pair_decimals"`
LotDecimals int `json:"lot_decimals"`
LotMultiplier int `json:"lot_multiplier"`
LeverageBuy []int `json:"leverage_buy"`
LeverageSell []int `json:"leverage_sell"`
Fees [][]float64 `json:"fees"`
FeesMaker [][]float64 `json:"fees_maker"`
FeeVolumeCurrency string `json:"fee_volume_currency"`
MarginCall int `json:"margin_call"`
MarginStop int `json:"margin_stop"`
}
// Ticker is a standard ticker type
type Ticker struct {
Ask float64
Bid float64
Last float64
Volume float64
VWAP float64
Trades int64
Low float64
High float64
Open float64
}
// TickerResponse holds ticker information before its put into the Ticker struct
type TickerResponse struct {
Ask []string `json:"a"`
Bid []string `json:"b"`
Last []string `json:"c"`
Volume []string `json:"v"`
VWAP []string `json:"p"`
Trades []int64 `json:"t"`
Low []string `json:"l"`
High []string `json:"h"`
Open string `json:"o"`
}
// OpenHighLowClose contains ticker event information
type OpenHighLowClose struct {
Time float64
Open float64
High float64
Low float64
Close float64
Vwap float64
Volume float64
Count float64
}
// RecentTrades holds recent trade data
type RecentTrades struct {
Price float64
Volume float64
Time float64
BuyOrSell string
MarketOrLimit string
Miscellaneous interface{}
}
// OrderbookBase stores the orderbook price and amount data
type OrderbookBase struct {
Price float64
Amount float64
}
// Orderbook stores the bids and asks orderbook data
type Orderbook struct {
Bids []OrderbookBase
Asks []OrderbookBase
}
// Spread holds the spread between trades
type Spread struct {
Time float64
Bid float64
Ask float64
}
// TradeBalanceOptions type
type TradeBalanceOptions struct {
Aclass string
Asset string
}
// TradeBalanceInfo type
type TradeBalanceInfo struct {
EquivalentBalance float64 `json:"eb,string"` // combined balance of all currencies
TradeBalance float64 `json:"tb,string"` // combined balance of all equity currencies
MarginAmount float64 `json:"m,string"` // margin amount of open positions
Net float64 `json:"n,string"` // unrealized net profit/loss of open positions
Equity float64 `json:"e,string"` // trade balance + unrealized net profit/loss
FreeMargin float64 `json:"mf,string"` // equity - initial margin (maximum margin available to open new positions)
MarginLevel float64 `json:"ml,string"` // (equity / initial margin) * 100
}
// OrderInfo type
type OrderInfo struct {
RefID string `json:"refid"`
UserRef int32 `json:"userref"`
Status string `json:"status"`
OpenTm float64 `json:"opentm"`
StartTm float64 `json:"starttm"`
ExpireTm float64 `json:"expiretm"`
Descr struct {
Pair string `json:"pair"`
Type string `json:"type"`
OrderType string `json:"ordertype"`
Price float64 `json:"price,string"`
Price2 float64 `json:"price2,string"`
Leverage string `json:"leverage"`
Order string `json:"order"`
Close string `json:"close"`
} `json:"descr"`
Vol float64 `json:"vol,string"`
VolExec float64 `json:"vol_exec,string"`
Cost float64 `json:"cost,string"`
Fee float64 `json:"fee,string"`
Price float64 `json:"price,string"`
StopPrice float64 `json:"stopprice,string"`
LimitPrice float64 `json:"limitprice,string"`
Misc string `json:"misc"`
Oflags string `json:"oflags"`
Trades []string `json:"trades"`
}
// OpenOrders type
type OpenOrders struct {
Open map[string]OrderInfo `json:"open"`
Count int64 `json:"count"`
}
// ClosedOrders type
type ClosedOrders struct {
Closed map[string]OrderInfo `json:"closed"`
Count int64 `json:"count"`
}
// GetClosedOrdersOptions type
type GetClosedOrdersOptions struct {
Trades bool
UserRef int32
Start string
End string
Ofs int64
CloseTime string
}
// OrderInfoOptions type
type OrderInfoOptions struct {
Trades bool
UserRef int32
}
// GetTradesHistoryOptions type
type GetTradesHistoryOptions struct {
Type string
Trades bool
Start string
End string
Ofs int64
}
// TradesHistory type
type TradesHistory struct {
Trades map[string]TradeInfo `json:"trades"`
Count int64 `json:"count"`
}
// TradeInfo type
type TradeInfo struct {
OrderTxID string `json:"ordertxid"`
Pair string `json:"pair"`
Time float64 `json:"time"`
Type string `json:"type"`
OrderType string `json:"ordertype"`
Price float64 `json:"price,string"`
Cost float64 `json:"cost,string"`
Fee float64 `json:"fee,string"`
Vol float64 `json:"vol,string"`
Margin float64 `json:"margin,string"`
Misc string `json:"misc"`
PosTxID string `json:"postxid"`
Cprice float64 `json:"cprice,string"`
Cfee float64 `json:"cfee,string"`
Cvol float64 `json:"cvol,string"`
Cmargin float64 `json:"cmargin,string"`
Trades []string `json:"trades"`
PosStatus string `json:"posstatus"`
}
// Position holds the opened position
type Position struct {
Ordertxid string `json:"ordertxid"`
Pair string `json:"pair"`
Time float64 `json:"time"`
Type string `json:"type"`
OrderType string `json:"ordertype"`
Cost float64 `json:"cost,string"`
Fee float64 `json:"fee,string"`
Vol float64 `json:"vol,string"`
VolClosed float64 `json:"vol_closed,string"`
Margin float64 `json:"margin,string"`
Rollovertm int64 `json:"rollovertm,string"`
Misc string `json:"misc"`
Oflags string `json:"oflags"`
PosStatus string `json:"posstatus"`
Net string `json:"net"`
Terms string `json:"terms"`
}
// GetLedgersOptions type
type GetLedgersOptions struct {
Aclass string
Asset string
Type string
Start string
End string
Ofs int64
}
// Ledgers type
type Ledgers struct {
Ledger map[string]LedgerInfo `json:"ledger"`
Count int64 `json:"count"`
}
// LedgerInfo type
type LedgerInfo struct {
Refid string `json:"refid"`
Time float64 `json:"time"`
Type string `json:"type"`
Aclass string `json:"aclass"`
Asset string `json:"asset"`
Amount float64 `json:"amount,string"`
Fee float64 `json:"fee,string"`
Balance float64 `json:"balance,string"`
}
// TradeVolumeResponse type
type TradeVolumeResponse struct {
Currency string `json:"currency"`
Volume float64 `json:"volume,string"`
Fees map[string]TradeVolumeFee `json:"fees"`
FeesMaker map[string]TradeVolumeFee `json:"fees_maker"`
}
// TradeVolumeFee type
type TradeVolumeFee struct {
Fee float64 `json:"fee,string"`
MinFee float64 `json:"minfee,string"`
MaxFee float64 `json:"maxfee,string"`
NextFee float64 `json:"nextfee,string"`
NextVolume float64 `json:"nextvolume,string"`
TierVolume float64 `json:"tiervolume,string"`
}
// AddOrderResponse type
type AddOrderResponse struct {
Description OrderDescription `json:"descr"`
TransactionIds []string `json:"txid"`
}
// OrderDescription represents an orders description
type OrderDescription struct {
Close string `json:"close"`
Order string `json:"order"`
}
// AddOrderOptions represents the AddOrder options
type AddOrderOptions struct {
UserRef int32
Oflags string
StartTm string
ExpireTm string
CloseOrderType string
ClosePrice float64
ClosePrice2 float64
Validate bool
}
// CancelOrderResponse type
type CancelOrderResponse struct {
Count int64 `json:"count"`
Pending interface{} `json:"pending"`
}