@yuants/vendor-okx 0.16.8 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/dist/account.js +198 -0
  2. package/dist/account.js.map +1 -0
  3. package/dist/api.js +463 -0
  4. package/dist/api.js.map +1 -0
  5. package/dist/cli.js +3 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/cluster.js +80 -0
  8. package/dist/cluster.js.map +1 -0
  9. package/dist/extension.js +89 -0
  10. package/dist/extension.js.map +1 -0
  11. package/dist/index.js +7 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/interest_rate.js +133 -0
  14. package/dist/interest_rate.js.map +1 -0
  15. package/dist/legacy_index.js +554 -0
  16. package/dist/legacy_index.js.map +1 -0
  17. package/dist/logger.js +91 -0
  18. package/dist/logger.js.map +1 -0
  19. package/dist/ohlc.js +98 -0
  20. package/dist/ohlc.js.map +1 -0
  21. package/dist/order.js +96 -0
  22. package/dist/order.js.map +1 -0
  23. package/dist/product.js +85 -0
  24. package/dist/product.js.map +1 -0
  25. package/dist/quote.js +58 -0
  26. package/dist/quote.js.map +1 -0
  27. package/dist/vendor-okx.d.ts +1 -0
  28. package/lib/account.d.ts +102 -0
  29. package/lib/account.d.ts.map +1 -0
  30. package/lib/account.js +201 -0
  31. package/lib/account.js.map +1 -0
  32. package/lib/api.d.ts +1401 -0
  33. package/lib/api.d.ts.map +1 -0
  34. package/lib/api.js +470 -0
  35. package/lib/api.js.map +1 -0
  36. package/lib/cli.d.ts +3 -0
  37. package/lib/cli.d.ts.map +1 -0
  38. package/lib/cli.js +5 -0
  39. package/lib/cli.js.map +1 -0
  40. package/lib/cluster.d.ts +2 -0
  41. package/lib/cluster.d.ts.map +1 -0
  42. package/lib/cluster.js +108 -0
  43. package/lib/cluster.js.map +1 -0
  44. package/lib/extension.d.ts +4 -0
  45. package/lib/extension.d.ts.map +1 -0
  46. package/lib/extension.js +91 -0
  47. package/lib/extension.js.map +1 -0
  48. package/lib/index.d.ts +7 -0
  49. package/lib/index.d.ts.map +1 -0
  50. package/lib/index.js +9 -0
  51. package/lib/index.js.map +1 -0
  52. package/lib/interest_rate.d.ts +2 -0
  53. package/lib/interest_rate.d.ts.map +1 -0
  54. package/lib/interest_rate.js +135 -0
  55. package/lib/interest_rate.js.map +1 -0
  56. package/lib/legacy_index.d.ts +2 -0
  57. package/lib/legacy_index.d.ts.map +1 -0
  58. package/lib/legacy_index.js +556 -0
  59. package/lib/legacy_index.js.map +1 -0
  60. package/lib/logger.d.ts +21 -0
  61. package/lib/logger.d.ts.map +1 -0
  62. package/lib/logger.js +98 -0
  63. package/lib/logger.js.map +1 -0
  64. package/lib/ohlc.d.ts +2 -0
  65. package/lib/ohlc.d.ts.map +1 -0
  66. package/lib/ohlc.js +100 -0
  67. package/lib/ohlc.js.map +1 -0
  68. package/lib/order.d.ts +4 -0
  69. package/lib/order.d.ts.map +1 -0
  70. package/lib/order.js +99 -0
  71. package/lib/order.js.map +1 -0
  72. package/lib/product.d.ts +6 -0
  73. package/lib/product.d.ts.map +1 -0
  74. package/lib/product.js +88 -0
  75. package/lib/product.js.map +1 -0
  76. package/lib/quote.d.ts +42 -0
  77. package/lib/quote.d.ts.map +1 -0
  78. package/lib/quote.js +61 -0
  79. package/lib/quote.js.map +1 -0
  80. package/package.json +5 -2
  81. package/temp/image-tag +1 -0
  82. package/temp/package-deps.json +41 -0
  83. package/temp/vendor-okx.api.json +177 -0
  84. package/temp/vendor-okx.api.md +9 -0
