forked from Gerifield/gobitpanda
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.go
More file actions
422 lines (373 loc) · 12.3 KB
/
types.go
File metadata and controls
422 lines (373 loc) · 12.3 KB
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
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
package gobitpanda
import (
"net/http"
"sync"
"time"
)
const (
// APIBase points to the public Bitpanda Global Exchange API
APIBase = "https://api.exchange.bitpanda.com/public"
)
// Currency codes
const (
CurrencyBEST string = "BEST"
CurrencyBTC string = "BTC"
CurrencyETH string = "ETH"
CurrencyEUR string = "EUR"
CurrencyMIOTA string = "MIOTA"
CurrencyPAN string = "PAN"
CurrencyUSDT string = "USDT"
CurrencyXRP string = "XRP"
)
// Instrument codes
const (
InstrumentBESTBTC string = "BEST_BTC"
InstrumentBESTEUR string = "BEST_EUR"
InstrumentBESTUSDT string = "BEST_USDT"
InstrumentBTCEUR string = "BTC_EUR"
InstrumentBTCUSDT string = "BTC_USDT"
InstrumentETHBTC string = "ETH_BTC"
InstrumentETHEUR string = "ETH_EUR"
InstrumentMIOTABTC string = "MIOTA_BTC"
InstrumentMIOTAEUR string = "MIOTA_EUR"
InstrumentPANBTC string = "PAN_BTC"
InstrumentXRPBTC string = "XRP_BTC"
InstrumentXRPEUR string = "XRP_EUR"
)
// Levels
const (
LevelOne int = 1
LevelTwo int = 2
LevelThree int = 3
LevelDefault int = 3
)
// Possible value for `type` in orders
//
// https://developers.bitpanda.com/exchange/#/orders-post
const (
OrderTypeMarket string = "MARKET"
OrderTypeLimit string = "LIMIT"
OrderTypeStop string = "STOP"
)
// Possible value for `side` in orders
const (
OrderSideBuy string = "BUY"
OrderSideSell string = "SELL"
)
// Periods
const (
PeriodOneMinute int = 1
PeriodFiveMinutes int = 5
PeriodFifteenMinutes int = 15
PeriodThirtyMinutes int = 30
PeriodOneHour int = 1
PeriodFourHours int = 4
PeriodOneDay int = 1
PeriodOneWeek int = 1
PeriodOneMonth int = 1
)
// Status
const (
StatusOpen string = "OPEN"
StatusStopTriggered string = "STOP_TRIGGERED"
StatusFilled string = "FILLED"
StatusFilledFully string = "FILLED_FULLY"
StatusFilledClosed string = "FILLED_CLOSED"
StatusFilledRejected string = "FILLED_REJECTED"
StatusRejected string = "REJECTED"
StatusClosed string = "CLOSED"
StatusFailed string = "FAILED"
)
// Units
const (
UnitMinutes string = "MINUTES"
UnitHours string = "HOURS"
UnitDays string = "DAYS"
UnitWeeks string = "WEEKS"
UnitMonths string = "MONTHS"
)
type (
// Account details of a registered user's balance(s).
Account struct {
AccountID string `json:"account_id"`
Balances []Balance `json:"balances"`
}
// AccountFees struct
AccountFees struct {
AccountID string `json:"account_id"`
RunningTradingVolume string `json:"running_trading_volume"`
FeeGroupID string `json:"fee_group_id"`
FeeTiers []FeeTier `json:"fee_tiers"`
ActiveFeeTier FeeTier `json:"active_fee_tier"`
CollectFeesInBest bool `json:"collect_fees_in_best"`
FeeDiscountRate string `json:"fee_discount_rate"`
MinimumPriceValue string `json:"minimum_price_value"`
}
// Ask struct
Ask struct {
Value Value `json:"value"`
}
//Asks struct
Asks struct {
Price string `json:"price,omitempty"`
Amount string `json:"amount,omitempty"`
NumberOfOrders uint `json:"number_of_orders,omitempty"`
OrderID string `json:"order_id,omitempty"`
}
// Balance Account balance for one single currency
Balance struct {
AccountID string `json:"account_id"`
CurrencyCode string `json:"currency_code"`
Change string `json:"change"`
Available string `json:"available"`
Locked string `json:"locked"`
Sequence uint `json:"sequence"`
Time time.Time `json:"time"` // RFC3339
}
// Bid struct
Bid struct {
Value Value `json:"value"`
}
//Bids struct
Bids struct {
Price string `json:"price,omitempty"`
Amount string `json:"amount,omitempty"`
NumberOfOrders uint `json:"number_of_orders,omitempty"`
OrderID string `json:"order_id,omitempty"`
}
// Candlestick representing price action for a given period
Candlestick struct {
LastSequence uint `json:"last_sequence"`
InstrumentCode string `json:"instrument_code"`
Granularity Granularity `json:"granularity"`
High string `json:"high"`
Low string `json:"low"`
Open string `json:"open"`
Close string `json:"close"`
Volume string `json:"volume"`
Time time.Time `json:"time"` // RFC3339
}
// Client represents a Bitpanda REST API Client
Client struct {
sync.Mutex
Client *http.Client
APIBase string
APIToken string
}
// CreateOrder struct
CreateOrder struct {
InstrumentCode string `json:"instrument_code"`
Type string `json:"type"`
Side string `json:"side"`
Amount string `json:"amount"`
Price string `json:"price,omitempty"`
TriggerPrice string `json:"trigger_price,omitempty"`
ClientID string `json:"client_id,omitempty"`
}
// Currency struct
Currency struct {
Code string `json:"code"`
Precision int `json:"precision,omitempty"`
}
// CurrencyCode struct
CurrencyCode struct {
Code string `json:"currency"`
}
// DepositReturn struct
DepositReturn struct {
Address string `json:"address"`
DestinationTag string `json:"destinationTag"`
Enabled bool `json:"enabled"`
CanCreateMore bool `json:"can_create_more"`
SmartContract bool `json:"is_smart_contract"`
}
// WithdrawReturn struct
WithdrawReturn struct {
Amount string `json:"amount"`
Recipient string `json:"recipient"`
DestinationTag string `json:"destinationTag"`
Fee string `json:"fee"`
}
// ErrorResponse struct
ErrorResponse struct {
Response *http.Response `json:"-"`
Error string `json:"error"`
}
// Fee applied account balance as part of trade settlement
Fee struct {
FeeAmount string `json:"fee_amount"`
FeeCurreny string `json:"fee_currency"`
FeePercentage string `json:"fee_percentage"`
FeeGroupID string `json:"fee_group_id"`
FeeType string `json:"fee_type"`
RunningTradingVolume string `json:"running_trading_volume"`
}
// FeeGroup struct
FeeGroup struct {
FeeGroupID string `json:"fee_group_id"`
DisplayText string `json:"display_text,omitempty"`
FeeTiers []FeeTier `json:"fee_tiers"`
FeeDiscountRate string `json:"fee_discount_rate"`
MinimumPriceValue string `json:"minimum_price_value"`
}
// FeeMode toggle to enable or disable fee collection with BEST
FeeMode struct {
CollectFeesInBest bool `json:"collect_fees_in_best"`
}
// FeeTier struct
FeeTier struct {
FeeGroupID string `json:"fee_group_id"`
Volume string `json:"volume"`
MakerFee string `json:"maker_fee"`
TakerFee string `json:"taker_fee"`
}
// FiatDepositReturn struct
FiatDepositReturn struct {
IBAN string `json:"iban"`
BIC string `json:"bic"`
Bank string `json:"bank"`
Address string `json:"address"`
Receiver string `json:"receiver"`
ReceiverAddress string `json:"receiver_address"`
UniquePaymentNumber string `json:"unique_payment_number"`
}
// Granularity struct
Granularity struct {
Unit string `json:"unit"`
Period uint `json:"period"`
}
// Instrument struct
Instrument struct {
State string `json:"state"`
Base Currency `json:"base"`
Quote Currency `json:"quote"`
AmountPrecision uint `json:"amount_precision"`
MarketPrecision uint `json:"market_precision"`
MinSize string `json:"min_size"`
}
// MarketTick struct
MarketTick struct {
InstrumentCode string `json:"instrument_code"`
Sequence int `json:"sequence"`
State string `json:"state"`
IsFrozen int `json:"is_frozen"`
QuoteVolume string `json:"quote_volume"`
BaseVolume string `json:"base_volume"`
LastPrice string `json:"last_price"`
BestBid string `json:"best_bid"`
BestAsk string `json:"best_ask"`
PriceChange string `json:"price_change"`
PriceChangePercentage string `json:"price_change_percentage"`
High string `json:"high"`
Low string `json:"low"`
}
// Order struct
Order struct {
OrderID string `json:"order_id"`
AccountID string `json:"account_id"`
InstrumentCode string `json:"instrument_code"`
Amount string `json:"amount"`
FilledAmount string `json:"filled_amount"`
Side string `json:"side"`
Type string `json:"type"`
Status string `json:"status"`
Sequence uint `json:"sequence,omitempty"`
Price string `json:"price"`
Reason string `json:"reason,omitempty"`
Time time.Time `json:"time"` // RFC3339
TimeLastUpdated time.Time `json:"time_last_updated,omitempty"` // RFC3339
TimeTriggered time.Time `json:"time_triggered,omitempty"` // RFC3339
TriggerPrice string `json:"trigger_price,omitempty"`
}
// OrderBook a snapshot of the order book state
OrderBook struct {
InstrumentCode string `json:"instrument_code"`
Time time.Time `json:"time"` // RFC3339
Bids []Bids `json:"bids"`
Asks []Asks `json:"asks"`
}
// OrderBookLvlOne a snapshot of the order book state
OrderBookLvlOne struct {
InstrumentCode string `json:"instrument_code"`
Time time.Time `json:"time"` // RFC3339
Bids Bid `json:"bids"`
Asks Ask `json:"asks"`
}
// OrderHistory Paginated collection of account orders
OrderHistory struct {
OrderHistory []OrderHistoryEntry `json:"order_history"`
MaxPageSize uint `json:"max_page_size,omitempty"`
Cursor string `json:"cursor,omitempty"`
}
// OrderHistoryEntry active or inactive order, for orders with the status FILLED, FILLED_FULLY, FILLED_CLOSED and FILLED_REJECTED, information about trades and fees is returned.
OrderHistoryEntry struct {
Order Order `json:"order"`
Trades []TradeHistoryEntry `json:"trades"`
}
// PriceTick struct
PriceTick struct {
InstrumentCode string `json:"instrument_code"`
Price string `json:"price"`
Amount string `json:"amount"`
Volume string `json:"volume"`
Sequence int `json:"sequence"`
TakerSide string `json:"taker_side"`
Time time.Time `json:"time"`
TradeTimestamp int64 `json:"trade_timestamp"`
}
// Recipient struct
Recipient struct {
Address string `json:"address"`
DestinationTag string `json:"destination_tag"`
}
// Time struct
Time struct {
Iso string `json:"iso"` // RFC3339
EpochMillis uint64 `json:"epoch_millis"`
}
// TimeGranularity is a length of time defined by unit and period used to identify the type of candlestick.
// Supported resolutions are 1, 5, 15, 30 MINUTES & 1, 4 HOURS & 1 DAYS & 1 WEEKS & 1 MONTHS.
TimeGranularity struct {
Unit string `json:"unit"`
Period uint `json:"period"`
}
// Trade struct
Trade struct {
TradeID string `json:"trade_id"`
OrderID string `json:"order_id"`
AccountID string `json:"account_id"`
Amount string `json:"amount"`
Side string `json:"side"`
InstrumentCode string `json:"instrument_code"`
Price string `json:"price"`
Time time.Time `json:"time"` // RFC3339
Sequence uint `json:"sequence,omitempty"`
}
// TradeHistory Paginated collection of account trades
TradeHistory struct {
TradeHistory []TradeHistoryEntry `json:"trade_history"`
MaxPageSize uint `json:"max_page_size,omitempty"`
Cursor string `json:"cursor,omitempty"`
}
// TradeHistoryEntry Trade recorded for exactly one order
TradeHistoryEntry struct {
Trade Trade `json:"trade"`
Fee Fee `json:"fee"`
}
// TradingVolume struct
TradingVolume struct {
Volume string `json:"volume"`
}
// Value struct
Value struct {
Price string `json:"price"`
Amount string `json:"amount"`
NumberOfOrders uint `json:"number_of_orders"`
}
//Withdraw struct
Withdraw struct {
Currency string `json:"currency"`
Amount string `json:"amount"`
Recipient Recipient `json:"recipient"`
}
)