forked from thrasher-corp/gocryptotrader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bitstamp_types.go
243 lines (212 loc) · 6.61 KB
/
bitstamp_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
package bitstamp
import "errors"
// Transaction types
const (
Deposit = iota
Withdrawal
MarketTrade
SubAccountTransfer = 14
)
// Order side type
const (
BuyOrder = iota
SellOrder
)
var errWSPairParsingError = errors.New("unable to parse currency pair from wsResponse.Channel")
// Ticker holds ticker information
type Ticker struct {
Last float64 `json:"last,string"`
High float64 `json:"high,string"`
Low float64 `json:"low,string"`
Vwap float64 `json:"vwap,string"`
Volume float64 `json:"volume,string"`
Bid float64 `json:"bid,string"`
Ask float64 `json:"ask,string"`
Timestamp int64 `json:"timestamp,string"`
Open float64 `json:"open,string"`
}
// OrderbookBase holds singular price information
type OrderbookBase struct {
Price float64
Amount float64
}
// Orderbook holds orderbook information
type Orderbook struct {
Timestamp int64 `json:"timestamp,string"`
Bids []OrderbookBase
Asks []OrderbookBase
}
// TradingPair holds trading pair information
type TradingPair struct {
Name string `json:"name"`
URLSymbol string `json:"url_symbol"`
BaseDecimals int `json:"base_decimals"`
CounterDecimals int `json:"counter_decimals"`
MinimumOrder string `json:"minimum_order"`
Trading string `json:"trading"`
Description string `json:"description"`
}
// Transactions holds transaction data
type Transactions struct {
Date int64 `json:"date,string"`
TradeID int64 `json:"tid,string"`
Price float64 `json:"price,string"`
Type int `json:"type,string"`
Amount float64 `json:"amount,string"`
}
// EURUSDConversionRate holds buy sell conversion rate information
type EURUSDConversionRate struct {
Buy float64 `json:"buy,string"`
Sell float64 `json:"sell,string"`
}
// Balance stores the balance info
type Balance struct {
Available float64
Balance float64
Reserved float64
WithdrawalFee float64
BTCFee float64 // for cryptocurrency pairs
USDFee float64
EURFee float64
}
// Balances holds full balance information with the supplied APIKEYS
type Balances map[string]Balance
// UserTransactions holds user transaction information
type UserTransactions struct {
Date string `json:"datetime"`
TransactionID int64 `json:"id"`
Type int `json:"type,string"`
USD float64 `json:"usd"`
EUR float64 `json:"eur"`
BTC float64 `json:"btc"`
XRP float64 `json:"xrp"`
BTCUSD float64 `json:"btc_usd"`
Fee float64 `json:"fee,string"`
OrderID int64 `json:"order_id"`
}
// Order holds current open order data
type Order struct {
ID int64 `json:"id,string"`
DateTime string `json:"datetime"`
Type int `json:"type,string"`
Price float64 `json:"price,string"`
Amount float64 `json:"amount,string"`
Currency string `json:"currency_pair"`
}
// OrderStatus holds order status information
type OrderStatus struct {
Price float64 `json:"price,string"`
Amount float64 `json:"amount,string"`
Type int `json:"type"`
ID int64 `json:"id,string"`
DateTime string `json:"datetime"`
Status string
Transactions []struct {
TradeID int64 `json:"tid"`
USD float64 `json:"usd,string"`
Price float64 `json:"price,string"`
Fee float64 `json:"fee,string"`
BTC float64 `json:"btc,string"`
}
}
// CancelOrder holds the order cancellation info
type CancelOrder struct {
Price float64 `json:"price"`
Amount float64 `json:"amount"`
Type int `json:"type"`
ID int64 `json:"id"`
}
// DepositAddress holds the deposit info
type DepositAddress struct {
Address string `json:"address"`
DestinationTag int64 `json:"destination_tag"`
}
// WithdrawalRequests holds request information on withdrawals
type WithdrawalRequests struct {
OrderID int64 `json:"id"`
Date string `json:"datetime"`
Type int `json:"type"`
Amount float64 `json:"amount,string"`
Status int `json:"status"`
Data interface{}
Address string `json:"address"` // Bitcoin withdrawals only
TransactionID string `json:"transaction_id"` // Bitcoin withdrawals only
}
// CryptoWithdrawalResponse response from a crypto withdrawal request
type CryptoWithdrawalResponse struct {
ID int64 `json:"id"`
}
// FIATWithdrawalResponse response from a fiat withdrawal request
type FIATWithdrawalResponse struct {
ID int64 `json:"id"`
}
// UnconfirmedBTCTransactions holds address information about unconfirmed
// transactions
type UnconfirmedBTCTransactions struct {
Amount float64 `json:"amount,string"`
Address string `json:"address"`
Confirmations int `json:"confirmations"`
}
// CaptureError is used to capture unmarshalled errors
type CaptureError struct {
Status interface{} `json:"status"`
Reason interface{} `json:"reason"`
Code interface{} `json:"code"`
Error interface{} `json:"error"`
}
const (
sepaWithdrawal string = "sepa"
internationalWithdrawal string = "international"
errStr string = "error"
)
type websocketEventRequest struct {
Event string `json:"event"`
Data websocketData `json:"data"`
}
type websocketData struct {
Channel string `json:"channel"`
}
type websocketResponse struct {
Event string `json:"event"`
Channel string `json:"channel"`
}
type websocketTradeResponse struct {
websocketResponse
Data websocketTradeData `json:"data"`
}
type websocketTradeData struct {
Microtimestamp string `json:"microtimestamp"`
Amount float64 `json:"amount"`
BuyOrderID int64 `json:"buy_order_id"`
SellOrderID int64 `json:"sell_order_id"`
AmountStr string `json:"amount_str"`
PriceStr string `json:"price_str"`
Timestamp int64 `json:"timestamp,string"`
Price float64 `json:"price"`
Type int `json:"type"`
ID int64 `json:"id"`
}
type websocketOrderBookResponse struct {
websocketResponse
Data websocketOrderBook `json:"data"`
}
type websocketOrderBook struct {
Asks [][]string `json:"asks"`
Bids [][]string `json:"bids"`
Timestamp int64 `json:"timestamp,string"`
Microtimestamp string `json:"microtimestamp"`
}
// OHLCResponse holds returned candle data
type OHLCResponse struct {
Data struct {
Pair string `json:"pair"`
OHLCV []struct {
Timestamp int64 `json:"timestamp,string"`
Open float64 `json:"open,string"`
High float64 `json:"high,string"`
Low float64 `json:"low,string"`
Close float64 `json:"close,string"`
Volume float64 `json:"volume,string"`
} `json:"ohlc"`
} `json:"data"`
}