-
Notifications
You must be signed in to change notification settings - Fork 497
/
index.d.ts
2358 lines (2136 loc) · 58.9 KB
/
index.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
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
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// tslint:disable:interface-name
declare module 'binance-api-node' {
export default function(options?: {
apiKey?: string
apiSecret?: string
getTime?: () => number | Promise<number>
httpBase?: string
httpFutures?: string
wsBase?: string
wsFutures?: string
proxy?: string
}): Binance
export type ErrorCodes_LT =
| -1000
| -1001
| -1002
| -1003
| -1006
| -1007
| -1013
| -1014
| -1015
| -1016
| -1020
| -1021
| -1022
| -1100
| -1101
| -1102
| -1103
| -1104
| -1105
| -1106
| -1112
| -1114
| -1115
| -1116
| -1117
| -1118
| -1119
| -1120
| -1121
| -1125
| -1127
| -1128
| -1130
| -2008
| -2009
| -2010
| -2012
| -2013
| -2014
| -2015
export const enum ErrorCodes {
UNKNOWN = -1000,
DISCONNECTED = -1001,
UNAUTHORIZED = -1002,
TOO_MANY_REQUESTS = -1003,
UNEXPECTED_RESP = -1006,
TIMEOUT = -1007,
INVALID_MESSAGE = -1013,
UNKNOWN_ORDER_COMPOSITION = -1014,
TOO_MANY_ORDERS = -1015,
SERVICE_SHUTTING_DOWN = -1016,
UNSUPPORTED_OPERATION = -1020,
INVALID_TIMESTAMP = -1021,
INVALID_SIGNATURE = -1022,
ILLEGAL_CHARS = -1100,
TOO_MANY_PARAMETERS = -1101,
MANDATORY_PARAM_EMPTY_OR_MALFORMED = -1102,
UNKNOWN_PARAM = -1103,
UNREAD_PARAMETERS = -1104,
PARAM_EMPTY = -1105,
PARAM_NOT_REQUIRED = -1106,
NO_DEPTH = -1112,
TIF_NOT_REQUIRED = -1114,
INVALID_TIF = -1115,
INVALID_ORDER_TYPE = -1116,
INVALID_SIDE = -1117,
EMPTY_NEW_CL_ORD_ID = -1118,
EMPTY_ORG_CL_ORD_ID = -1119,
BAD_INTERVAL = -1120,
BAD_SYMBOL = -1121,
INVALID_LISTEN_KEY = -1125,
MORE_THAN_XX_HOURS = -1127,
OPTIONAL_PARAMS_BAD_COMBO = -1128,
INVALID_PARAMETER = -1130,
BAD_API_ID = -2008,
DUPLICATE_API_KEY_DESC = -2009,
INSUFFICIENT_BALANCE = -2010,
CANCEL_ALL_FAIL = -2012,
NO_SUCH_ORDER = -2013,
BAD_API_KEY_FMT = -2014,
REJECTED_MBX_KEY = -2015,
}
export enum HttpMethod {
GET = 'GET',
HEAD = 'HEAD',
POST = 'POST',
PUT = 'PUT',
DELETE = 'DELETE',
CONNECT = 'CONNECT',
OPTIONS = 'OPTIONS',
TRACE = 'TRACE',
PATCH = 'PATCH',
}
export interface Account {
accountType: TradingType.MARGIN | TradingType.SPOT
balances: AssetBalance[]
buyerCommission: number
canDeposit: boolean
canTrade: boolean
canWithdraw: boolean
makerCommission: number
permissions: TradingType_LT[]
sellerCommission: number
takerCommission: number
updateTime: number
}
export interface TradeFee {
symbol: string
makerCommission: number
takerCommission: number
}
export interface AggregatedTrade {
aggId: number
symbol: string
price: string
quantity: string
firstId: number
lastId: number
timestamp: number
isBuyerMaker: boolean
wasBestPrice: boolean
}
export interface AssetBalance {
asset: string
free: string
locked: string
}
export type booleanString = 'true' | 'false'
export interface positionAmount {
amount: string
amountInBTC: string
amountInUSDT: string
asset: string
}
export interface MultiAssetsMargin {
multiAssetsMargin: boolean
}
export interface LendingAccount {
positionAmountVos: positionAmount[]
totalAmountInBTC: string
totalAmountInUSDT: string
totalFixedAmountInBTC: string
totalFixedAmountInUSDT: string
totalFlexibleInBTC: string
totalFlexibleInUSDT: string
}
export interface FundingWallet {
asset: string
free: string // available balance
locked: string // locked asset
freeze: string // freeze asset
withdrawing: string
btcValuation: string
}
export interface NetworkInformation {
addressRegex: string
coin: string
depositDesc: string
depositEnable: boolean
isDefault: boolean
memoRegex: string
minConfirm: number
name: string
network: string
resetAddressStatus: boolean
specialTips: string
unLockConfirm: number
withdrawDesc: string
withdrawEnable: boolean
withdrawFee: number
withdrawIntegerMultiple: number
withdrawMax: number
withdrawMin: number
sameAddress: string
}
export interface CoinInformation {
coin: string
depositAllEnable: boolean
free: number
freeze: number
ipoable: number
ipoing: number
isLegalMoney: boolean
locked: number
name: string
networkList: NetworkInformation[]
}
export interface DepositAddress {
address: string
tag: string
coin: string
url: string
}
export interface WithdrawResponse {
id: string
}
export type DepositStatus_LT = 0 | 1
export const enum DepositStatus {
PENDING = 0,
SUCCESS = 1,
}
export interface UserAssetDribbletDetails {
transId: number
serviceChargeAmount: string
amount: string
operateTime: number
transferedAmount: string
fromAsset: string
}
export interface UserAssetDribblets {
operateTime: number
totalTransferedAmount: string
totalServiceChargeAmount: string
transId: number
userAssetDribbletDetails: UserAssetDribbletDetails[]
}
export interface DustLog {
total: number
userAssetDribblets: UserAssetDribblets[]
}
export interface DustTransferResult {
amount: string;
fromAsset: string;
operateTime: number;
serviceChargeAmount: string;
tranId: number;
transferedAmount: string;
}
export interface DustTransfer {
totalServiceCharge: string
totalTransfered: string
transferResult: DustTransferResult[]
}
export interface DepositHistoryResponse {
[index: number]: {
insertTime: number
amount: string
coin: string
network: string
address: string
txId: string
status: DepositStatus_LT
addressTag?: string
transferType?: number
confirmTimes?: string
}
}
export type WithdrawStatus_LT = 0 | 1 | 2 | 3 | 4 | 5 | 6
export const enum WithdrawStatus {
EMAIL_SENT = 0,
CANCELLED = 1,
AWAITING_APPROVAL = 2,
REJECTED = 3,
PROCESSING = 4,
FAILURE = 5,
COMPLETED = 6,
}
export interface WithdrawHistoryResponse {
[index: number]: {
id: string
amount: string
transactionFee: string
address: string
coin: string
txId: string
applyTime: number
status: WithdrawStatus_LT
network: string
transferType?: number
withdrawOrderId?: string
}
}
export interface AssetDetail {
[asset: string]: {
minWithdrawAmount: string
depositStatus: boolean
withdrawFee: string
withdrawStatus: boolean
depositTip?: string
}
}
export interface BNBBurn {
spotBNBBurn: boolean
interestBNBBurn: boolean
}
export interface SetBNBBurnOptions {
spotBNBBurn?: boolean | booleanString
interestBNBBurn?: boolean | booleanString
recvWindow?: number
}
export interface AccountSnapshot {
code: number
msg: string
snapshotVos: {
data: {
balances: {
asset: string
free: number
locked: number
}[]
totalAssetOfBtc: number
}
type: string
updateTime: number
}[]
}
export type GetOrderOptions =
| { symbol: string; orderId: number; useServerTime?: boolean }
| { symbol: string; origClientOrderId: string; useServerTime?: boolean }
export type CancelOrderOptions =
| { symbol: string; orderId: number; useServerTime?: boolean; newClientOrderId?: string }
| {
symbol: string
origClientOrderId: string
useServerTime?: boolean
newClientOrderId?: string
}
export type GetOrderOcoOptions =
| { orderListId: number; useServerTime?: boolean }
| { listClientOrderId: string; useServerTime?: boolean }
export type CancelOrderOcoOptions =
| { symbol: string; orderListId: number; useServerTime?: boolean; newClientOrderId?: string }
| {
symbol: string
listClientOrderId: string
useServerTime?: boolean
newClientOrderId?: string
}
export type cancelOpenOrdersOptions = {
symbol: string
useServerTime?: boolean
}
export interface GetInfo {
spot: GetInfoDetails
futures: GetInfoDetails
}
export type GetInfoDetails = {
usedWeight1m?: string
orderCount10s?: string
orderCount1m?: string
orderCount1h?: string
orderCount1d?: string
responseTime?: string
}
export type TransferType_LT =
| 'MAIN_C2C'
| 'MAIN_UMFUTURE'
| 'MAIN_CMFUTURE'
| 'MAIN_MARGIN'
| 'MAIN_MINING'
| 'C2C_MAIN'
| 'C2C_UMFUTURE'
| 'C2C_MINING'
| 'UMFUTURE_MAIN'
| 'UMFUTURE_C2C'
| 'UMFUTURE_MARGIN'
| 'CMFUTURE_MAIN'
| 'MARGIN_MAIN'
| 'MARGIN_UMFUTURE'
| 'MINING_MAIN'
| 'MINING_UMFUTURE'
| 'MINING_C2C'
export const enum TransferType {
MAIN_C2C = 'MAIN_C2C',
MAIN_UMFUTURE = 'MAIN_UMFUTURE',
MAIN_CMFUTURE = 'MAIN_CMFUTURE',
MAIN_MARGIN = 'MAIN_MARGIN',
MAIN_MINING = 'MAIN_MINING',
C2C_MAIN = 'C2C_MAIN',
C2C_UMFUTURE = 'C2C_UMFUTURE',
C2C_MINING = 'C2C_MINING',
UMFUTURE_MAIN = 'UMFUTURE_MAIN',
UMFUTURE_C2C = 'UMFUTURE_C2C',
UMFUTURE_MARGIN = 'UMFUTURE_MARGIN',
CMFUTURE_MAIN = 'CMFUTURE_MAIN',
MARGIN_MAIN = 'MARGIN_MAIN',
MARGIN_UMFUTURE = 'MARGIN_UMFUTURE',
MINING_MAIN = 'MINING_MAIN',
MINING_UMFUTURE = 'MINING_UMFUTURE',
MINING_C2C = 'MINING_C2C',
}
export interface UniversalTransfer {
type: TransferType_LT
asset: string
amount: string
recvWindow?: number
}
export interface UniversalTransferHistory {
type: TransferType_LT
startTime?: number
endTime?: number
current?: number
size?: number
recvWindow?: number
}
export interface UniversalTransferHistoryResponse {
total: string
rows: {
asset: string
amount: string
type: TransferType_LT
status: string
tranId: number
timestamp: number
}[]
}
export interface MarginBorrowParent {
asset: string
isIsolated?: 'TRUE' | 'FALSE'
amount: string
recvWindow?: number
}
export interface MarginBorrowCross extends MarginBorrowParent {
isIsolated?: 'FALSE'
}
export interface MarginBorrowIsolated extends MarginBorrowParent {
isIsolated: 'TRUE'
symbol: string
}
export type MarginBorrowOptions = MarginBorrowCross | MarginBorrowIsolated
export type MarginType_LT = 'ISOLATED' | 'CROSSED'
export const enum MarginType {
ISOLATED = 'ISOLATED',
CROSSED = 'CROSSED',
}
export interface ApiPermission {
ipRestrict: boolean
createTime: number
enableWithdrawals: boolean
enableInternalTransfer: boolean
permitsUniversalTransfer: boolean
enableVanillaOptions: boolean
enableReading: boolean
enableFutures: boolean
enableMargin: boolean
enableSpotAndMarginTrading: boolean
tradingAuthorityExpirationTime: number
}
export interface Binance {
getInfo(): GetInfo
accountInfo(options?: { useServerTime: boolean }): Promise<Account>
tradeFee(options?: { useServerTime: boolean }): Promise<TradeFee[]>
aggTrades(options?: {
symbol: string
fromId?: string
startTime?: number
endTime?: number
limit?: number
}): Promise<AggregatedTrade[]>
allBookTickers(): Promise<{ [key: string]: Ticker }>
book(options: { symbol: string; limit?: number }): Promise<OrderBook>
exchangeInfo(options?: { symbol: string }): Promise<ExchangeInfo>
lendingAccount(options?: { useServerTime: boolean }): Promise<LendingAccount>
fundingWallet(options?: {
asset?: string
needBtcValuation?: booleanString
useServerTime?: boolean
}): Promise<FundingWallet[]>
apiPermission(options?: { recvWindow?: number }): Promise<ApiPermission>
order(options: NewOrderSpot): Promise<Order>
orderTest(options: NewOrderSpot): Promise<Order>
orderOco(options: NewOcoOrder): Promise<OcoOrder>
ping(): Promise<boolean>
prices(options?: { symbol?: string }): Promise<{ [index: string]: string }>
avgPrice(options?: { symbol: string }): Promise<AvgPriceResult | AvgPriceResult[]>
time(): Promise<number>
trades(options: { symbol: string; limit?: number }): Promise<TradeResult[]>
ws: WebSocket
myTrades(options: {
symbol: string
orderId?: number
startTime?: number
endTime?: number
fromId?: number
limit?: number
recvWindow?: number
useServerTime?: boolean
}): Promise<MyTrade[]>
getOrder(options: GetOrderOptions): Promise<QueryOrderResult>
getOrderOco(options: GetOrderOcoOptions): Promise<QueryOrderOcoResult>
cancelOrder(options: CancelOrderOptions): Promise<CancelOrderResult>
cancelOrderOco(options: CancelOrderOcoOptions): Promise<CancelOrderOcoResult>
cancelOpenOrders(options: cancelOpenOrdersOptions): Promise<CancelOrderResult[]>
openOrders(options: {
symbol?: string
recvWindow?: number
useServerTime?: boolean
}): Promise<QueryOrderResult[]>
allOrders(options: {
symbol?: string
orderId?: number
startTime?: number
endTime?: number
limit?: number
recvWindow?: number
timestamp?: number
useServerTime?: boolean
}): Promise<QueryOrderResult[]>
allOrdersOCO(options: {
timestamp: number
fromId?: number
startTime?: number
endTime?: number
limit?: number
recvWindow: number
}): Promise<QueryOrderResult[]>
dailyStats(options?: { symbol: string }): Promise<DailyStatsResult | DailyStatsResult[]>
candles(options: CandlesOptions): Promise<CandleChartResult[]>
tradesHistory(options: {
symbol: string
limit?: number
fromId?: number
}): Promise<TradeResult[]>
capitalConfigs(options?: { recvWindow?: number }): Promise<CoinInformation[]>
depositAddress(options: {
coin: string
network?: string
recvWindow?: number
}): Promise<DepositAddress>
withdraw(options: {
coin: string
network?: string
address: string
amount: number
name?: string
transactionFeeFlag?: boolean
}): Promise<WithdrawResponse>
assetDetail(): Promise<AssetDetail>
getBnbBurn(): Promise<BNBBurn>
setBnbBurn(opts: SetBNBBurnOptions): Promise<BNBBurn>
accountSnapshot(options: {
type: string
startTime?: number
endTime?: number
limit?: number
}): Promise<AccountSnapshot>
withdrawHistory(options: {
coin: string
status?: number
startTime?: number
endTime?: number
offset?: number
limit?: number
}): Promise<WithdrawHistoryResponse>
depositHistory(options: {
coin?: string
status?: number
startTime?: number
endTime?: number
offset?: number
limit?: number
recvWindow?: number
}): Promise<DepositHistoryResponse>
dustLog(options: {
startTime?: number
endTime?: number
recvWindow?: number
timestamp: number
}): DustLog
dustTransfer(options: {
asset: string[],
recvWindow?: number,
})
universalTransfer(options: UniversalTransfer): Promise<{ tranId: number }>
universalTransferHistory(
options: UniversalTransferHistory,
): Promise<UniversalTransferHistoryResponse>
futuresPing(): Promise<boolean>
futuresTime(): Promise<number>
futuresExchangeInfo(): Promise<ExchangeInfo<FuturesOrderType_LT>>
futuresBook(options: { symbol: string; limit?: number }): Promise<OrderBook>
futuresCandles(options: CandlesOptions): Promise<CandleChartResult[]>
futuresMarkPriceCandles(options: CandlesOptions): Promise<CandleChartResult[]>
futuresIndexPriceCandles(options: IndexPriceCandlesOptions): Promise<CandleChartResult[]>
futuresAggTrades(options?: {
symbol: string
fromId?: string
startTime?: number
endTime?: number
limit?: number
}): Promise<AggregatedTrade[]>
futuresTrades(options: { symbol: string; limit?: number }): Promise<TradeResult[]>
futuresUserTrades(options: {
symbol?: string
startTime?: number
endTime?: number
fromId?: number
limit?: number
}): Promise<FuturesUserTradeResult[]>
futuresDailyStats(options?: { symbol: string }): Promise<DailyStatsResult | DailyStatsResult[]>
futuresPrices(options?: { symbol: string }): Promise<{ [index: string]: string }>
futuresAllBookTickers(): Promise<{ [key: string]: Ticker }>
futuresMarkPrice(): Promise<MarkPriceResult[]>
futuresAllForceOrders(options?: {
symbol?: string
startTime?: number
endTime?: number
limit?: number
}): Promise<AllForceOrdersResult[]>
futuresFundingRate(options: {
symbol: string
startTime?: number
endTime?: number
limit?: number
}): Promise<FundingRateResult[]>
futuresOrder(options: NewFuturesOrder): Promise<FuturesOrder>
futuresBatchOrders(options: {
batchOrders: NewFuturesOrder[]
recvWindow?: number
timestamp?: number
}): Promise<FuturesOrder[]>
getMultiAssetsMargin(): Promise<MultiAssetsMargin>
setMultiAssetsMargin(options: MultiAssetsMargin): Promise<MultiAssetsMargin>
futuresCancelOrder(options: {
symbol: string
orderId: number
useServerTime?: boolean
}): Promise<CancelOrderResult>
futuresCancelAllOpenOrders(options: {
symbol: string
}): Promise<FuturesCancelAllOpenOrdersResult>
futuresCancelBatchOrders(options: {
symbol: string
orderIdList?: string
origClientOrderIdList?: string
recvWindow?: number
timestamp?: number
})
futuresGetOrder(options: {
symbol: string
orderId?: number
origClientOrderId?: string
recvWindow?: number
timestamp?: number
}): Promise<QueryFuturesOrderResult>
futuresOpenOrders(options: {
symbol?: string
useServerTime?: boolean
}): Promise<QueryFuturesOrderResult[]>
futuresAllOrders(options: {
symbol: string
orderId?: number
startTime?: number
endTime?: number
limit?: number
recvWindow?: number
}): Promise<QueryFuturesOrderResult>
futuresPositionRisk(options?: {
symbol?: string
recvWindow?: number
}): Promise<PositionRiskResult[]>
futuresLeverageBracket(options?: {
symbol?: string
recvWindow: number
}): Promise<LeverageBracketResult[]>
futuresAccountBalance(options?: { recvWindow: number }): Promise<FuturesBalanceResult[]>
futuresAccountInfo(options?: { recvWindow: number }): Promise<FuturesAccountInfoResult>
futuresPositionMode(options?: { recvWindow: number }): Promise<PositionModeResult>
futuresPositionModeChange(options: {
dualSidePosition: string
recvWindow: number
}): Promise<ChangePositionModeResult>
futuresLeverage(options: {
symbol: string
leverage: number
recvWindow?: number
}): Promise<FuturesLeverageResult>
futuresMarginType(options: {
symbol: string
marginType: MarginType_LT
recvWindow?: number
}): Promise<FuturesMarginTypeResult>
futuresIncome(options: {
symbol?: string
incomeType?: FuturesIncomeType_LT
startTime?: number
endTime?: number
limit?: number
recvWindow?: number
}): Promise<FuturesIncomeResult[]>
marginOrder(options: NewOrderMargin): Promise<Order>
marginOrderOco(options: NewOcoOrderMargin): Promise<MarginOcoOrder>
marginGetOrder(options: {
symbol: string
isIsolated?: string | boolean
orderId?: string
origClientOrderId?: string
recvWindow?: number
}): Promise<Order>
marginAllOrders(options: {
symbol: string
useServerTime?: boolean
}): Promise<QueryOrderResult[]>
marginCancelOrder(options: {
symbol: string
orderId?: number
useServerTime?: boolean
}): Promise<CancelOrderResult>
marginOpenOrders(options: {
symbol?: string
useServerTime?: boolean
}): Promise<QueryOrderResult[]>
marginRepay(options: MarginBorrowOptions): Promise<{ tranId: number }>
marginLoan(options: MarginBorrowOptions): Promise<{ tranId: number }>
marginAccountInfo(options?: { recvWindow?: number }): Promise<IsolatedCrossAccount>
marginIsolatedAccount(options?: {
symbols?: string
recvWindow?: number
}): Promise<IsolatedMarginAccount>
marginMaxBorrow(options: {
asset: string
isolatedSymbol?: string
recvWindow?: number
}): Promise<{ amount: string; borrowLimit: string }>
marginCreateIsolated(options: {
base: string
quote: string
recvWindow?: number
}): Promise<{ success: boolean; symbol: string }>
marginIsolatedTransfer(options: marginIsolatedTransfer): Promise<{ tranId: string }>
marginIsolatedTransferHistory(
options: marginIsolatedTransferHistory,
): Promise<marginIsolatedTransferHistoryResponse>
marginMyTrades(options: {
symbol: string
isIsolated?: string | boolean
startTime?: number
endTime?: number
limit?: number
fromId?: number
}): Promise<MyTrade[]>
publicRequest(method: HttpMethod, url: string, payload: object): Promise<unknown>
privateRequest(method: HttpMethod, url: string, payload: object): Promise<unknown>
disableMarginAccount(options: { symbol: string }): Promise<{ success: boolean; symbol: string }>
enableMarginAccount(options: { symbol: string }): Promise<{ success: boolean; symbol: string }>
getPortfolioMarginAccountInfo(): Promise<{
uniMMR: string
accountEquity: string
accountMaintMargin: string
accountStatus: string
}>
}
export interface HttpError extends Error {
code: number
url: string
}
export type MarkPrice = {
eventType: string
eventTime: number
symbol: string
markPrice: string
indexPrice: string
settlePrice: string
fundingRate: string
nextFundingRate: number
}
export type UserDataStreamEvent =
| OutboundAccountInfo
| ListStatus
| ExecutionReport
| BalanceUpdate
| OutboundAccountPosition
| MarginCall
export interface WebSocket {
customSubStream: (
pair: string | string[],
callback: (data: any) => void,
) => ReconnectingWebSocketHandler
futuresAllMarkPrices: (
payload: { updateSpeed: '1s' | '3s' },
callback: (data: MarkPrice[]) => void,
) => ReconnectingWebSocketHandler
futuresCustomSubStream: (
pair: string | string[],
callback: (data: any) => void,
) => ReconnectingWebSocketHandler
depth: (
pair: string | string[],
callback: (depth: Depth) => void,
transform?: boolean,
) => ReconnectingWebSocketHandler
futuresDepth: (
pair: string | string[],
callback: (depth: Depth) => void,
transform?: boolean,
) => ReconnectingWebSocketHandler
partialDepth: (
options: { symbol: string; level: number } | { symbol: string; level: number }[],
callback: (depth: PartialDepth) => void,
transform?: boolean,
) => ReconnectingWebSocketHandler
futuresPartialDepth: (
options: { symbol: string; level: number } | { symbol: string; level: number }[],
callback: (depth: PartialDepth) => void,
transform?: boolean,
) => ReconnectingWebSocketHandler
ticker: (
pair: string | string[],
callback: (ticker: Ticker) => void,
) => ReconnectingWebSocketHandler
miniTicker: (
pair: string | string[],
callback: (ticker: MiniTicker) => void,
) => ReconnectingWebSocketHandler
allMiniTickers: (callback: (ticker: MiniTicker[]) => void) => ReconnectingWebSocketHandler
futuresTicker: (
pair: string | string[],
callback: (ticker: Ticker) => void,
) => ReconnectingWebSocketHandler
allTickers: (callback: (tickers: Ticker[]) => void) => ReconnectingWebSocketHandler
futuresAllTickers: (callback: (tickers: Ticker[]) => void) => ReconnectingWebSocketHandler
candles: (
pair: string | string[],
period: string,
callback: (ticker: Candle) => void,
) => ReconnectingWebSocketHandler
trades: (
pairs: string | string[],
callback: (trade: WSTrade) => void,
) => ReconnectingWebSocketHandler
aggTrades: (
pairs: string | string[],
callback: (trade: AggregatedTrade) => void,
) => ReconnectingWebSocketHandler
futuresLiquidations: (
symbol: string | string[],
callback: (forecOrder: ForceOrder) => void,
) => ReconnectingWebSocketHandler
futuresAllLiquidations: (
callback: (forecOrder: ForceOrder) => void,
) => ReconnectingWebSocketHandler
futuresAggTrades: (
pairs: string | string[],
callback: (trade: AggregatedTrade) => void,
) => ReconnectingWebSocketHandler
futuresCandles: (
pair: string | string[],
period: string,
callback: (ticker: Candle) => void,
) => ReconnectingWebSocketHandler
user: (callback: (msg: UserDataStreamEvent) => void) => Promise<ReconnectingWebSocketHandler>
marginUser: (
callback: (msg: OutboundAccountInfo | ExecutionReport) => void,
) => Promise<ReconnectingWebSocketHandler>
futuresUser: (
callback: (
msg:
| OutboundAccountInfo
| ExecutionReport
| AccountUpdate
| OrderUpdate
| AccountConfigUpdate
| MarginCall,
) => void,
) => Promise<ReconnectingWebSocketHandler>
}
export type WebSocketCloseOptions = {
delay: number
fastClose: boolean
keepClosed: boolean
}
export type ReconnectingWebSocketHandler = (options?: WebSocketCloseOptions) => void
export type CandleChartInterval_LT =
| '1m'
| '3m'
| '5m'
| '15m'
| '30m'
| '1h'
| '2h'
| '4h'
| '6h'
| '8h'
| '12h'
| '1d'
| '3d'
| '1w'
| '1M'
export const enum CandleChartInterval {
ONE_MINUTE = '1m',
THREE_MINUTES = '3m',
FIVE_MINUTES = '5m',
FIFTEEN_MINUTES = '15m',
THIRTY_MINUTES = '30m',
ONE_HOUR = '1h',
TWO_HOURS = '2h',
FOUR_HOURS = '4h',
SIX_HOURS = '6h',
EIGHT_HOURS = '8h',
TWELVE_HOURS = '12h',
ONE_DAY = '1d',
THREE_DAYS = '3d',
ONE_WEEK = '1w',
ONE_MONTH = '1M',
}
export type RateLimitType_LT = 'REQUEST_WEIGHT' | 'ORDERS'
export const enum RateLimitType {
REQUEST_WEIGHT = 'REQUEST_WEIGHT',
ORDERS = 'ORDERS',
}
export type TradingType_LT = 'MARGIN' | 'SPOT'
export const enum TradingType {
MARGIN = 'MARGIN',
SPOT = 'SPOT',
}
export type RateLimitInterval_LT = 'SECOND' | 'MINUTE' | 'DAY'
export const enum RateLimitInterval {
SECOND = 'SECOND',
MINUTE = 'MINUTE',
DAY = 'DAY',
}
export interface ExchangeInfoRateLimit {
rateLimitType: RateLimitType_LT
interval: RateLimitInterval_LT
intervalNum: number
limit: number
}
export type ExchangeFilterType_LT = 'EXCHANGE_MAX_NUM_ORDERS' | 'EXCHANGE_MAX_ALGO_ORDERS'
export const enum ExchangeFilterType {