-
Notifications
You must be signed in to change notification settings - Fork 762
Expand file tree
/
Copy pathtypes.ts
More file actions
603 lines (552 loc) · 14.5 KB
/
types.ts
File metadata and controls
603 lines (552 loc) · 14.5 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
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
// trying to keep them compatible with
// https://github.com/ViewBlock/binance-api-node/blob/master/index.d.ts
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE'
export type Interval =
| '1m'
| '3m'
| '5m'
| '15m'
| '30m'
| '1h'
| '2h'
| '4h'
| '6h'
| '8h'
| '12h'
| '1d'
| '3d'
| '1w'
| '1M'
export type OrderType =
| 'LIMIT'
| 'MARKET'
| 'STOP'
| 'STOP_MARKET'
| 'TAKE_PROFIT'
| 'TAKE_PROFIT_MARKET'
| 'LIMIT_MAKER'
| 'TRAILING_STOP_MARKET'
export type OrderSide = 'BUY' | 'SELL'
export type OrderStatus =
| 'CANCELED'
| 'EXPIRED'
| 'FILLED'
| 'NEW'
| 'PARTIALLY_FILLED'
| 'PENDING_CANCEL'
| 'REJECTED'
export type TimeInForce = 'GTC' | 'IOC' | 'FOK' | 'GTE_GTC' | 'GTD'
export interface Response {
code: number
msg: string
}
export interface Candle {
openTime: number
open: string
high: string
low: string
close: string
volume: string
closeTime: number
quoteVolume?: string
trades: number
baseAssetVolume?: string
quoteAssetVolume: string
}
export interface OrderFill {
tradeId: number
price: string
qty: string
commission: string
commissionAsset: string
}
export interface Order {
clientOrderId: string
cummulativeQuoteQty: string
executedQty: string
fills?: OrderFill[]
icebergQty?: string
isIsolated?: boolean
isWorking: boolean
orderId: number
orderListId: number
origQty: string
price: string
side: OrderSide
status: OrderStatus
stopPrice?: string
symbol: string
time: number
timeInForce: TimeInForce
transactTime?: number
type: OrderType
updateTime: number
}
export interface FuturesOrder {
clientOrderId: string
cumQty: string
cumQuote: string
executedQty: string
orderId: number
avgPrice: string
origQty: string
price: string
reduceOnly: boolean
side: OrderSide
positionSide: PositionSide
status: OrderStatus
stopPrice: string
closePosition: boolean
symbol: string
timeInForce: TimeInForce
type: OrderType
origType: OrderType
activatePrice: string
priceRate: string
updateTime: number
workingType: WorkingType
}
export type PositionSide = 'BOTH' | 'SHORT' | 'LONG'
export type WorkingType = 'MARK_PRICE' | 'CONTRACT_PRICE'
// export type symbol = string;
// eslint-disable-next-line
export type Callback = (...args: any) => any;
export interface IConstructorArgs {
APIKEY: string;
APISECRET: string;
PRIVATEKEY: string; // when using RSA/EDCSA keys
PRIVATEKEYPASSWORD: string; // when using RSA/EDCSA keys
recvWindow: number;
useServerTime: boolean;
reconnect: boolean;
test: boolean;
hedgeMode: boolean;
httpsProxy: string;
socksProxy: string;
domain: string;
headers: Record<string, any>;
// eslint-disable-next-line
log: (...args: any[]) => void;
verbose: boolean;
keepAlive: boolean;
localAddress: boolean;
family: boolean;
urls: Partial<{
base: string;
wapi: string;
sapi: string;
fapi: string;
fapiTest: string;
stream: string;
combineStream: string;
fstream: string;
fstreamSingle: string;
fstreamTest: string;
fstreamSingleTest: string;
dstream: string;
dstreamSingle: string;
dstreamTest: string;
dstreamSingleTest: string;
}>;
timeOffset: number;
}
export interface IWebsocketsMethods {
// deprecated, using it for backward compatibility
/* eslint-disable */
userData(all_updates_callback?: Callback, balance_callback?: Callback, execution_callback?: Callback, subscribed_callback?: Callback, list_status_callback?: Callback);
userMarginData(call_updates_callback?: Callback, balance_callback?: Callback, executionCallback?: Callback, subscribedCallback?: Callback, list_statusCallback?: Callback);
depthCacheStaggered(symbols :string |string[], callback?: Callback, limit?: number, stagger?: number);
userFutureData(all_updates_callback?: Callback, margin_callCallback?: Callback, account_updateCallback?: Callback, order_updateCallback?: Callback, subscribedCallback?: Callback);
userDeliveryData(all_updates_callback?: Callback, margin_callCallback?: Callback, account_updateCallback?: Callback, order_updateCallback?: Callback, subscribedCallback?: Callback): any;
subscribeCombined(url: string, callback: Callback, reconnect?: Callback, opened_callback?: Callback);
subscribe(endpoint: string, callback: Callback, reconnect?: Callback, opened_callback?: Callback);
subscriptions(...args: any): any;
futuresSubcriptions(...args: any): any;
deliverySubcriptions(...args: any): any;
terminate(endpoint: string): any;
futuresTerminate(endpoint: string, reconnect?: boolean)
deliveryTerminate(endpoint: string, reconnect?: boolean)
depth(...args: any): any;
depthCache(symbols: string[] | string, callback?: Callback, limit?: number): any;
clearDepthCache(symbols: string | string[]): any;
depthCacheStaggered(symbols: string[] | string, callback: Callback, limit?: number, stagger?: number)
aggTrades(symbols: string | string[], callback: Callback): any;
trades(symbols: string | string[], callback: Callback): string;
chart(symbols: string | string[], interval: Interval, callback?: Callback, limit?: number)
candlesticks(symbols: string | string[], interval: Interval, callback: Callback)
miniTicker(callback: Callback): string;
bookTickers(symbol: string | string[], callback?: Callback): string;
prevDay(symbols: string | string[] | undefined, callback?: Callback, singleCallback?: Callback)
futuresCandlesticks(symbols: string[] | string, interval: Interval, callback: Callback)
futuresTicker(symbol?: string, callback?: Callback)
futuresMiniTicker(symbol?: string, callback?: Callback)
futuresAggTrades(symbols: string[] | string, callback: Callback)
futuresMarkPrice(symbol?: string, callback?: Callback, speed?: string)
futuresLiquidation(symbol?: string, callback?: Callback)
futuresTicker(symbol?: string, callback?: Callback)
futuresBookTicker(symbol?: string, callback?: Callback)
futuresChart(symbols: string[] | string, interval: Interval, callback: Callback, limit?: number)
deliveryAggTrade(symbols: string[] | string, callback: Callback)
deliveryMarkPrice(symbol?: string, callback?: Callback, speed?: string)
deliveryLiquidation(symbol?: string, callback?: Callback)
deliveryTicker(symbol?: string, callback?: Callback)
deliveryMiniTicker(symbol?: string, callback?: Callback)
deliveryBookTicker(symbol?: string, callback?: Callback)
deliveryChart(symbols: string[] | string, interval: Interval, callback: Callback, limit?: number)
deliveryCandlesticks(symbols: string[] | string, interval: Interval, callback: Callback)
}
export interface FundingRate {
symbol: string
fundingRate: string
fundingTime: number
time: number
}
export interface PositionRisk {
breakEvenPrice: string
entryPrice: string
marginType: 'isolated' | 'cross'
isAutoAddMargin: string
isolatedMargin: string
leverage: string
liquidationPrice: string
marginAsset: string
markPrice: string
maxNotionalValue: string
positionAmt: string
symbol: string
unRealizedProfit: string
positionSide: PositionSide
notional: string
isolatedWallet: string
updateTime: number
}
export interface CancelOrder{
symbol: string
origClientOrderId: string
orderId: number
orderListId: number
clientOrderId: string
price: string
origQty: string
executedQty: string
cummulativeQuoteQty: string
status: string
timeInForce: string
type: OrderType
side: OrderSide
}
export interface AggregatedTrade {
aggId: number
symbol: string
price: string
quantity: string
firstId: number
lastId: number
timestamp: number
isBuyerMaker: boolean
wasBestPrice?: boolean
}
export interface Trade {
id: number
price: string
qty: string
quoteQty: string
time: number
isBuyerMaker: boolean
isBestMatch: boolean
}
export interface MyTrade {
id: number
symbol: string
orderId: number
orderListId: number
price: string
qty: string
quoteQty: string
commission: string
commissionAsset: string
time: number
isBuyer: boolean
isMaker: boolean
isBestMatch: boolean
}
export type WithdrawStatus = 0 | 1 | 2 | 3 | 4 | 5 | 6
export interface WithdrawHistoryResponse {
[index: number]: {
id: string
amount: string
transactionFee: string
address: string
coin: string
txId: string
applyTime: number
status: WithdrawStatus
network: string
transferType?: number
withdrawOrderId?: string
}
}
export interface DepositHistoryResponse {
[index: number]: {
insertTime: number
amount: string
coin: string
network: string
address: string
txId: string
status: DepositStatus
addressTag?: string
transferType?: number
confirmTimes?: string
}
}
export interface CancelOrder {
symbol: string
origClientOrderId: string
orderId: number
orderListId: number
clientOrderId: string
price: string
origQty: string
executedQty: string
cummulativeQuoteQty: string
status: string
timeInForce: string
type: OrderType
side: OrderSide
}
export interface FuturesUserTrade {
buyer: boolean
commission: string
commissionAsset: string
id: number
maker: boolean
orderId: number
price: string
qty: string
quoteQty: string
realizedPnl: string
side: OrderSide
positionSide: PositionSide
symbol: string
time: number
}
export interface DepositAddress {
address: string
tag: string
coin: string
url: string
}
export interface WithdrawResponse {
id: string
}
export type DepositStatus = 0 | 1
export interface FuturesCancelAllOpenOrder {
code: number
msg: string
}
export interface OrderBook {
symbol: string
lastUpdateId: number
asks: Bid[]
bids: Bid[]
}
export interface Bid {
price: string
quantity: string
}
export interface BookTicker {
symbol: string
bidPrice: string
bidQty: string
askPrice: string
askQty: string
}
export interface DailyStats {
symbol: string
priceChange: string
priceChangePercent: string
weightedAvgPrice: string
prevClosePrice: string
lastPrice: string
lastQty: string
bidPrice: string
bidQty: string
askPrice: string
askQty: string
openPrice: string
highPrice: string
lowPrice: string
volume: string
quoteVolume: string
openTime: number
closeTime: number
firstId: number // First tradeId
lastId: number // Last tradeId
count: number // Trade count
}
export interface Ticker {
eventType: string
eventTime: number
symbol: string
priceChange: string
priceChangePercent: string
weightedAvg: string
prevDayClose: string
curDayClose: string
closeTradeQuantity: string
bestBid: string
bestBidQnt: string
bestAsk: string
bestAskQnt: string
open: string
high: string
low: string
volume: string
volumeQuote: string
openTime: number
closeTime: number
firstTradeId: number
lastTradeId: number
totalTrades: number
}
// export {
// Interval as interval,
// string as symbol,
// Callback as callback,
// IConstructorArgs
// }
export type TradingType = 'MARGIN' | 'SPOT'
export interface Account {
accountType: TradingType
balances: AssetBalance[]
buyerCommission: number
canDeposit: boolean
canTrade: boolean
canWithdraw: boolean
makerCommission: number
permissions: TradingType[]
sellerCommission: number
takerCommission: number
updateTime: number
}
export interface AssetBalance {
asset: string
free: string
locked: string
}
export interface FuturesAccountInfo {
feeTier: number
canTrade: boolean
canDeposit: boolean
canWithdraw: boolean
updateTime: number
totalInitialMargin: string
totalMaintMargin: string
totalWalletBalance: string
totalUnrealizedProfit: string
totalMarginBalance: string
totalPositionInitialMargin: string
totalOpenOrderInitialMargin: string
totalCrossWalletBalance: string
totalCrossUnPnl: string
availableBalance: string
maxWithdrawAmount: string
assets: FuturesAsset[]
positions: FuturesAccountPosition[]
}
export interface FuturesAccountPosition {
symbol: string
initialMargin: string
maintMargin: string
unrealizedProfit: string
positionInitialMargin: string
openOrderInitialMargin: string
leverage: string
isolated: boolean
entryPrice: string
maxNotional: string
positionSide: PositionSide
positionAmt: string
notional: string
isolatedWallet: string
updateTime: number
bidNotional: string
askNotional: string
}
export type FuturesAssetType =
| 'DOT'
| 'BTC'
| 'SOL'
| 'BNB'
| 'ETH'
| 'ADA'
| 'USDT'
| 'XRP'
| 'BUSD'
export type FuturesAsset = {
asset: FuturesAssetType
walletBalance: string
unrealizedProfit: string
marginBalance: string
maintMargin: string
initialMargin: string
positionInitialMargin: string
openOrderInitialMargin: string
maxWithdrawAmount: string
crossWalletBalance: string
crossUnPnl: string
availableBalance: string
marginAvailable: boolean
updateTime: number
}
export interface FuturesBalance {
accountAlias: string
asset: string
balance: string
crossWalletBalance: string
crossUnPnl: string
availableBalance: string
maxWithdrawAmount: string
}
export interface QueryOrder {
clientOrderId: string
cummulativeQuoteQty: string
executedQty: string
icebergQty: string
isWorking: boolean
orderId: number
orderListId: number
origQty: string
origQuoteOrderQty: string
price: string
side: OrderSide
status: OrderStatus
stopPrice: string
symbol: string
time: number
timeInForce: TimeInForce
type: OrderType
updateTime: number
}
export interface PremiumIndex {
symbol: string
markPrice: string
indexPrice: string
lastFundingRate: string
nextFundingTime: number
estimatedSettlePrice: string
time: number
}
export interface OpenInterest {
openInterest: string
symbol: string
time: number
}
export interface SymbolConfig {
symbol: string
marginType: string
isAutoAddMargin: boolean
leverage: number
maxNotionalValue: string
}