package/lib/api.d.ts ADDED
@@ -0,0 +1,1401 @@
1
+ /**
2
+ * API v5: https://www.okx.com/docs-v5/#overview
3
+ */
4
+ export declare class OkxClient {
5
+ config: {
6
+ auth: {
7
+ public_key: string;
8
+ secret_key: string;
9
+ passphrase: string;
10
+ };
11
+ };
12
+ noAuth: boolean;
13
+ constructor(config: {
14
+ auth: {
15
+ public_key: string;
16
+ secret_key: string;
17
+ passphrase: string;
18
+ };
19
+ });
20
+ request(method: string, path: string, params?: any): Promise<any>;
21
+ /**
22
+ * 获取所有产品行情信息
23
+ *
24
+ * 获取产品行情信息
25
+ *
26
+ * 限速:20次/2s
27
+ * 限速规则:IP
28
+ *
29
+ * https://www.okx.com/docs-v5/zh/#order-book-trading-market-data-get-tickers
30
+ */
31
+ getMarketTickers: (params: {
32
+ instType: string;
33
+ uly?: string;
34
+ instFamily?: string;
35
+ }) => Promise<{
36
+ code: string;
37
+ msg: string;
38
+ data: Array<{
39
+ instType: string;
40
+ instId: string;
41
+ last: string;
42
+ lastSz: string;
43
+ askPx: string;
44
+ askSz: string;
45
+ bidPx: string;
46
+ bidSz: string;
47
+ open24h: string;
48
+ high24h: string;
49
+ low24h: string;
50
+ volCcy24h: string;
51
+ vol24h: string;
52
+ sodUtc0: string;
53
+ sodUtc8: string;
54
+ ts: string;
55
+ }>;
56
+ }>;
57
+ /**
58
+ * 获取账户资产估值
59
+ *
60
+ * 查看账户资产估值
61
+ *
62
+ * 限速:1次/s
63
+ * 限速规则:UserID
64
+ *
65
+ * https://www.okx.com/docs-v5/zh/#funding-account-rest-api-get-account-asset-valuation
66
+ */
67
+ getAssetValuation: (params?: {
68
+ ccy?: string;
69
+ }) => Promise<{
70
+ code: string;
71
+ msg: string;
72
+ data: Array<{
73
+ details: {
74
+ classic: string;
75
+ earn: string;
76
+ funding: string;
77
+ trading: string;
78
+ };
79
+ totalBal: string;
80
+ ts: string;
81
+ }>;
82
+ }>;
83
+ /**
84
+ * 获取持仓总量
85
+ *
86
+ * 查询单个交易产品的市场的持仓总量
87
+ *
88
+ * 限速:20次/2s
89
+ * 限速规则:IP + instrumentID
90
+ *
91
+ * https://www.okx.com/docs-v5/zh/#public-data-rest-api-get-open-interest
92
+ */
93
+ getOpenInterest: (params: {
94
+ instType: string;
95
+ uly?: string;
96
+ instFamily?: string;
97
+ instId?: string;
98
+ }) => Promise<{
99
+ code: string;
100
+ msg: string;
101
+ data: {
102
+ instType: string;
103
+ instId: string;
104
+ oi: string;
105
+ oiCcy: string;
106
+ ts: string;
107
+ }[];
108
+ }>;
109
+ /**
110
+ * 查看账户配置
111
+ * 查看当前账户的配置信息。
112
+ *
113
+ * 限速:5次/2s
114
+ * 限速规则:UserID
115
+ *
116
+ * https://www.okx.com/docs-v5/zh/#trading-account-rest-api-get-account-configuration
117
+ */
118
+ getAccountConfig: () => Promise<{
119
+ code: string;
120
+ data: Array<{
121
+ acctLv: string;
122
+ autoLoan: boolean;
123
+ ctIsoMode: string;
124
+ greeksType: string;
125
+ level: string;
126
+ levelTmp: string;
127
+ mgnIsoMode: string;
128
+ posMode: string;
129
+ spotOffsetType: string;
130
+ uid: string;
131
+ label: string;
132
+ roleType: string;
133
+ traderInsts: any[];
134
+ spotRoleType: string;
135
+ spotTraderInsts: any[];
136
+ opAuth: string;
137
+ kycLv: string;
138
+ ip: string;
139
+ perm: string;
140
+ mainUid: string;
141
+ }>;
142
+ msg: string;
143
+ }>;
144
+ /**
145
+ * 获取市场借币杠杆利率和借币限额
146
+ *
147
+ * 限速:2次/2s
148
+ * 限速规则:IP
149
+ *
150
+ * https://www.okx.com/docs-v5/zh/#public-data-rest-api-get-interest-rate-and-loan-quota
151
+ */
152
+ getInterestRateLoanQuota: () => Promise<{
153
+ code: string;
154
+ data?: Array<{
155
+ basic: Array<{
156
+ ccy: string;
157
+ rate: string;
158
+ quota: string;
159
+ }>;
160
+ vip: Array<{
161
+ loanQuotaCoef: string;
162
+ level: string;
163
+ }>;
164
+ regular: Array<{
165
+ loanQuotaCoef: string;
166
+ level: string;
167
+ }>;
168
+ }>;
169
+ }>;
170
+ /**
171
+ * 获取交易产品基础信息
172
+ *
173
+ * 获取所有可交易产品的信息列表。
174
+ *
175
+ * 限速:20次/2s
176
+ * 限速规则:IP +instType
177
+ *
178
+ * https://www.okx.com/docs-v5/zh/#public-data-rest-api-get-instruments
179
+ */
180
+ getInstruments: (params: {
181
+ instType: string;
182
+ uly?: string;
183
+ instFamily?: string;
184
+ instId?: string;
185
+ }) => Promise<{
186
+ code: string;
187
+ msg: string;
188
+ data: Array<{
189
+ alias: string;
190
+ baseCcy: string;
191
+ category: string;
192
+ ctMult: string;
193
+ ctType: string;
194
+ ctVal: string;
195
+ ctValCcy: string;
196
+ expTime: string;
197
+ instFamily: string;
198
+ instId: string;
199
+ instType: string;
200
+ lever: string;
201
+ listTime: string;
202
+ lotSz: string;
203
+ maxIcebergSz: string;
204
+ maxLmtAmt: string;
205
+ maxLmtSz: string;
206
+ maxMktAmt: string;
207
+ maxMktSz: string;
208
+ maxStopSz: string;
209
+ maxTriggerSz: string;
210
+ maxTwapSz: string;
211
+ minSz: string;
212
+ optType: string;
213
+ quoteCcy: string;
214
+ settleCcy: string;
215
+ state: string;
216
+ stk: string;
217
+ tickSz: string;
218
+ uly: string;
219
+ }>;
220
+ }>;
221
+ /**
222
+ * 获取永续合约当前资金费率
223
+ * 获取当前资金费率
224
+ *
225
+ * 限速:20次/2s
226
+ * 限速规则:IP +instrumentID
227
+ *
228
+ * https://www.okx.com/docs-v5/zh/#public-data-rest-api-get-funding-rate
229
+ */
230
+ getFundingRate: (params: {
231
+ instId: string;
232
+ }) => Promise<{
233
+ code: string;
234
+ data: Array<{
235
+ fundingRate: string;
236
+ fundingTime: string;
237
+ instId: string;
238
+ instType: string;
239
+ method: string;
240
+ maxFundingRate: string;
241
+ minFundingRate: string;
242
+ nextFundingRate: string;
243
+ nextFundingTime: string;
244
+ premium: string;
245
+ settFundingRate: string;
246
+ settState: string;
247
+ ts: string;
248
+ }>;
249
+ msg: string;
250
+ }>;
251
+ /**
252
+ * 获取永续合约历史资金费率
253
+ *
254
+ * 获取最近3个月的历史资金费率
255
+ *
256
+ * 限速:10次/2s
257
+ * 限速规则:IP +instrumentID
258
+ *
259
+ * https://www.okx.com/docs-v5/zh/#public-data-rest-api-get-funding-rate-history
260
+ */
261
+ getFundingRateHistory: (params: {
262
+ instId: string;
263
+ before?: string;
264
+ after?: string;
265
+ limit?: string;
266
+ }) => Promise<{
267
+ code: string;
268
+ msg: string;
269
+ data: Array<{
270
+ fundingRate: string;
271
+ fundingTime: string;
272
+ instId: string;
273
+ instType: string;
274
+ method: string;
275
+ realizedRate: string;
276
+ }>;
277
+ }>;
278
+ /**
279
+ * 获取标记价格历史K线数据
280
+ *
281
+ * 获取最近几年的标记价格K线数据
282
+ *
283
+ * 限速:10次/2s
284
+ * 限速规则:IP
285
+ *
286
+ * https://www.okx.com/docs-v5/zh/#public-data-rest-api-get-mark-price-candlesticks-history
287
+ */
288
+ getHistoryMarkPriceCandles: (params: {
289
+ instId: string;
290
+ bar?: string;
291
+ after?: string;
292
+ before?: string;
293
+ limit?: string;
294
+ }) => Promise<{
295
+ code: string;
296
+ msg: string;
297
+ data: Array<[ts: string, o: string, h: string, l: string, c: string, confirm: string]>;
298
+ }>;
299
+ /**
300
+ * GET / 获取交易产品历史K线数据
301
+ *
302
+ * 获取最近几年的历史k线数据(1s k线支持查询最近3个月的数据)
303
+ *
304
+ * 限速:20次/2s
305
+ *
306
+ * 限速规则:IP
307
+ *
308
+ * 期权不支持 1s K线, 其他业务线 (币币, 杠杆, 交割和永续)支持
309
+ */
310
+ getHistoryCandles: (params: {
311
+ instId: string;
312
+ bar?: string;
313
+ after?: string;
314
+ before?: string;
315
+ limit?: string;
316
+ }) => Promise<{
317
+ code: string;
318
+ msg: string;
319
+ data: Array<[
320
+ ts: string,
321
+ o: string,
322
+ h: string,
323
+ l: string,
324
+ c: string,
325
+ vol: string,
326
+ volCcy: string,
327
+ volCcyQuote: string,
328
+ confirm: string
329
+ ]>;
330
+ }>;
331
+ /**
332
+ * 获取余币宝余额
333
+ *
334
+ * 限速:6次/s
335
+ * 限速规则:UserID
336
+ *
337
+ * https://www.okx.com/docs-v5/zh/#financial-product-savings-get-saving-balance
338
+ */
339
+ getFinanceSavingsBalance: (params: {
340
+ ccy?: string;
341
+ }) => Promise<{
342
+ code: string;
343
+ msg: string;
344
+ data: {
345
+ earnings: string;
346
+ redemptAmt: string;
347
+ rate: string;
348
+ ccy: string;
349
+ amt: string;
350
+ loanAmt: string;
351
+ pendingAmt: string;
352
+ }[];
353
+ }>;
354
+ /**
355
+ * 余币宝申购/赎回
356
+ *
357
+ * 仅资金账户中的资产支持余币宝申购。
358
+ *
359
+ * 限速:6次/s
360
+ *
361
+ * 限速规则:UserID
362
+ *
363
+ * https://www.okx.com/docs-v5/zh/#financial-product-savings-post-savings-purchase-redemption
364
+ */
365
+ postFinanceSavingsPurchaseRedempt: (params: {
366
+ ccy: string;
367
+ amt: string;
368
+ side: string;
369
+ rate: string;
370
+ }) => Promise<{
371
+ code: string;
372
+ msg: string;
373
+ data: {
374
+ ccy: string;
375
+ amt: string;
376
+ side: string;
377
+ rate: string;
378
+ }[];
379
+ }>;
380
+ /**
381
+ * GET / 获取市场借贷历史(公共)
382
+ *
383
+ * 公共接口无须鉴权
384
+ *
385
+ * 返回2021年12月14日后的记录
386
+ *
387
+ * 限速:6次/s
388
+ * 限速规则:IP
389
+ *
390
+ * https://www.okx.com/docs-v5/zh/#financial-product-savings-get-public-borrow-history-public
391
+ */
392
+ getLendingRateHistory: (params: {
393
+ ccy?: string;
394
+ after?: string;
395
+ before?: string;
396
+ limit?: string;
397
+ }) => Promise<{
398
+ code: string;
399
+ msg: string;
400
+ data: Array<{
401
+ ccy: string;
402
+ amt: string;
403
+ rate: string;
404
+ ts: string;
405
+ }>;
406
+ }>;
407
+ /**
408
+ * 提币
409
+ *
410
+ * 用户提币。普通子账户不支持提币。
411
+ *
412
+ * API只能提币到免认证地址/账户上,通过 WEB/APP 可以设置免认证地址。
413
+ *
414
+ * 关于标签:某些币种如XRP充币时同时需要一个充值地址和标签(又名memo/payment_id),标签是一种保证您的充币地址唯一性的数字串,与充币地址成对出现并一一对应。请您务必遵守正确的充值步骤,在提币时输入完整信息,否则将面临丢失币的风险!
415
+ * 对于有标签的币种,如果是OKX用户间的提币,请走内部转账不要走链上提币。
416
+ *
417
+ * 限速:6次/s
418
+ * 限速规则:UserID
419
+ *
420
+ * https://www.okx.com/docs-v5/zh/#funding-account-rest-api-withdrawal
421
+ */
422
+ postAssetWithdrawal: (params: {
423
+ amt: string;
424
+ fee: string;
425
+ dest: string;
426
+ ccy: string;
427
+ chain?: string;
428
+ toAddr: string;
429
+ clientId?: string;
430
+ rcvrInfo?: {
431
+ walletType: string;
432
+ exchId: string;
433
+ rcvrFirstName: string;
434
+ rcvrLastName: string;
435
+ };
436
+ }) => Promise<{
437
+ code: string;
438
+ msg: string;
439
+ data: Array<{
440
+ amt: string;
441
+ wdId: string;
442
+ ccy: string;
443
+ clientId: string;
444
+ chain: string;
445
+ }>;
446
+ }>;
447
+ /**
448
+ * 获取充值地址信息
449
+ *
450
+ * 获取各个币种的充值地址,包括曾使用过的老地址。
451
+ *
452
+ * 限速:6次/s
453
+ * 限速规则:UserID
454
+ *
455
+ * https://www.okx.com/docs-v5/zh/#funding-account-rest-api-get-deposit-address
456
+ */
457
+ getAssetDepositAddress: (params: {
458
+ ccy: string;
459
+ }) => Promise<{
460
+ code: string;
461
+ data: {
462
+ chain: string;
463
+ ctAddr: string;
464
+ ccy: string;
465
+ to: string;
466
+ addr: string;
467
+ verifiedName: string;
468
+ selected: boolean;
469
+ }[];
470
+ msg: string;
471
+ }>;
472
+ /**
473
+ * 获取提币记录
474
+ *
475
+ * 根据币种,提币状态,时间范围获取提币记录,按照时间倒序排列,默认返回100条数据。
476
+ * 支持Websocket订阅,参考 提币信息频道。
477
+ *
478
+ * 限速:6 次/s
479
+ * 限速规则:UserID
480
+ *
481
+ * https://www.okx.com/docs-v5/zh/#funding-account-rest-api-get-withdrawal-history
482
+ */
483
+ getAssetWithdrawalHistory: (params: {
484
+ ccy?: string;
485
+ wdId?: string;
486
+ clientId?: string;
487
+ txId?: string;
488
+ type?: string;
489
+ state?: string;
490
+ after?: string;
491
+ before?: string;
492
+ limit?: string;
493
+ }) => Promise<{
494
+ code: string;
495
+ msg: string;
496
+ data: {
497
+ chain: string;
498
+ fee: string;
499
+ feeCcy: string;
500
+ ccy: string;
501
+ clientId: string;
502
+ amt: string;
503
+ txId: string;
504
+ from: string;
505
+ areaCodeFrom: string;
506
+ to: string;
507
+ areaCodeTo: string;
508
+ state: string;
509
+ ts: string;
510
+ nonTradableAsset: boolean;
511
+ wdId: string;
512
+ }[];
513
+ }>;
514
+ /**
515
+ * 获取充值记录
516
+ *
517
+ * 根据币种,充值状态,时间范围获取充值记录,按照时间倒序排列,默认返回 100 条数据。
518
+ * 支持Websocket订阅,参考 充值信息频道。
519
+ *
520
+ * 限速:6次/s
521
+ * 限速规则:UserID
522
+ *
523
+ * https://www.okx.com/docs-v5/zh/#funding-account-rest-api-get-deposit-history
524
+ */
525
+ getAssetDepositHistory: (params: {
526
+ ccy?: string;
527
+ depId?: string;
528
+ state?: string;
529
+ fromWdId?: string;
530
+ txId?: string;
531
+ type?: string;
532
+ after?: string;
533
+ before?: string;
534
+ limit?: string;
535
+ }) => Promise<{
536
+ code: string;
537
+ msg: string;
538
+ data: {
539
+ actualDepBlkConfirm: string;
540
+ amt: string;
541
+ areaCodeFrom: string;
542
+ ccy: string;
543
+ chain: string;
544
+ depId: string;
545
+ from: string;
546
+ fromWdId: string;
547
+ state: string;
548
+ to: string;
549
+ ts: string;
550
+ txId: string;
551
+ }[];
552
+ }>;
553
+ /**
554
+ * 获取资金账户余额
555
+ *
556
+ * 获取资金账户所有资产列表,查询各币种的余额、冻结和可用等信息。
557
+ *
558
+ * 只返回余额大于0的币资产信息。
559
+ *
560
+ * 限速:6次/s
561
+ * 限速规则:UserID
562
+ *
563
+ * https://www.okx.com/docs-v5/zh/#funding-account-rest-api-get-balance
564
+ */
565
+ getAssetBalances: (params: {
566
+ ccy?: string;
567
+ }) => Promise<{
568
+ code: string;
569
+ msg: string;
570
+ data: {
571
+ availBal: string;
572
+ bal: string;
573
+ ccy: string;
574
+ frozenBal: string;
575
+ }[];
576
+ }>;
577
+ /**
578
+ * 资金划转
579
+ *
580
+ * 调用时,API Key 需要有交易权限。
581
+ *
582
+ * 支持母账户的资金账户划转到交易账户,母账户到子账户的资金账户和交易账户划转。
583
+ *
584
+ * 子账户默认可转出至母账户,划转到同一母账户下的其他子账户,需要先调用 设置子账户主动转出权限 接口进行授权。
585
+ *
586
+ * 请求失败不代表划转失败,建议以获取资金划转状态接口返回的状态为准。
587
+ *
588
+ * 限速:2 次/s
589
+ * 限速规则:UserID + Currency
590
+ *
591
+ * https://www.okx.com/docs-v5/zh/#funding-account-rest-api-funds-transfer
592
+ */
593
+ postAssetTransfer: (params: {
594
+ ccy: string;
595
+ type?: string;
596
+ amt: string;
597
+ from: string;
598
+ to: string;
599
+ subAcct?: string;
600
+ loanTrans?: boolean;
601
+ omitPosRisk?: string;
602
+ clientId?: string;
603
+ }) => Promise<{
604
+ code: string;
605
+ msg: string;
606
+ data: {
607
+ transId: string;
608
+ ccy: string;
609
+ clientId: string;
610
+ from: string;
611
+ amt: string;
612
+ to: string;
613
+ }[];
614
+ }>;
615
+ /**
616
+ * 查看账户余额
617
+ *
618
+ * 获取交易账户中资金余额信息。
619
+ *
620
+ * 免息额度和折算率都是公共数据,不在账户接口内展示
621
+ *
622
+ * 限速:10次/2s
623
+ * 限速规则:UserID
624
+ *
625
+ * https://www.okx.com/docs-v5/zh/#trading-account-rest-api-get-balance
626
+ */
627
+ getAccountBalance: (params: {
628
+ ccy?: string;
629
+ }) => Promise<{
630
+ code: string;
631
+ data: {
632
+ adjEq: string;
633
+ borrowFroz: string;
634
+ details: {
635
+ availBal: string;
636
+ availEq: string;
637
+ borrowFroz: string;
638
+ cashBal: string;
639
+ ccy: string;
640
+ crossLiab: string;
641
+ disEq: string;
642
+ eq: string;
643
+ eqUsd: string;
644
+ fixedBal: string;
645
+ frozenBal: string;
646
+ imr: string;
647
+ interest: string;
648
+ isoEq: string;
649
+ isoLiab: string;
650
+ isoUpl: string;
651
+ liab: string;
652
+ maxLoan: string;
653
+ mgnRatio: string;
654
+ mmr: string;
655
+ notionalLever: string;
656
+ ordFrozen: string;
657
+ rewardBal: string;
658
+ spotInUseAmt: string;
659
+ spotIsoBal: string;
660
+ stgyEq: string;
661
+ twap: string;
662
+ uTime: string;
663
+ upl: string;
664
+ uplLiab: string;
665
+ openAvgPx: string;
666
+ spotUpl: string;
667
+ accAvgPx: string;
668
+ totalPnl: string;
669
+ spotBal: string;
670
+ }[];
671
+ imr: string;
672
+ isoEq: string;
673
+ mgnRatio: string;
674
+ mmr: string;
675
+ notionalUsd: string;
676
+ ordFroz: string;
677
+ totalEq: string;
678
+ uTime: string;
679
+ upl: string;
680
+ }[];
681
+ msg: string;
682
+ }>;
683
+ /**
684
+ * 查看持仓信息
685
+ *
686
+ * 获取该账户下拥有实际持仓的信息。账户为买卖模式会显示净持仓(net),账户为开平仓模式下会分别返回开多(long)或开空(short)的仓位。按照仓位创建时间倒序排列。
687
+ *
688
+ * 如果该 instId 拥有过仓位且当前持仓量为0,传 instId 时,如果当前存在有效的posId,会返回仓位信息,如果当前不存在有效的 posId 时,不会返回仓位信息;不传 instId 时,仓位信息不返回。
689
+ *
690
+ * 逐仓交易设置中,如果设置为自主划转模式,逐仓转入保证金后,会生成一个持仓量为0的仓位
691
+ *
692
+ * 限速:10次/2s
693
+ * 限速规则:UserID
694
+ *
695
+ * https://www.okx.com/docs-v5/zh/#trading-account-rest-api-get-positions
696
+ */
697
+ getAccountPositions: (params: {
698
+ instType?: string;
699
+ instId?: string;
700
+ posId?: string;
701
+ }) => Promise<{
702
+ code: string;
703
+ msg: string;
704
+ data: {
705
+ adl: string;
706
+ availPos: string;
707
+ avgPx: string;
708
+ cTime: string;
709
+ ccy: string;
710
+ deltaBS: string;
711
+ deltaPA: string;
712
+ gammaBS: string;
713
+ gammaPA: string;
714
+ imr: string;
715
+ instId: string;
716
+ instType: string;
717
+ interest: string;
718
+ idxPx: string;
719
+ last: string;
720
+ usdPx: string;
721
+ bePx: string;
722
+ lever: string;
723
+ liab: string;
724
+ liabCcy: string;
725
+ liqPx: string;
726
+ markPx: string;
727
+ margin: string;
728
+ mgnMode: string;
729
+ mgnRatio: string;
730
+ mmr: string;
731
+ notionalUsd: string;
732
+ optVal: string;
733
+ pTime: string;
734
+ pos: string;
735
+ posCcy: string;
736
+ posId: string;
737
+ posSide: string;
738
+ spotInUseAmt: string;
739
+ spotInUseCcy: string;
740
+ thetaBS: string;
741
+ thetaPA: string;
742
+ tradeId: string;
743
+ bizRefId: string;
744
+ bizRefType: string;
745
+ quoteBal: string;
746
+ baseBal: string;
747
+ baseBorrowed: string;
748
+ baseInterest: string;
749
+ quoteBorrowed: string;
750
+ quoteInterest: string;
751
+ uTime: string;
752
+ upl: string;
753
+ uplLastPx: string;
754
+ uplRatio: string;
755
+ uplRatioLastPx: string;
756
+ vegaBS: string;
757
+ vegaPA: string;
758
+ realizedPnl: string;
759
+ pnl: string;
760
+ fee: string;
761
+ fundingFee: string;
762
+ liqPenalty: string;
763
+ closeOrderAlgo: {
764
+ algoId: string;
765
+ slTriggerPx: string;
766
+ slTriggerPxType: string;
767
+ tpTriggerPx: string;
768
+ tpTriggerPxType: string;
769
+ closeFraction: string;
770
+ }[];
771
+ }[];
772
+ }>;
773
+ /**
774
+ * 赚币
775
+ * GET / 查看项目
776
+ *
777
+ * 限速:3次/s
778
+ * 限速规则:UserID
779
+ */
780
+ getFinanceStakingDeFiOffers: (params: {
781
+ productId?: string;
782
+ protocolType?: string;
783
+ ccy?: string;
784
+ }) => Promise<{
785
+ code: string;
786
+ msg: string;
787
+ data: {
788
+ ccy: string;
789
+ productId: string;
790
+ protocol: string;
791
+ protocolType: string;
792
+ term: string;
793
+ apy: string;
794
+ earlyRedeem: boolean;
795
+ investData: {
796
+ ccy: string;
797
+ bal: string;
798
+ minAmt: string;
799
+ maxAmt: string;
800
+ }[];
801
+ earningData: {
802
+ ccy: string;
803
+ earningType: string;
804
+ }[];
805
+ state: string;
806
+ earningCcy?: string[];
807
+ }[];
808
+ }>;
809
+ /**
810
+ * 赚币
811
+ * GET / 查看活跃订单
812
+ *
813
+ * 限速:3次/s
814
+ * 限速规则:UserID
815
+ */
816
+ getFinanceStakingDeFiOrdersActive: (params: {
817
+ productId?: string;
818
+ protocolType?: string;
819
+ ccy?: string;
820
+ state?: string;
821
+ }) => Promise<{
822
+ code: string;
823
+ msg: string;
824
+ data: {
825
+ ordId: string;
826
+ state: string;
827
+ ccy: string;
828
+ protocol: string;
829
+ protocolType: string;
830
+ term: string;
831
+ apy: string;
832
+ investData: {
833
+ ccy: string;
834
+ amt: string;
835
+ minAmt?: string;
836
+ maxAmt?: string;
837
+ }[];
838
+ earningData: {
839
+ ccy: string;
840
+ earningType: string;
841
+ earnings: string;
842
+ }[];
843
+ purchasedTime: string;
844
+ estSettlementTime: string;
845
+ cancelRedemptionDeadline: string;
846
+ tag: string;
847
+ earningCcy?: string[];
848
+ }[];
849
+ }>;
850
+ /**
851
+ * 下单
852
+ *
853
+ * 只有当您的账户有足够的资金才能下单。
854
+ *
855
+ * 限速:60次/2s
856
+ *
857
+ * 跟单交易带单产品的限速:4次/2s
858
+ *
859
+ * 限速规则(期权以外):UserID + Instrument ID
860
+ *
861
+ * 限速规则(只限期权):UserID + Instrument Family
862
+ *
863
+ * https://www.okx.com/docs-v5/zh/#order-book-trading-trade-post-place-order
864
+ */
865
+ postTradeOrder: (params: {
866
+ instId: string;
867
+ tdMode: string;
868
+ ccy?: string;
869
+ clOrdId?: string;
870
+ tag?: string;
871
+ side: string;
872
+ posSide?: string;
873
+ ordType: string;
874
+ sz: string;
875
+ px?: string;
876
+ pxUsd?: string;
877
+ pxVol?: string;
878
+ reduceOnly?: string;
879
+ tgtCcy?: string;
880
+ banAmend?: string;
881
+ quickMgnType?: string;
882
+ stpId?: string;
883
+ stpMode?: string;
884
+ attachAlgoOrds?: Array<{
885
+ attachAlgoClOrdId?: string;
886
+ tpTriggerPx?: string;
887
+ tpOrdPx?: string;
888
+ tpOrdKind?: string;
889
+ slTriggerPx?: string;
890
+ slOrdPx?: string;
891
+ tpTriggerPxType?: string;
892
+ slTriggerPxType?: string;
893
+ sz?: string;
894
+ amendPxOnTriggerType?: string;
895
+ }>;
896
+ }) => Promise<{
897
+ code: string;
898
+ msg: string;
899
+ data: {
900
+ clOrdId: string;
901
+ ordId: string;
902
+ tag: string;
903
+ sCode: string;
904
+ sMsg: string;
905
+ }[];
906
+ inTime: string;
907
+ outTime: string;
908
+ }>;
909
+ /**
910
+ * 修改订单
911
+ *
912
+ * 修改当前未成交的挂单
913
+ *
914
+ * 限速:60次/2s
915
+ *
916
+ * 跟单交易带单员带单产品的限速:4个/2s
917
+ *
918
+ * 限速规则:User ID + Instrument ID
919
+ *
920
+ * 权限:交易
921
+ *
922
+ * 该接口限速同时受到 子账户限速 及 基于成交比率的子账户限速 限速规则的影响。
923
+ */
924
+ postTradeAmendOrder: (params: {
925
+ instId: string;
926
+ cxIOnFail?: boolean;
927
+ ordId?: string;
928
+ clOrdId?: string;
929
+ reqId?: string;
930
+ newSz?: string;
931
+ newPx?: string;
932
+ newPxUsd?: string;
933
+ newPxVol?: string;
934
+ attachAlgoOrds?: Array<{
935
+ attachAlgoId?: string;
936
+ attachAlgoClOrdId?: string;
937
+ newTpTriggerPx?: string;
938
+ newTpOrdPx?: string;
939
+ newTpOrdKind?: string;
940
+ newSlTriggerPx?: string;
941
+ newSlOrdPx?: string;
942
+ newTpTriggerPxType?: string;
943
+ newSlTriggerPxType?: string;
944
+ sz?: string;
945
+ amendPxOnTriggerType?: string;
946
+ }>;
947
+ }) => Promise<{
948
+ code: string;
949
+ msg: string;
950
+ data: {
951
+ clOrdId: string;
952
+ ordId: string;
953
+ ts: string;
954
+ reqId: string;
955
+ sCode: string;
956
+ sMsg: string;
957
+ }[];
958
+ inTime: string;
959
+ outTime: string;
960
+ }>;
961
+ /**
962
+ * 获取未成交订单列表
963
+ *
964
+ * 获取当前账户下所有未成交订单信息
965
+ *
966
+ * 限速:60次/2s
967
+ * 限速规则:UserID
968
+ *
969
+ * https://www.okx.com/docs-v5/zh/#order-book-trading-trade-get-order-list
970
+ */
971
+ getTradeOrdersPending: (params: {
972
+ instType?: string;
973
+ uly?: string;
974
+ instFamily?: string;
975
+ instId?: string;
976
+ ordType?: string;
977
+ state?: string;
978
+ after?: string;
979
+ before?: string;
980
+ limit?: string;
981
+ }) => Promise<{
982
+ code: string;
983
+ msg: string;
984
+ data: {
985
+ accFillSz: string;
986
+ avgPx: string;
987
+ cTime: string;
988
+ category: string;
989
+ ccy: string;
990
+ clOrdId: string;
991
+ fee: string;
992
+ feeCcy: string;
993
+ fillPx: string;
994
+ fillSz: string;
995
+ fillTime: string;
996
+ instId: string;
997
+ instType: string;
998
+ lever: string;
999
+ ordId: string;
1000
+ ordType: string;
1001
+ pnl: string;
1002
+ posSide: string;
1003
+ px: string;
1004
+ pxUsd: string;
1005
+ pxVol: string;
1006
+ pxType: string;
1007
+ rebate: string;
1008
+ rebateCcy: string;
1009
+ side: string;
1010
+ attachAlgoClOrdId: string;
1011
+ slOrdPx: string;
1012
+ slTriggerPx: string;
1013
+ slTriggerPxType: string;
1014
+ attachAlgoOrds: any[];
1015
+ source: string;
1016
+ state: string;
1017
+ stpId: string;
1018
+ stpMode: string;
1019
+ sz: string;
1020
+ tag: string;
1021
+ tdMode: string;
1022
+ tgtCcy: string;
1023
+ tpOrdPx: string;
1024
+ tpTriggerPx: string;
1025
+ tpTriggerPxType: string;
1026
+ tradeId: string;
1027
+ reduceOnly: string;
1028
+ quickMgnType: string;
1029
+ algoClOrdId: string;
1030
+ algoId: string;
1031
+ isTpLimit: string;
1032
+ uTime: string;
1033
+ }[];
1034
+ }>;
1035
+ /**
1036
+ * 获取历史订单记录(近七天)
1037
+ *
1038
+ * 获取最近7天挂单,且完成的订单数据,包括7天以前挂单,但近7天才成交的订单数据。按照订单创建时间倒序排序。
1039
+ *
1040
+ * 已经撤销的未成交单 只保留2小时
1041
+ * 限速:40次/2s
1042
+ * 限速规则:User ID
1043
+ */
1044
+ getTradeOrdersHistory: (params: {
1045
+ instType: string;
1046
+ uly?: string;
1047
+ instFamily?: string;
1048
+ instId?: string;
1049
+ ordType?: string;
1050
+ state?: string;
1051
+ category?: string;
1052
+ after?: string;
1053
+ before?: string;
1054
+ begin?: string;
1055
+ end?: string;
1056
+ limit?: string;
1057
+ }) => Promise<{
1058
+ code: string;
1059
+ msg: string;
1060
+ data: Array<{
1061
+ instType: string;
1062
+ instId: string;
1063
+ tgtCcy: string;
1064
+ ccy: string;
1065
+ ordId: string;
1066
+ clOrdId: string;
1067
+ tag: string;
1068
+ px: string;
1069
+ pxUsd: string;
1070
+ pxVol: string;
1071
+ pxType: string;
1072
+ sz: string;
1073
+ ordType: string;
1074
+ side: string;
1075
+ posSide: string;
1076
+ tdMode: string;
1077
+ accFillSz: string;
1078
+ fillPx: string;
1079
+ tradeId: string;
1080
+ fillSz: string;
1081
+ fillTime: string;
1082
+ avgPx: string;
1083
+ state: string;
1084
+ lever: string;
1085
+ attachAlgoClOrdId: string;
1086
+ tpTriggerPx: string;
1087
+ tpTriggerPxType: string;
1088
+ tpOrdPx: string;
1089
+ slTriggerPx: string;
1090
+ slTriggerPxType: string;
1091
+ slOrdPx: string;
1092
+ attachAlgoOrds: any[];
1093
+ linkedAlgoOrd: any[];
1094
+ stpId: string;
1095
+ stpMode: string;
1096
+ feeCcy: string;
1097
+ fee: string;
1098
+ rebateCcy: string;
1099
+ source: string;
1100
+ rebate: string;
1101
+ pnl: string;
1102
+ category: string;
1103
+ reduceOnly: string;
1104
+ cancelSource: string;
1105
+ cancelSourceReason: string;
1106
+ algoClOrdId: string;
1107
+ algoId: string;
1108
+ isTpLimit: string;
1109
+ uTime: string;
1110
+ cTime: string;
1111
+ tradeQuoteCcy: string;
1112
+ }>;
1113
+ }>;
1114
+ /**
1115
+ * 撤单
1116
+ *
1117
+ * 撤销之前下的未完成订单。
1118
+ *
1119
+ * 限速:60次/2s
1120
+ *
1121
+ * 限速规则(期权以外):UserID + Instrument ID
1122
+ *
1123
+ * 限速规则(只限期权):UserID + Instrument Family
1124
+ *
1125
+ * https://www.okx.com/docs-v5/zh/#order-book-trading-trade-post-cancel-order
1126
+ */
1127
+ postTradeCancelOrder: (params: {
1128
+ instId: string;
1129
+ ordId?: string;
1130
+ clOrdId?: string;
1131
+ }) => Promise<{
1132
+ code: string;
1133
+ msg: string;
1134
+ data: {
1135
+ clOrdId: string;
1136
+ ordId: string;
1137
+ sCode: string;
1138
+ sMsg: string;
1139
+ }[];
1140
+ inTime: string;
1141
+ outTime: string;
1142
+ }>;
1143
+ /**
1144
+ * 查看子账户列表
1145
+ *
1146
+ * 仅适用于母账户。
1147
+ *
1148
+ * 限速:2次/2s
1149
+ *
1150
+ * 限速规则:UserID
1151
+ */
1152
+ getSubAccountList: (params?: {
1153
+ enable?: string;
1154
+ subAct?: string;
1155
+ after?: string;
1156
+ before?: string;
1157
+ limit?: string;
1158
+ }) => Promise<{
1159
+ data: {
1160
+ type: string;
1161
+ enable: string;
1162
+ subAcct: string;
1163
+ uid: string;
1164
+ label: string;
1165
+ mobile: string;
1166
+ gAuth: boolean;
1167
+ frozenFunc: string[];
1168
+ canTransOut: boolean;
1169
+ ts: string;
1170
+ }[];
1171
+ code: string;
1172
+ msg: string;
1173
+ }>;
1174
+ /**
1175
+ * 设置子账户主动转出权限
1176
+ *
1177
+ * 设置子账户转出权限(仅适用于母账户),默认可转出至母账户。
1178
+ *
1179
+ * 限速:1次/s
1180
+ *
1181
+ * 限速规则:UserID
1182
+ */
1183
+ postSetSubAccountTransferOut: (params: {
1184
+ subAcct: string;
1185
+ canTransOut: boolean;
1186
+ }) => Promise<{
1187
+ subAcct: string;
1188
+ canTransOut: boolean;
1189
+ }>;
1190
+ /**
1191
+ * 获取资金划转状态
1192
+ *
1193
+ * 获取最近2个星期内的资金划转状态数据
1194
+ *
1195
+ * 限速:10 次/s
1196
+ *
1197
+ * 限速规则:UserID
1198
+ *
1199
+ * https://www.okx.com/docs-v5/zh/#funding-account-rest-api-get-funds-transfer-state
1200
+ */
1201
+ getAssetTransferState: (params: {
1202
+ transId?: string;
1203
+ clientId?: string;
1204
+ type?: string;
1205
+ }) => Promise<{
1206
+ code: string;
1207
+ msg: string;
1208
+ data: {
1209
+ transId: string;
1210
+ clientId: string;
1211
+ ccy: string;
1212
+ amt: string;
1213
+ type: string;
1214
+ from: string;
1215
+ to: string;
1216
+ subAcct: string;
1217
+ state: string;
1218
+ }[];
1219
+ }>;
1220
+ /**
1221
+ * 获取币种列表
1222
+ *
1223
+ * 获取当前用户KYC实体支持的币种列表。
1224
+ *
1225
+ * 限速:6 次/s
1226
+ *
1227
+ * 限速规则:UserID
1228
+ *
1229
+ * https://www.okx.com/docs-v5/zh/#funding-account-rest-api-get-currencies
1230
+ */
1231
+ getAssetCurrencies: (params?: {
1232
+ ccy?: string;
1233
+ }) => Promise<{
1234
+ code: string;
1235
+ msg: string;
1236
+ data: {
1237
+ ccy: string;
1238
+ name: string;
1239
+ chain: string;
1240
+ canWd: boolean;
1241
+ canInternal: boolean;
1242
+ minWd: string;
1243
+ maxWd: string;
1244
+ wdTickSz: string;
1245
+ wdQuota: string;
1246
+ usedWdQuota: string;
1247
+ minFee: string;
1248
+ maxFee: string;
1249
+ }[];
1250
+ }>;
1251
+ /**
1252
+ * 获取指数行情数据
1253
+ *
1254
+ *
1255
+ * 限速:20 次/2s
1256
+ *
1257
+ *
1258
+ * https://www.okx.com/docs-v5/zh/#public-data-rest-api-get-index-tickers
1259
+ */
1260
+ getMarketIndexTicker: (params?: {
1261
+ quoteCcy?: string;
1262
+ instId?: string;
1263
+ }) => Promise<{
1264
+ code: string;
1265
+ msg: string;
1266
+ data: {
1267
+ instId: string;
1268
+ idxPx: string;
1269
+ high24h: string;
1270
+ sodUtc0: string;
1271
+ open24h: string;
1272
+ low24h: string;
1273
+ sodUtc8: string;
1274
+ ts: string;
1275
+ }[];
1276
+ }>;
1277
+ /**
1278
+ * 账单流水查询(近七天)
1279
+ *
1280
+ *
1281
+ * 限速:5次/s
1282
+ *
1283
+ *
1284
+ * https://www.okx.com/docs-v5/zh/#trading-account-rest-api-get-bills-details-last-7-days
1285
+ */
1286
+ getAccountBills: (params?: {
1287
+ instType?: string;
1288
+ instId?: string;
1289
+ ccy?: string;
1290
+ mgnMode?: 'isolated' | 'cross';
1291
+ ctType?: 'linear' | 'inverse';
1292
+ type?: AccountBillType;
1293
+ subType?: string;
1294
+ after?: string;
1295
+ before?: string;
1296
+ begin?: string;
1297
+ end?: string;
1298
+ limit?: string;
1299
+ }) => Promise<{
1300
+ code: string;
1301
+ msg: string;
1302
+ data: {
1303
+ instType: string;
1304
+ billId: string;
1305
+ type: string;
1306
+ subType: string;
1307
+ ts: string;
1308
+ balChg: string;
1309
+ posBalChg: string;
1310
+ bal: string;
1311
+ posBal: string;
1312
+ sz: string;
1313
+ px: string;
1314
+ ccy: string;
1315
+ pnl: string;
1316
+ fee: string;
1317
+ mgnMode: 'isolated' | 'cross' | 'cash' | '';
1318
+ instId: string;
1319
+ ordId: string;
1320
+ execType: string;
1321
+ from: string;
1322
+ to: string;
1323
+ notes: string;
1324
+ interest: string;
1325
+ tag: string;
1326
+ fillTime: string;
1327
+ tradeId: string;
1328
+ clOrdId: string;
1329
+ fillIdxPx: string;
1330
+ fillMarkPx: string;
1331
+ fillPxVol: string;
1332
+ fillPxUsd: string;
1333
+ fillMarkVol: string;
1334
+ fillFwdPx: string;
1335
+ }[];
1336
+ }>;
1337
+ /**
1338
+ * 账单流水查询(近三个月)
1339
+ *
1340
+ *
1341
+ * 限速:5次/2s
1342
+ *
1343
+ *
1344
+ * https://www.okx.com/docs-v5/zh/#trading-account-rest-api-get-bills-details-last-3-months
1345
+ */
1346
+ getAccountBillsArchive: (params?: {
1347
+ instType?: string;
1348
+ instId?: string;
1349
+ ccy?: string;
1350
+ mgnMode?: 'isolated' | 'cross';
1351
+ ctType?: 'linear' | 'inverse';
1352
+ type?: AccountBillType;
1353
+ subType?: string;
1354
+ after?: string;
1355
+ before?: string;
1356
+ begin?: string;
1357
+ end?: string;
1358
+ limit?: string;
1359
+ }) => Promise<{
1360
+ code: string;
1361
+ msg: string;
1362
+ data: {
1363
+ instType: string;
1364
+ billId: string;
1365
+ type: string;
1366
+ subType: string;
1367
+ ts: string;
1368
+ balChg: string;
1369
+ posBalChg: string;
1370
+ bal: string;
1371
+ posBal: string;
1372
+ sz: string;
1373
+ px: string;
1374
+ ccy: string;
1375
+ pnl: string;
1376
+ fee: string;
1377
+ mgnMode: 'isolated' | 'cross' | 'cash' | '';
1378
+ instId: string;
1379
+ ordId: string;
1380
+ execType: string;
1381
+ from: string;
1382
+ to: string;
1383
+ notes: string;
1384
+ interest: string;
1385
+ tag: string;
1386
+ fillTime: string;
1387
+ tradeId: string;
1388
+ clOrdId: string;
1389
+ fillIdxPx: string;
1390
+ fillMarkPx: string;
1391
+ fillPxVol: string;
1392
+ fillPxUsd: string;
1393
+ fillMarkVol: string;
1394
+ fillFwdPx: string;
1395
+ }[];
1396
+ }>;
1397
+ }
1398
+ declare type AccountBillType = '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | '10' | '11' | '12' | '13' | '14' | '15' | '16' | '22' | '24' | '26' | '27' | '28' | '29' | '30' | '32' | '33' | '34' | '250' | '251';
1399
+ export declare const client: OkxClient;
1400
+ export {};
1401
+ //# sourceMappingURL=api.d.ts.map