-
Notifications
You must be signed in to change notification settings - Fork 17
/
gemini-api.d.ts
307 lines (265 loc) · 7.1 KB
/
gemini-api.d.ts
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
// Type definitions for gemini-api
// Project: https://github.com/mjesuele/gemini-api-node
// Definitions by: Evan Shortiss <https://github.com/evanshortiss/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.23
// This is not publicly exposed, but is instead exposed as a static member of
// the GeminiAPI (aka RestClient)
declare class WebsocketClient {}
export class GeminiAPI {
constructor (options: RestClientOptions)
static WebsocketClient: WebsocketClient
/**
* Retrieves all available symbols for trading.
*/
getAllSymbols(): Promise<string[]>
/**
* Retrieves information about recent trading activity for the symbol.
* @param symbol
*/
getTicker(symbol: string): Promise<Ticker>
/**
* This will return the current order book, as two arrays, one of bids, and one of asks.
* @param symbol
* @param params
*/
getOrderBook(symbol: string, params?: OrderBook): Promise<OrderBook>
/**
* This will return the trades that have executed since the specified timestamp.
* Timestamps are either seconds or milliseconds since the epoch (1970-01-01).
* See the Data Types section of the Gemini API docs for information on this.
* @param symbol
* @param params
*/
getTradeHistory(symbol: string, params?: Params.TradeHistory): Promise<Trade[]>
/**
* Retreives details of the current auction.
* @param symbol
*/
getCurrentAuction(symbol: string): Promise<AuctionClosedState|AuctionOpenedState|AuctionIndicativePriceState>
/**
* This will return the auction events, optionally including publications of
* indicative prices, since the specific timestamp.
* @param symbol
* @param params
*/
getAuctionHistory(symbol: string, params?: Params.AuctionHistory): Promise<AuctionHistoryEntry[]>
/**
* Place an order. Only limit orders are supported via the API.
* @param params
*/
newOrder(params: Params.NewOrder): Promise<OrderStatus>
/**
* This will cancel an order. If the order is already canceled, the message
* will succeed but have no effect.
* @param params
*/
cancelOrder(params: Params.CancelOrder): Promise<OrderStatus>
/**
* Cancel all orders for this session.
*/
cancelAllSessionOrders(): Promise<{ result: boolean }>
/**
* This will cancel all outstanding orders created by all sessions owned by
* this account, including interactive orders placed through the UI.
*/
cancelAllActiveOrders(): Promise<{ result: boolean }>
/**
* Gets the status for an order
* @param params
*/
getMyOrderStatus(params: Params.OrderStatus): Promise<OrderStatus>
/**
* Returns active orders for the session account.
*/
getMyActiveOrders(): Promise<OrderStatus[]>
/**
* Returns past trades. 50 are returned by default, with a max of 500 being
* returned if the limit_trades param is passed.
* @param params
*/
getMyPastTrades(params?: Params.AccountPastTrades): Promise<AccountTradesEntry[]>
/**
* Returns the trade volume for the session account.
*/
getMyTradeVolume(): Promise<TradeVolumeEntry[]>
/**
* Returns available balances in the supported currencies
*/
getMyAvailableBalances(): Promise<AccountBalancesEntry[]>
}
export type OrderSide = 'buy'|'sell'
export type OrderType = 'exchange limit'
export type OrderExecutionOption = 'maker-or-cancel'|'immediate-or-cancel'|'auction-only'
export namespace Params {
interface CancelOrder {
client_order_id: string
}
interface OrderStatus {
client_order_id: string
}
interface NewOrder {
client_order_id?: string
symbol: string
amount: string
price: string
side: OrderSide
type: OrderType
options?: OrderExecutionOption
}
interface AuctionHistory {
limit_auction_results: number
include_indicative: boolean
since: number
}
interface AccountOrderBook {
limit_asks?: number
limit_bids?: number
}
interface TradeHistory {
timestamp?: number
limit_trades?: number
include_breaks?: number
}
interface AccountPastTrades {
symbol: string
limit_trades?: number
timestamp?: number
}
}
export interface AuctionHistoryEntry {
auction_id: number
auction_price: string
auction_quantity: string
eid: number
highest_bid_price: string
lowest_ask_price: string
collar_price: string
auction_result: string
timestamp: number
timestampms: number
event_type: string
}
export interface AuctionClosedState {
closed_until_ms: number
last_auction_price: string
last_auction_quantity: string
last_highest_bid_price: string
last_lowest_ask_price: string
last_collar_price: string
next_auction_ms: number
}
export interface AuctionOpenedState {
last_auction_eid: number
last_auction_price: string
last_auction_quantity: string
last_highest_bid_price: string
last_lowest_ask_price: string
last_collar_price: string
next_auction_ms: number
next_update_ms: number
}
export interface AuctionIndicativePriceState {
last_auction_eid: number
most_recent_indicative_price: string
most_recent_indicative_quantity: string
most_recent_highest_bid_price: string
most_recent_lowest_ask_price: string
most_recent_collar_price: string
next_auction_ms: number
next_update_ms: number
}
export interface AccountBalancesEntry {
currency: string
amount: string
available: string
availableForWithdrawal: string
}
export interface AccountTradesEntry {
price: string
amount: string
timestamp: number
timestampms: number
type: string
aggressor: boolean
fee_currency: string
fee_amount: string
tid: number
order_id: string
exchange: string
is_auction_fill: boolean
break?: boolean
}
export interface TradeVolumeEntry {
account_id: string
symbol: string
base_currency: string
notional_currency: string
data_date: string
total_volume_base: string
maker_buy_sell_ratio: string
buy_maker_base: string
buy_maker_notional: string
buy_maker_count: string
sell_maker_base: string
sell_maker_notional: string
sell_maker_count: string
buy_taker_base: string
buy_taker_notional: string
buy_taker_count: string
sell_taker_base: string
sell_taker_notional: string
sell_taker_count: string
}
export interface Trade {
timestamp: number
timestampms: number
tid: number
price: string
amount: string
exchange: string
type: string
broken: boolean
}
export interface Ticker {
ask: string
bid: string
last: string
volume: {
BTC?: string
ETH?: string
USD?: string
timestamp: number
}
}
export interface OrderStatus {
order_id: string
client_order_id: string
symbol: string
price: string
avg_execution_price: string
side: OrderSide
type: OrderType
timestamp: string
timestampms: number
is_live: boolean
is_cancelled: false
options: OrderExecutionOption[],
executed_amount: string
remaining_amount: string
original_amount: string
}
export interface OrderBookEntry {
price: string
amount: string
}
export interface OrderBook {
bids: Array<OrderBookEntry>
asks: Array<OrderBookEntry>
}
export interface RestClientOptions {
key: string
secret: string
sandbox?: boolean
}
export default GeminiAPI;