forked from thrasher-corp/gocryptotrader
/
gdax_types.go
405 lines (372 loc) · 12.9 KB
/
gdax_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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
package gdax
// Product holds product information
type Product struct {
ID string `json:"id"`
BaseCurrency string `json:"base_currency"`
QuoteCurrency string `json:"quote_currency"`
BaseMinSize float64 `json:"base_min_size,string"`
BaseMaxSize int64 `json:"base_max_size,string"`
QuoteIncrement float64 `json:"quote_increment,string"`
DisplayName string `json:"string"`
}
// Ticker holds basic ticker information
type Ticker struct {
TradeID int64 `json:"trade_id"`
Price float64 `json:"price,string"`
Size float64 `json:"size,string"`
Time string `json:"time"`
}
// Trade holds executed trade information
type Trade struct {
TradeID int64 `json:"trade_id"`
Price float64 `json:"price,string"`
Size float64 `json:"size,string"`
Time string `json:"time"`
Side string `json:"side"`
}
// History holds historic rate information
type History struct {
Time int64 `json:"time"`
Low float64 `json:"low"`
High float64 `json:"high"`
Open float64 `json:"open"`
Close float64 `json:"close"`
Volume float64 `json:"volume"`
}
// Stats holds last 24 hr data for gdax
type Stats struct {
Open float64 `json:"open,string"`
High float64 `json:"high,string"`
Low float64 `json:"low,string"`
Volume float64 `json:"volume,string"`
}
// Currency holds singular currency product information
type Currency struct {
ID string
Name string
MinSize float64 `json:"min_size,string"`
}
// ServerTime holds current requested server time information
type ServerTime struct {
ISO string `json:"iso"`
Epoch float64 `json:"epoch"`
}
// AccountResponse holds the details for the trading accounts
type AccountResponse struct {
ID string `json:"id"`
Currency string `json:"currency"`
Balance float64 `json:"balance,string"`
Available float64 `json:"available,string"`
Hold float64 `json:"hold,string"`
ProfileID string `json:"profile_id"`
MarginEnabled bool `json:"margin_enabled"`
FundedAmount float64 `json:"funded_amount,string"`
DefaultAmount float64 `json:"default_amount,string"`
}
// AccountLedgerResponse holds account history information
type AccountLedgerResponse struct {
ID string `json:"id"`
CreatedAt string `json:"created_at"`
Amount float64 `json:"amount,string"`
Balance float64 `json:"balance,string"`
Type string `json:"type"`
Details interface{} `json:"details"`
}
// AccountHolds contains the hold information about an account
type AccountHolds struct {
ID string `json:"id"`
AccountID string `json:"account_id"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
Amount float64 `json:"amount,string"`
Type string `json:"type"`
Reference string `json:"ref"`
}
// GeneralizedOrderResponse is the generalized return type across order
// placement and information collation
type GeneralizedOrderResponse struct {
ID string `json:"id"`
Price float64 `json:"price,string"`
Size float64 `json:"size,string"`
ProductID string `json:"product_id"`
Side string `json:"side"`
Stp string `json:"stp"`
Type string `json:"type"`
TimeInForce string `json:"time_in_force"`
PostOnly bool `json:"post_only"`
CreatedAt string `json:"created_at"`
FillFees float64 `json:"fill_fees,string"`
FilledSize float64 `json:"filled_size,string"`
ExecutedValue float64 `json:"executed_value,string"`
Status string `json:"status"`
Settled bool `json:"settled"`
Funds float64 `json:"funds,string"`
SpecifiedFunds float64 `json:"specified_funds,string"`
DoneReason string `json:"done_reason"`
DoneAt string `json:"done_at"`
}
// Funding holds funding data
type Funding struct {
ID string `json:"id"`
OrderID string `json:"order_id"`
ProfileID string `json:"profile_id"`
Amount float64 `json:"amount,string"`
Status string `json:"status"`
CreatedAt string `json:"created_at"`
Currency string `json:"currency"`
RepaidAmount float64 `json:"repaid_amount"`
DefaultAmount float64 `json:"default_amount,string"`
RepaidDefault bool `json:"repaid_default"`
}
// MarginTransfer holds margin transfer details
type MarginTransfer struct {
CreatedAt string `json:"created_at"`
ID string `json:"id"`
UserID string `json:"user_id"`
ProfileID string `json:"profile_id"`
MarginProfileID string `json:"margin_profile_id"`
Type string `json:"type"`
Amount float64 `json:"amount,string"`
Currency string `json:"currency"`
AccountID string `json:"account_id"`
MarginAccountID string `json:"margin_account_id"`
MarginProductID string `json:"margin_product_id"`
Status string `json:"status"`
Nonce int `json:"nonce"`
}
// AccountOverview holds account information returned from position
type AccountOverview struct {
Status string `json:"status"`
Funding struct {
MaxFundingValue float64 `json:"max_funding_value,string"`
FundingValue float64 `json:"funding_value,string"`
OldestOutstanding struct {
ID string `json:"id"`
OrderID string `json:"order_id"`
CreatedAt string `json:"created_at"`
Currency string `json:"currency"`
AccountID string `json:"account_id"`
Amount float64 `json:"amount,string"`
} `json:"oldest_outstanding"`
} `json:"funding"`
Accounts struct {
LTC Account `json:"LTC"`
ETH Account `json:"ETH"`
USD Account `json:"USD"`
BTC Account `json:"BTC"`
} `json:"accounts"`
MarginCall struct {
Active bool `json:"active"`
Price float64 `json:"price,string"`
Side string `json:"side"`
Size float64 `json:"size,string"`
Funds float64 `json:"funds,string"`
} `json:"margin_call"`
UserID string `json:"user_id"`
ProfileID string `json:"profile_id"`
Position struct {
Type string `json:"type"`
Size float64 `json:"size,string"`
Complement float64 `json:"complement,string"`
MaxSize float64 `json:"max_size,string"`
} `json:"position"`
ProductID string `json:"product_id"`
}
// Account is a sub-type for account overview
type Account struct {
ID string `json:"id"`
Balance float64 `json:"balance,string"`
Hold float64 `json:"hold,string"`
FundedAmount float64 `json:"funded_amount,string"`
DefaultAmount float64 `json:"default_amount,string"`
}
// PaymentMethod holds payment method information
type PaymentMethod struct {
ID string `json:"id"`
Type string `json:"type"`
Name string `json:"name"`
Currency string `json:"currency"`
PrimaryBuy bool `json:"primary_buy"`
PrimarySell bool `json:"primary_sell"`
AllowBuy bool `json:"allow_buy"`
AllowSell bool `json:"allow_sell"`
AllowDeposits bool `json:"allow_deposits"`
AllowWithdraw bool `json:"allow_withdraw"`
Limits struct {
Buy []LimitInfo `json:"buy"`
InstantBuy []LimitInfo `json:"instant_buy"`
Sell []LimitInfo `json:"sell"`
Deposit []LimitInfo `json:"deposit"`
} `json:"limits"`
}
// LimitInfo is a sub-type for payment method
type LimitInfo struct {
PeriodInDays int `json:"period_in_days"`
Total struct {
Amount float64 `json:"amount,string"`
Currency string `json:"currency"`
} `json:"total"`
}
// DepositWithdrawalInfo holds returned deposit information
type DepositWithdrawalInfo struct {
ID string `json:"id"`
Amount float64 `json:"amount,string"`
Currency string `json:"currency"`
PayoutAt string `json:"payout_at"`
}
// CoinbaseAccounts holds coinbase account information
type CoinbaseAccounts struct {
ID string `json:"id"`
Name string `json:"name"`
Balance float64 `json:"balance,string"`
Currency string `json:"currency"`
Type string `json:"type"`
Primary bool `json:"primary"`
Active bool `json:"active"`
WireDepositInformation struct {
AccountNumber string `json:"account_number"`
RoutingNumber string `json:"routing_number"`
BankName string `json:"bank_name"`
BankAddress string `json:"bank_address"`
BankCountry struct {
Code string `json:"code"`
Name string `json:"name"`
} `json:"bank_country"`
AccountName string `json:"account_name"`
AccountAddress string `json:"account_address"`
Reference string `json:"reference"`
} `json:"wire_deposit_information"`
SepaDepositInformation struct {
Iban string `json:"iban"`
Swift string `json:"swift"`
BankName string `json:"bank_name"`
BankAddress string `json:"bank_address"`
BankCountryName string `json:"bank_country_name"`
AccountName string `json:"account_name"`
AccountAddress string `json:"account_address"`
Reference string `json:"reference"`
} `json:"sep_deposit_information"`
}
// Report holds historical information
type Report struct {
ID string `json:"id"`
Type string `json:"type"`
Status string `json:"status"`
CreatedAt string `json:"created_at"`
CompletedAt string `json:"completed_at"`
ExpiresAt string `json:"expires_at"`
FileURL string `json:"file_url"`
Params struct {
StartDate string `json:"start_date"`
EndDate string `json:"end_date"`
} `json:"params"`
}
// Volume type contains trailing volume information
type Volume struct {
ProductID string `json:"product_id"`
ExchangeVolume float64 `json:"exchange_volume,string"`
Volume float64 `json:"volume,string"`
RecordedAt string `json:"recorded_at"`
}
// OrderL1L2 is a type used in layer conversion
type OrderL1L2 struct {
Price float64
Amount float64
NumOrders float64
}
// OrderL3 is a type used in layer conversion
type OrderL3 struct {
Price float64
Amount float64
OrderID string
}
// OrderbookL1L2 holds level 1 and 2 order book information
type OrderbookL1L2 struct {
Sequence int64 `json:"sequence"`
Bids []OrderL1L2 `json:"bids"`
Asks []OrderL1L2 `json:"asks"`
}
// OrderbookL3 holds level 3 order book information
type OrderbookL3 struct {
Sequence int64 `json:"sequence"`
Bids []OrderL3 `json:"bids"`
Asks []OrderL3 `json:"asks"`
}
// OrderbookResponse is a generalized response for order books
type OrderbookResponse struct {
Sequence int64 `json:"sequence"`
Bids [][]interface{} `json:"bids"`
Asks [][]interface{} `json:"asks"`
}
// FillResponse contains fill information from the exchange
type FillResponse struct {
TradeID int `json:"trade_id"`
ProductID string `json:"product_id"`
Price float64 `json:"price,string"`
Size float64 `json:"size,string"`
OrderID string `json:"order_id"`
CreatedAt string `json:"created_at"`
Liquidity string `json:"liquidity"`
Fee float64 `json:"fee,string"`
Settled bool `json:"settled"`
Side string `json:"side"`
}
// WebsocketSubscribe takes in subscription information
type WebsocketSubscribe struct {
Type string `json:"type"`
ProductID string `json:"product_id"`
}
// WebsocketReceived holds websocket received values
type WebsocketReceived struct {
Type string `json:"type"`
Time string `json:"time"`
Sequence int `json:"sequence"`
OrderID string `json:"order_id"`
Size float64 `json:"size,string"`
Price float64 `json:"price,string"`
Side string `json:"side"`
}
// WebsocketOpen collates open orders
type WebsocketOpen struct {
Type string `json:"type"`
Time string `json:"time"`
Sequence int `json:"sequence"`
OrderID string `json:"order_id"`
Price float64 `json:"price,string"`
RemainingSize float64 `json:"remaining_size,string"`
Side string `json:"side"`
}
// WebsocketDone holds finished order information
type WebsocketDone struct {
Type string `json:"type"`
Time string `json:"time"`
Sequence int `json:"sequence"`
Price float64 `json:"price,string"`
OrderID string `json:"order_id"`
Reason string `json:"reason"`
Side string `json:"side"`
RemainingSize float64 `json:"remaining_size,string"`
}
// WebsocketMatch holds match information
type WebsocketMatch struct {
Type string `json:"type"`
TradeID int `json:"trade_id"`
Sequence int `json:"sequence"`
MakerOrderID string `json:"maker_order_id"`
TakerOrderID string `json:"taker_order_id"`
Time string `json:"time"`
Size float64 `json:"size,string"`
Price float64 `json:"price,string"`
Side string `json:"side"`
}
// WebsocketChange holds change information
type WebsocketChange struct {
Type string `json:"type"`
Time string `json:"time"`
Sequence int `json:"sequence"`
OrderID string `json:"order_id"`
NewSize float64 `json:"new_size,string"`
OldSize float64 `json:"old_size,string"`
Price float64 `json:"price,string"`
Side string `json:"side"`
}