unicex 0.5.0__py3-none-any.whl → 0.8.0__py3-none-any.whl

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 (100) hide show
  1. unicex/__init__.py +56 -124
  2. unicex/_abc/__init__.py +2 -0
  3. unicex/_abc/exchange_info.py +176 -0
  4. unicex/_abc/uni_client.py +2 -2
  5. unicex/_base/client.py +2 -2
  6. unicex/binance/__init__.py +12 -0
  7. unicex/binance/adapter.py +2 -2
  8. unicex/binance/exchange_info.py +12 -0
  9. unicex/bitget/__init__.py +14 -4
  10. unicex/bitget/adapter.py +1 -1
  11. unicex/bitget/exchange_info.py +12 -0
  12. unicex/bitget/uni_websocket_manager.py +1 -1
  13. unicex/bybit/__init__.py +12 -0
  14. unicex/bybit/adapter.py +2 -2
  15. unicex/bybit/exchange_info.py +12 -0
  16. unicex/bybit/uni_client.py +2 -2
  17. unicex/enums.py +16 -5
  18. unicex/extra.py +84 -6
  19. unicex/gateio/__init__.py +12 -0
  20. unicex/gateio/adapter.py +4 -4
  21. unicex/gateio/exchange_info.py +12 -0
  22. unicex/hyperliquid/__init__.py +12 -0
  23. unicex/hyperliquid/adapter.py +151 -30
  24. unicex/hyperliquid/client.py +2208 -125
  25. unicex/hyperliquid/exchange_info.py +100 -0
  26. unicex/hyperliquid/uni_client.py +176 -22
  27. unicex/mapper.py +35 -33
  28. unicex/mexc/__init__.py +12 -0
  29. unicex/mexc/adapter.py +30 -13
  30. unicex/mexc/exchange_info.py +32 -0
  31. unicex/mexc/uni_client.py +6 -0
  32. unicex/okx/__init__.py +12 -0
  33. unicex/okx/adapter.py +25 -9
  34. unicex/okx/client.py +2599 -26
  35. unicex/okx/exchange_info.py +50 -0
  36. unicex/okx/uni_client.py +10 -10
  37. unicex/types.py +31 -0
  38. unicex-0.8.0.dist-info/METADATA +192 -0
  39. unicex-0.8.0.dist-info/RECORD +75 -0
  40. unicex/bitrue/__init__.py +0 -15
  41. unicex/bitrue/adapter.py +0 -8
  42. unicex/bitrue/client.py +0 -128
  43. unicex/bitrue/uni_client.py +0 -151
  44. unicex/bitrue/uni_websocket_manager.py +0 -269
  45. unicex/bitrue/user_websocket.py +0 -7
  46. unicex/bitrue/websocket_manager.py +0 -11
  47. unicex/bitunix/__init__.py +0 -15
  48. unicex/bitunix/adapter.py +0 -8
  49. unicex/bitunix/client.py +0 -8
  50. unicex/bitunix/uni_client.py +0 -151
  51. unicex/bitunix/uni_websocket_manager.py +0 -269
  52. unicex/bitunix/user_websocket.py +0 -7
  53. unicex/bitunix/websocket_manager.py +0 -11
  54. unicex/btse/__init__.py +0 -15
  55. unicex/btse/adapter.py +0 -8
  56. unicex/btse/client.py +0 -123
  57. unicex/btse/uni_client.py +0 -151
  58. unicex/btse/uni_websocket_manager.py +0 -269
  59. unicex/btse/user_websocket.py +0 -7
  60. unicex/btse/websocket_manager.py +0 -11
  61. unicex/kcex/__init__.py +0 -15
  62. unicex/kcex/adapter.py +0 -8
  63. unicex/kcex/client.py +0 -8
  64. unicex/kcex/uni_client.py +0 -151
  65. unicex/kcex/uni_websocket_manager.py +0 -269
  66. unicex/kcex/user_websocket.py +0 -7
  67. unicex/kcex/websocket_manager.py +0 -11
  68. unicex/kraken/__init__.py +0 -15
  69. unicex/kraken/adapter.py +0 -8
  70. unicex/kraken/client.py +0 -165
  71. unicex/kraken/uni_client.py +0 -151
  72. unicex/kraken/uni_websocket_manager.py +0 -269
  73. unicex/kraken/user_websocket.py +0 -7
  74. unicex/kraken/websocket_manager.py +0 -11
  75. unicex/kucoin/__init__.py +0 -15
  76. unicex/kucoin/adapter.py +0 -8
  77. unicex/kucoin/client.py +0 -120
  78. unicex/kucoin/uni_client.py +0 -151
  79. unicex/kucoin/uni_websocket_manager.py +0 -269
  80. unicex/kucoin/user_websocket.py +0 -7
  81. unicex/kucoin/websocket_manager.py +0 -11
  82. unicex/weex/__init__.py +0 -15
  83. unicex/weex/adapter.py +0 -8
  84. unicex/weex/client.py +0 -8
  85. unicex/weex/uni_client.py +0 -151
  86. unicex/weex/uni_websocket_manager.py +0 -269
  87. unicex/weex/user_websocket.py +0 -7
  88. unicex/weex/websocket_manager.py +0 -11
  89. unicex/xt/__init__.py +0 -15
  90. unicex/xt/adapter.py +0 -8
  91. unicex/xt/client.py +0 -8
  92. unicex/xt/uni_client.py +0 -151
  93. unicex/xt/uni_websocket_manager.py +0 -269
  94. unicex/xt/user_websocket.py +0 -7
  95. unicex/xt/websocket_manager.py +0 -11
  96. unicex-0.5.0.dist-info/METADATA +0 -170
  97. unicex-0.5.0.dist-info/RECORD +0 -123
  98. {unicex-0.5.0.dist-info → unicex-0.8.0.dist-info}/WHEEL +0 -0
  99. {unicex-0.5.0.dist-info → unicex-0.8.0.dist-info}/licenses/LICENSE +0 -0
  100. {unicex-0.5.0.dist-info → unicex-0.8.0.dist-info}/top_level.txt +0 -0
unicex/okx/client.py CHANGED
@@ -205,76 +205,2649 @@ class Client(BaseClient):
205
205
  method=method, endpoint=endpoint, params=params, data=data, signed=signed
206
206
  )
207
207
 
208
- # topic: Order Book Trading
209
- # sub-topic: Market Data
208
+ # topic: Trading Account
210
209
 
211
- async def tickers(
210
+ async def get_account_instruments(
211
+ self,
212
+ inst_type: Literal["SPOT", "MARGIN", "SWAP", "FUTURES", "OPTION"],
213
+ inst_family: str | None = None,
214
+ inst_id: str | None = None,
215
+ ) -> dict:
216
+ """Получение доступных инструментов аккаунта.
217
+
218
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-instruments
219
+ """
220
+ params = {
221
+ "instType": inst_type,
222
+ "instFamily": inst_family,
223
+ "instId": inst_id,
224
+ }
225
+
226
+ return await self._make_request(
227
+ "GET",
228
+ endpoint="/api/v5/account/instruments",
229
+ params=params,
230
+ signed=True,
231
+ )
232
+
233
+ async def get_balance(self, ccy: str | None = None) -> dict:
234
+ """Получение баланса аккаунта.
235
+
236
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-balance
237
+ """
238
+ params = {
239
+ "ccy": ccy,
240
+ }
241
+
242
+ return await self._make_request(
243
+ "GET",
244
+ endpoint="/api/v5/account/balance",
245
+ params=params,
246
+ signed=True,
247
+ )
248
+
249
+ async def get_positions(
250
+ self,
251
+ inst_type: Literal["MARGIN", "SWAP", "FUTURES", "OPTION"] | None = None,
252
+ inst_id: str | None = None,
253
+ pos_id: str | None = None,
254
+ ) -> dict:
255
+ """Получение текущих позиций аккаунта.
256
+
257
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-positions
258
+ """
259
+ params = {
260
+ "instType": inst_type,
261
+ "instId": inst_id,
262
+ "posId": pos_id,
263
+ }
264
+
265
+ return await self._make_request(
266
+ "GET",
267
+ endpoint="/api/v5/account/positions",
268
+ params=params,
269
+ signed=True,
270
+ )
271
+
272
+ async def get_positions_history(
273
+ self,
274
+ inst_type: Literal["MARGIN", "SWAP", "FUTURES", "OPTION"] | None = None,
275
+ inst_id: str | None = None,
276
+ mgn_mode: Literal["cross", "isolated"] | None = None,
277
+ type_: str | None = None,
278
+ pos_id: str | None = None,
279
+ after: int | None = None,
280
+ before: int | None = None,
281
+ limit: int | None = None,
282
+ ) -> dict:
283
+ """Получение истории позиций аккаунта.
284
+
285
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-positions-history
286
+ """
287
+ params = {
288
+ "instType": inst_type,
289
+ "instId": inst_id,
290
+ "mgnMode": mgn_mode,
291
+ "type": type_,
292
+ "posId": pos_id,
293
+ "after": after,
294
+ "before": before,
295
+ "limit": limit,
296
+ }
297
+
298
+ return await self._make_request(
299
+ "GET",
300
+ endpoint="/api/v5/account/positions-history",
301
+ params=params,
302
+ signed=True,
303
+ )
304
+
305
+ async def get_account_position_risk(
306
+ self, inst_type: Literal["MARGIN", "SWAP", "FUTURES", "OPTION"] | None = None
307
+ ) -> dict:
308
+ """Получение риска по аккаунту и позициям.
309
+
310
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-account-and-position-risk
311
+ """
312
+ params = {
313
+ "instType": inst_type,
314
+ }
315
+
316
+ return await self._make_request(
317
+ "GET",
318
+ endpoint="/api/v5/account/account-position-risk",
319
+ params=params,
320
+ signed=True,
321
+ )
322
+
323
+ async def get_account_bills(
324
+ self,
325
+ inst_type: Literal["SPOT", "MARGIN", "SWAP", "FUTURES", "OPTION"] | None = None,
326
+ inst_id: str | None = None,
327
+ ccy: str | None = None,
328
+ mgn_mode: Literal["isolated", "cross"] | None = None,
329
+ ct_type: Literal["linear", "inverse"] | None = None,
330
+ type_: str | None = None,
331
+ sub_type: str | None = None,
332
+ after: str | None = None,
333
+ before: str | None = None,
334
+ begin: int | None = None,
335
+ end: int | None = None,
336
+ limit: int | None = None,
337
+ ) -> dict:
338
+ """Получение выписок за последние 7 дней.
339
+
340
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-bills-details-last-7-days
341
+ """
342
+ params = {
343
+ "instType": inst_type,
344
+ "instId": inst_id,
345
+ "ccy": ccy,
346
+ "mgnMode": mgn_mode,
347
+ "ctType": ct_type,
348
+ "type": type_,
349
+ "subType": sub_type,
350
+ "after": after,
351
+ "before": before,
352
+ "begin": begin,
353
+ "end": end,
354
+ "limit": limit,
355
+ }
356
+
357
+ return await self._make_request(
358
+ "GET",
359
+ endpoint="/api/v5/account/bills",
360
+ params=params,
361
+ signed=True,
362
+ )
363
+
364
+ async def get_account_bills_archive(
365
+ self,
366
+ inst_type: Literal["SPOT", "MARGIN", "SWAP", "FUTURES", "OPTION"] | None = None,
367
+ inst_id: str | None = None,
368
+ ccy: str | None = None,
369
+ mgn_mode: Literal["isolated", "cross"] | None = None,
370
+ ct_type: Literal["linear", "inverse"] | None = None,
371
+ type_: str | None = None,
372
+ sub_type: str | None = None,
373
+ after: str | None = None,
374
+ before: str | None = None,
375
+ begin: int | None = None,
376
+ end: int | None = None,
377
+ limit: int | None = None,
378
+ ) -> dict:
379
+ """Получение выписок за последние 3 месяца.
380
+
381
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-bills-details-last-3-months
382
+ """
383
+ params = {
384
+ "instType": inst_type,
385
+ "instId": inst_id,
386
+ "ccy": ccy,
387
+ "mgnMode": mgn_mode,
388
+ "ctType": ct_type,
389
+ "type": type_,
390
+ "subType": sub_type,
391
+ "after": after,
392
+ "before": before,
393
+ "begin": begin,
394
+ "end": end,
395
+ "limit": limit,
396
+ }
397
+
398
+ return await self._make_request(
399
+ "GET",
400
+ endpoint="/api/v5/account/bills-archive",
401
+ params=params,
402
+ signed=True,
403
+ )
404
+
405
+ async def apply_bills_history_archive(
406
+ self, year: str, quarter: Literal["Q1", "Q2", "Q3", "Q4"]
407
+ ) -> dict:
408
+ """Запрос на формирование архива выписок.
409
+
410
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-apply-bills-details-since-2021
411
+ """
412
+ data = {
413
+ "year": year,
414
+ "quarter": quarter,
415
+ }
416
+
417
+ return await self._make_request(
418
+ "POST",
419
+ endpoint="/api/v5/account/bills-history-archive",
420
+ data=data,
421
+ signed=True,
422
+ )
423
+
424
+ async def get_bills_history_archive(
425
+ self, year: str, quarter: Literal["Q1", "Q2", "Q3", "Q4"]
426
+ ) -> dict:
427
+ """Получение ссылки на архив выписок.
428
+
429
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-bills-details-since-2021
430
+ """
431
+ params = {
432
+ "year": year,
433
+ "quarter": quarter,
434
+ }
435
+
436
+ return await self._make_request(
437
+ "GET",
438
+ endpoint="/api/v5/account/bills-history-archive",
439
+ params=params,
440
+ signed=True,
441
+ )
442
+
443
+ async def get_account_config(self) -> dict:
444
+ """Получение конфигурации аккаунта.
445
+
446
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-account-configuration
447
+ """
448
+ return await self._make_request(
449
+ "GET",
450
+ endpoint="/api/v5/account/config",
451
+ signed=True,
452
+ )
453
+
454
+ async def set_position_mode(self, pos_mode: Literal["long_short_mode", "net_mode"]) -> dict:
455
+ """Изменение режима позиций.
456
+
457
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-set-position-mode
458
+ """
459
+ data = {
460
+ "posMode": pos_mode,
461
+ }
462
+
463
+ return await self._make_request(
464
+ "POST",
465
+ endpoint="/api/v5/account/set-position-mode",
466
+ data=data,
467
+ signed=True,
468
+ )
469
+
470
+ async def set_leverage(
471
+ self,
472
+ lever: str,
473
+ mgn_mode: Literal["isolated", "cross"],
474
+ inst_id: str | None = None,
475
+ ccy: str | None = None,
476
+ pos_side: Literal["long", "short"] | None = None,
477
+ ) -> dict:
478
+ """Установка плеча.
479
+
480
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-set-leverage
481
+ """
482
+ data = {
483
+ "instId": inst_id,
484
+ "ccy": ccy,
485
+ "lever": lever,
486
+ "mgnMode": mgn_mode,
487
+ "posSide": pos_side,
488
+ }
489
+
490
+ return await self._make_request(
491
+ "POST",
492
+ endpoint="/api/v5/account/set-leverage",
493
+ data=data,
494
+ signed=True,
495
+ )
496
+
497
+ async def get_max_order_size(
498
+ self,
499
+ inst_id: str,
500
+ td_mode: Literal["cross", "isolated", "cash", "spot_isolated"],
501
+ ccy: str | None = None,
502
+ px: str | None = None,
503
+ leverage: str | None = None,
504
+ trade_quote_ccy: str | None = None,
505
+ ) -> dict:
506
+ """Получение максимального размера ордера.
507
+
508
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-maximum-order-quantity
509
+ """
510
+ params = {
511
+ "instId": inst_id,
512
+ "tdMode": td_mode,
513
+ "ccy": ccy,
514
+ "px": px,
515
+ "leverage": leverage,
516
+ "tradeQuoteCcy": trade_quote_ccy,
517
+ }
518
+
519
+ return await self._make_request(
520
+ "GET",
521
+ endpoint="/api/v5/account/max-size",
522
+ params=params,
523
+ signed=True,
524
+ )
525
+
526
+ async def get_max_avail_size(
527
+ self,
528
+ inst_id: str,
529
+ td_mode: Literal["cross", "isolated", "cash", "spot_isolated"],
530
+ ccy: str | None = None,
531
+ reduce_only: bool | None = None,
532
+ px: str | None = None,
533
+ trade_quote_ccy: str | None = None,
534
+ ) -> dict:
535
+ """Получение максимального доступного баланса/эквити.
536
+
537
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-maximum-available-balance-equity
538
+ """
539
+ params = {
540
+ "instId": inst_id,
541
+ "ccy": ccy,
542
+ "tdMode": td_mode,
543
+ "reduceOnly": reduce_only,
544
+ "px": px,
545
+ "tradeQuoteCcy": trade_quote_ccy,
546
+ }
547
+
548
+ return await self._make_request(
549
+ "GET",
550
+ endpoint="/api/v5/account/max-avail-size",
551
+ params=params,
552
+ signed=True,
553
+ )
554
+
555
+ async def adjustment_margin(
556
+ self,
557
+ inst_id: str,
558
+ pos_side: Literal["long", "short", "net"],
559
+ type_: Literal["add", "reduce"],
560
+ amt: str,
561
+ ccy: str | None = None,
562
+ ) -> dict:
563
+ """Изменение маржи изолированной позиции.
564
+
565
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-increase-decrease-margin
566
+ """
567
+ data = {
568
+ "instId": inst_id,
569
+ "posSide": pos_side,
570
+ "type": type_,
571
+ "amt": amt,
572
+ "ccy": ccy,
573
+ }
574
+
575
+ return await self._make_request(
576
+ "POST",
577
+ endpoint="/api/v5/account/position/margin-balance",
578
+ data=data,
579
+ signed=True,
580
+ )
581
+
582
+ async def get_leverage(
583
+ self,
584
+ mgn_mode: Literal["isolated", "cross"],
585
+ inst_id: str | None = None,
586
+ ccy: str | None = None,
587
+ ) -> dict:
588
+ """Получение текущего плеча.
589
+
590
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-leverage
591
+ """
592
+ params = {
593
+ "instId": inst_id,
594
+ "ccy": ccy,
595
+ "mgnMode": mgn_mode,
596
+ }
597
+
598
+ return await self._make_request(
599
+ "GET",
600
+ endpoint="/api/v5/account/leverage-info",
601
+ params=params,
602
+ signed=True,
603
+ )
604
+
605
+ async def get_leverage_estimated_info(
606
+ self,
607
+ inst_type: Literal["MARGIN", "SWAP", "FUTURES"],
608
+ mgn_mode: Literal["isolated", "cross"],
609
+ lever: str,
610
+ inst_id: str | None = None,
611
+ ccy: str | None = None,
612
+ pos_side: Literal["net", "long", "short"] | None = None,
613
+ ) -> dict:
614
+ """Получение оценочных данных по плечу.
615
+
616
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-leverage-estimated-info
617
+ """
618
+ params = {
619
+ "instType": inst_type,
620
+ "mgnMode": mgn_mode,
621
+ "lever": lever,
622
+ "instId": inst_id,
623
+ "ccy": ccy,
624
+ "posSide": pos_side,
625
+ }
626
+
627
+ return await self._make_request(
628
+ "GET",
629
+ endpoint="/api/v5/account/adjust-leverage-info",
630
+ params=params,
631
+ signed=True,
632
+ )
633
+
634
+ async def get_max_loan(
635
+ self,
636
+ mgn_mode: Literal["isolated", "cross"],
637
+ inst_id: str | None = None,
638
+ ccy: str | None = None,
639
+ mgn_ccy: str | None = None,
640
+ trade_quote_ccy: str | None = None,
641
+ ) -> dict:
642
+ """Получение максимального объема заимствования.
643
+
644
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-the-maximum-loan-of-instrument
645
+ """
646
+ params = {
647
+ "mgnMode": mgn_mode,
648
+ "instId": inst_id,
649
+ "ccy": ccy,
650
+ "mgnCcy": mgn_ccy,
651
+ "tradeQuoteCcy": trade_quote_ccy,
652
+ }
653
+
654
+ return await self._make_request(
655
+ "GET",
656
+ endpoint="/api/v5/account/max-loan",
657
+ params=params,
658
+ signed=True,
659
+ )
660
+
661
+ async def get_fee_rates(
662
+ self,
663
+ inst_type: Literal["SPOT", "MARGIN", "SWAP", "FUTURES", "OPTION"],
664
+ inst_id: str | None = None,
665
+ inst_family: str | None = None,
666
+ rule_type: Literal["normal", "pre_market"] | None = None,
667
+ ) -> dict:
668
+ """Получение торговых комиссий.
669
+
670
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-fee-rates
671
+ """
672
+ params = {
673
+ "instType": inst_type,
674
+ "instId": inst_id,
675
+ "instFamily": inst_family,
676
+ "ruleType": rule_type,
677
+ }
678
+
679
+ return await self._make_request(
680
+ "GET",
681
+ endpoint="/api/v5/account/trade-fee",
682
+ params=params,
683
+ signed=True,
684
+ )
685
+
686
+ async def get_interest_accrued(
687
+ self,
688
+ type_: str | None = None,
689
+ ccy: str | None = None,
690
+ inst_id: str | None = None,
691
+ mgn_mode: Literal["cross", "isolated"] | None = None,
692
+ after: int | None = None,
693
+ before: int | None = None,
694
+ limit: int | None = None,
695
+ ) -> dict:
696
+ """Получение данных по начисленным процентам.
697
+
698
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-interest-accrued-data
699
+ """
700
+ params = {
701
+ "type": type_,
702
+ "ccy": ccy,
703
+ "instId": inst_id,
704
+ "mgnMode": mgn_mode,
705
+ "after": after,
706
+ "before": before,
707
+ "limit": limit,
708
+ }
709
+
710
+ return await self._make_request(
711
+ "GET",
712
+ endpoint="/api/v5/account/interest-accrued",
713
+ params=params,
714
+ signed=True,
715
+ )
716
+
717
+ async def get_interest_rate(self, ccy: str | None = None) -> dict:
718
+ """Получение текущих процентных ставок.
719
+
720
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-interest-rate
721
+ """
722
+ params = {
723
+ "ccy": ccy,
724
+ }
725
+
726
+ return await self._make_request(
727
+ "GET",
728
+ endpoint="/api/v5/account/interest-rate",
729
+ params=params,
730
+ signed=True,
731
+ )
732
+
733
+ async def set_fee_type(self, fee_type: Literal["0", "1"]) -> dict:
734
+ """Настройка типа комиссии.
735
+
736
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-set-fee-type
737
+ """
738
+ data = {
739
+ "feeType": fee_type,
740
+ }
741
+
742
+ return await self._make_request(
743
+ "POST",
744
+ endpoint="/api/v5/account/set-fee-type",
745
+ data=data,
746
+ signed=True,
747
+ )
748
+
749
+ async def set_greeks(self, greeks_type: Literal["PA", "BS"]) -> dict:
750
+ """Настройка формата греков.
751
+
752
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-set-greeks-pa-bs
753
+ """
754
+ data = {
755
+ "greeksType": greeks_type,
756
+ }
757
+
758
+ return await self._make_request(
759
+ "POST",
760
+ endpoint="/api/v5/account/set-greeks",
761
+ data=data,
762
+ signed=True,
763
+ )
764
+
765
+ async def set_isolated_mode(
766
+ self,
767
+ iso_mode: Literal["auto_transfers_ccy", "automatic"],
768
+ type_: Literal["MARGIN", "CONTRACTS"],
769
+ ) -> dict:
770
+ """Настройка режима изолированной маржи.
771
+
772
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-isolated-margin-trading-settings
773
+ """
774
+ data = {
775
+ "isoMode": iso_mode,
776
+ "type": type_,
777
+ }
778
+
779
+ return await self._make_request(
780
+ "POST",
781
+ endpoint="/api/v5/account/set-isolated-mode",
782
+ data=data,
783
+ signed=True,
784
+ )
785
+
786
+ async def get_max_withdrawal(self, ccy: str | None = None) -> dict:
787
+ """Получение максимальной суммы вывода из трейдингового аккаунта.
788
+
789
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-maximum-withdrawals
790
+ """
791
+ params = {
792
+ "ccy": ccy,
793
+ }
794
+
795
+ return await self._make_request(
796
+ "GET",
797
+ endpoint="/api/v5/account/max-withdrawal",
798
+ params=params,
799
+ signed=True,
800
+ )
801
+
802
+ async def get_risk_state(self) -> dict:
803
+ """Получение статуса рисков аккаунта.
804
+
805
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-account-risk-state
806
+ """
807
+ return await self._make_request(
808
+ "GET",
809
+ endpoint="/api/v5/account/risk-state",
810
+ signed=True,
811
+ )
812
+
813
+ async def get_interest_limits(
814
+ self,
815
+ type_: str | None = None,
816
+ ccy: str | None = None,
817
+ ) -> dict:
818
+ """Получение лимитов и процентов заимствования.
819
+
820
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-borrow-interest-and-limit
821
+ """
822
+ params = {
823
+ "type": type_,
824
+ "ccy": ccy,
825
+ }
826
+
827
+ return await self._make_request(
828
+ "GET",
829
+ endpoint="/api/v5/account/interest-limits",
830
+ params=params,
831
+ signed=True,
832
+ )
833
+
834
+ async def spot_manual_borrow_repay(
835
+ self, ccy: str, side: Literal["borrow", "repay"], amt: str
836
+ ) -> dict:
837
+ """Ручное заимствование или погашение в спотовом режиме.
838
+
839
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-manual-borrow-repay
840
+ """
841
+ data = {
842
+ "ccy": ccy,
843
+ "side": side,
844
+ "amt": amt,
845
+ }
846
+
847
+ return await self._make_request(
848
+ "POST",
849
+ endpoint="/api/v5/account/spot-manual-borrow-repay",
850
+ data=data,
851
+ signed=True,
852
+ )
853
+
854
+ async def set_auto_repay(self, auto_repay: bool) -> dict:
855
+ """Настройка автоматического погашения в спотовом режиме.
856
+
857
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-set-auto-repay
858
+ """
859
+ data = {
860
+ "autoRepay": auto_repay,
861
+ }
862
+
863
+ return await self._make_request(
864
+ "POST",
865
+ endpoint="/api/v5/account/set-auto-repay",
866
+ data=data,
867
+ signed=True,
868
+ )
869
+
870
+ async def spot_borrow_repay_history(
871
+ self,
872
+ ccy: str | None = None,
873
+ type_: Literal["auto_borrow", "auto_repay", "manual_borrow", "manual_repay"] | None = None,
874
+ after: int | None = None,
875
+ before: int | None = None,
876
+ limit: int | None = None,
877
+ ) -> dict:
878
+ """Получение истории заимствований и погашений в спотовом режиме.
879
+
880
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-borrow-repay-history
881
+ """
882
+ params = {
883
+ "ccy": ccy,
884
+ "type": type_,
885
+ "after": after,
886
+ "before": before,
887
+ "limit": limit,
888
+ }
889
+
890
+ return await self._make_request(
891
+ "GET",
892
+ endpoint="/api/v5/account/spot-borrow-repay-history",
893
+ params=params,
894
+ signed=True,
895
+ )
896
+
897
+ async def position_builder(
898
+ self,
899
+ acct_lv: str | None = None,
900
+ incl_real_pos_and_eq: bool | None = None,
901
+ lever: str | None = None,
902
+ sim_pos: list[dict[str, Any]] | None = None,
903
+ sim_asset: list[dict[str, Any]] | None = None,
904
+ greeks_type: Literal["BS", "PA", "CASH"] | None = None,
905
+ idx_vol: str | None = None,
906
+ ) -> dict:
907
+ """Расчет параметров портфеля с виртуальными позициями.
908
+
909
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-position-builder-new
910
+ """
911
+ data = {
912
+ "acctLv": acct_lv,
913
+ "inclRealPosAndEq": incl_real_pos_and_eq,
914
+ "lever": lever,
915
+ "simPos": sim_pos,
916
+ "simAsset": sim_asset,
917
+ "greeksType": greeks_type,
918
+ "idxVol": idx_vol,
919
+ }
920
+
921
+ return await self._make_request(
922
+ "POST",
923
+ endpoint="/api/v5/account/position-builder",
924
+ data=data,
925
+ signed=True,
926
+ )
927
+
928
+ async def position_builder_graph(
929
+ self,
930
+ type_: Literal["mmr"],
931
+ incl_real_pos_and_eq: bool | None = None,
932
+ sim_pos: list[dict[str, Any]] | None = None,
933
+ sim_asset: list[dict[str, Any]] | None = None,
934
+ greeks_type: Literal["BS", "PA", "CASH"] | None = None,
935
+ mmr_config: dict[str, Any] | None = None,
936
+ ) -> dict:
937
+ """Расчет графика тренда риск-параметров.
938
+
939
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-position-builder-trend-graph
940
+ """
941
+ data = {
942
+ "inclRealPosAndEq": incl_real_pos_and_eq,
943
+ "simPos": sim_pos,
944
+ "simAsset": sim_asset,
945
+ "greeksType": greeks_type,
946
+ "type": type_,
947
+ "mmrConfig": mmr_config,
948
+ }
949
+
950
+ return await self._make_request(
951
+ "POST",
952
+ endpoint="/api/v5/account/position-builder-graph",
953
+ data=data,
954
+ signed=True,
955
+ )
956
+
957
+ async def set_risk_offset_amount(self, ccy: str, cl_spot_in_use_amt: str) -> dict:
958
+ """Установка величины спотового риск-офсета.
959
+
960
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-set-risk-offset-amount
961
+ """
962
+ data = {
963
+ "ccy": ccy,
964
+ "clSpotInUseAmt": cl_spot_in_use_amt,
965
+ }
966
+
967
+ return await self._make_request(
968
+ "POST",
969
+ endpoint="/api/v5/account/set-riskOffset-amt",
970
+ data=data,
971
+ signed=True,
972
+ )
973
+
974
+ async def get_greeks(self, ccy: str | None = None) -> dict:
975
+ """Получение греков по активам.
976
+
977
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-greeks
978
+ """
979
+ params = {
980
+ "ccy": ccy,
981
+ }
982
+
983
+ return await self._make_request(
984
+ "GET",
985
+ endpoint="/api/v5/account/greeks",
986
+ params=params,
987
+ signed=True,
988
+ )
989
+
990
+ async def get_account_position_tiers(
991
+ self,
992
+ inst_type: Literal["SWAP", "FUTURES", "OPTION"],
993
+ inst_family: str,
994
+ uly: str | None = None,
995
+ ) -> dict:
996
+ """Получение лимитов позиций в PM режиме.
997
+
998
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-pm-position-limitation
999
+ """
1000
+ params = {
1001
+ "instType": inst_type,
1002
+ "instFamily": inst_family,
1003
+ "uly": uly,
1004
+ }
1005
+
1006
+ return await self._make_request(
1007
+ "GET",
1008
+ endpoint="/api/v5/account/position-tiers",
1009
+ params=params,
1010
+ signed=True,
1011
+ )
1012
+
1013
+ async def activate_option(self) -> dict:
1014
+ """Активация торговли опционами.
1015
+
1016
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-activate-option
1017
+ """
1018
+ return await self._make_request(
1019
+ "POST",
1020
+ endpoint="/api/v5/account/activate-option",
1021
+ data={},
1022
+ signed=True,
1023
+ )
1024
+
1025
+ async def set_auto_loan(self, auto_loan: bool | None = None) -> dict:
1026
+ """Настройка автоматического заимствования.
1027
+
1028
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-set-auto-loan
1029
+ """
1030
+ data = {
1031
+ "autoLoan": auto_loan,
1032
+ }
1033
+
1034
+ return await self._make_request(
1035
+ "POST",
1036
+ endpoint="/api/v5/account/set-auto-loan",
1037
+ data=data,
1038
+ signed=True,
1039
+ )
1040
+
1041
+ async def account_level_switch_preset(
1042
+ self, acct_lv: Literal["2", "3", "4"], lever: str | None = None
1043
+ ) -> dict:
1044
+ """Преднастройка смены режима аккаунта.
1045
+
1046
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-preset-account-mode-switch
1047
+ """
1048
+ data = {
1049
+ "acctLv": acct_lv,
1050
+ "lever": lever,
1051
+ }
1052
+
1053
+ return await self._make_request(
1054
+ "POST",
1055
+ endpoint="/api/v5/account/account-level-switch-preset",
1056
+ data=data,
1057
+ signed=True,
1058
+ )
1059
+
1060
+ async def get_account_switch_precheck(self, acct_lv: Literal["1", "2", "3", "4"]) -> dict:
1061
+ """Предварительная проверка смены режима аккаунта.
1062
+
1063
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-precheck-account-mode-switch
1064
+ """
1065
+ params = {
1066
+ "acctLv": acct_lv,
1067
+ }
1068
+
1069
+ return await self._make_request(
1070
+ "GET",
1071
+ endpoint="/api/v5/account/set-account-switch-precheck",
1072
+ params=params,
1073
+ signed=True,
1074
+ )
1075
+
1076
+ async def set_account_level(self, acct_lv: Literal["1", "2", "3", "4"]) -> dict:
1077
+ """Смена режима аккаунта.
1078
+
1079
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-set-account-mode
1080
+ """
1081
+ data = {
1082
+ "acctLv": acct_lv,
1083
+ }
1084
+
1085
+ return await self._make_request(
1086
+ "POST",
1087
+ endpoint="/api/v5/account/set-account-level",
1088
+ data=data,
1089
+ signed=True,
1090
+ )
1091
+
1092
+ async def set_collateral_assets(
1093
+ self,
1094
+ type_: Literal["all", "custom"],
1095
+ collateral_enabled: bool,
1096
+ ccy_list: list[str] | None = None,
1097
+ ) -> dict:
1098
+ """Настройка списка коллатеральных активов.
1099
+
1100
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-set-collateral-assets
1101
+ """
1102
+ data = {
1103
+ "type": type_,
1104
+ "collateralEnabled": collateral_enabled,
1105
+ "ccyList": ccy_list,
1106
+ }
1107
+
1108
+ return await self._make_request(
1109
+ "POST",
1110
+ endpoint="/api/v5/account/set-collateral-assets",
1111
+ data=data,
1112
+ signed=True,
1113
+ )
1114
+
1115
+ async def get_collateral_assets(
1116
+ self, ccy: str | None = None, collateral_enabled: bool | None = None
1117
+ ) -> dict:
1118
+ """Получение списка коллатеральных активов.
1119
+
1120
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-collateral-assets
1121
+ """
1122
+ params = {
1123
+ "ccy": ccy,
1124
+ "collateralEnabled": collateral_enabled,
1125
+ }
1126
+
1127
+ return await self._make_request(
1128
+ "GET",
1129
+ endpoint="/api/v5/account/collateral-assets",
1130
+ params=params,
1131
+ signed=True,
1132
+ )
1133
+
1134
+ async def reset_mmp_status(
1135
+ self, inst_family: str, inst_type: Literal["OPTION"] | None = None
1136
+ ) -> dict:
1137
+ """Сброс статуса MMP.
1138
+
1139
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-reset-mmp-status
1140
+ """
1141
+ data = {
1142
+ "instType": inst_type,
1143
+ "instFamily": inst_family,
1144
+ }
1145
+
1146
+ return await self._make_request(
1147
+ "POST",
1148
+ endpoint="/api/v5/account/mmp-reset",
1149
+ data=data,
1150
+ signed=True,
1151
+ )
1152
+
1153
+ async def set_mmp(
1154
+ self,
1155
+ inst_family: str,
1156
+ time_interval: str,
1157
+ frozen_interval: str,
1158
+ qty_limit: str,
1159
+ ) -> dict:
1160
+ """Настройка параметров MMP.
1161
+
1162
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-set-mmp
1163
+ """
1164
+ data = {
1165
+ "instFamily": inst_family,
1166
+ "timeInterval": time_interval,
1167
+ "frozenInterval": frozen_interval,
1168
+ "qtyLimit": qty_limit,
1169
+ }
1170
+
1171
+ return await self._make_request(
1172
+ "POST",
1173
+ endpoint="/api/v5/account/mmp-config",
1174
+ data=data,
1175
+ signed=True,
1176
+ )
1177
+
1178
+ async def get_mmp_config(self, inst_family: str | None = None) -> dict:
1179
+ """Получение настроек MMP.
1180
+
1181
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-mmp-config
1182
+ """
1183
+ params = {
1184
+ "instFamily": inst_family,
1185
+ }
1186
+
1187
+ return await self._make_request(
1188
+ "GET",
1189
+ endpoint="/api/v5/account/mmp-config",
1190
+ params=params,
1191
+ signed=True,
1192
+ )
1193
+
1194
+ async def move_positions(
1195
+ self,
1196
+ from_acct: str,
1197
+ to_acct: str,
1198
+ legs: list[dict[str, Any]],
1199
+ client_id: str,
1200
+ ) -> dict:
1201
+ """Перемещение позиций между аккаунтами.
1202
+
1203
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-move-positions
1204
+ """
1205
+ data = {
1206
+ "fromAcct": from_acct,
1207
+ "toAcct": to_acct,
1208
+ "legs": legs,
1209
+ "clientId": client_id,
1210
+ }
1211
+
1212
+ return await self._make_request(
1213
+ "POST",
1214
+ endpoint="/api/v5/account/move-positions",
1215
+ data=data,
1216
+ signed=True,
1217
+ )
1218
+
1219
+ async def get_move_positions_history(
1220
+ self,
1221
+ block_td_id: str | None = None,
1222
+ client_id: str | None = None,
1223
+ begin_ts: int | None = None,
1224
+ end_ts: int | None = None,
1225
+ limit: int | None = None,
1226
+ state: Literal["filled", "pending"] | None = None,
1227
+ ) -> dict:
1228
+ """Получение истории перемещения позиций.
1229
+
1230
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-move-positions-history
1231
+ """
1232
+ params = {
1233
+ "blockTdId": block_td_id,
1234
+ "clientId": client_id,
1235
+ "beginTs": begin_ts,
1236
+ "endTs": end_ts,
1237
+ "limit": limit,
1238
+ "state": state,
1239
+ }
1240
+
1241
+ return await self._make_request(
1242
+ "GET",
1243
+ endpoint="/api/v5/account/move-positions-history",
1244
+ params=params,
1245
+ signed=True,
1246
+ )
1247
+
1248
+ async def set_auto_earn(
1249
+ self,
1250
+ ccy: str,
1251
+ action: Literal["turn_on", "turn_off"],
1252
+ earn_type: Literal["0", "1"] | None = None,
1253
+ ) -> dict:
1254
+ """Настройка автоматического Earn.
1255
+
1256
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-set-auto-earn
1257
+ """
1258
+ data = {
1259
+ "earnType": earn_type,
1260
+ "ccy": ccy,
1261
+ "action": action,
1262
+ }
1263
+
1264
+ return await self._make_request(
1265
+ "POST",
1266
+ endpoint="/api/v5/account/set-auto-earn",
1267
+ data=data,
1268
+ signed=True,
1269
+ )
1270
+
1271
+ async def set_settle_currency(self, settle_ccy: str) -> dict:
1272
+ """Настройка расчетной валюты для USD-маржинальных контрактов.
1273
+
1274
+ https://www.okx.com/docs-v5/en/#trading-account-rest-api-set-settle-currency
1275
+ """
1276
+ data = {
1277
+ "settleCcy": settle_ccy,
1278
+ }
1279
+
1280
+ return await self._make_request(
1281
+ "POST",
1282
+ endpoint="/api/v5/account/set-settle-currency",
1283
+ data=data,
1284
+ signed=True,
1285
+ )
1286
+
1287
+ # topic: Order Book Trading (Trade)
1288
+
1289
+ async def place_order(
1290
+ self,
1291
+ inst_id: str,
1292
+ td_mode: Literal["cross", "isolated", "cash", "spot_isolated"],
1293
+ side: Literal["buy", "sell"],
1294
+ ord_type: Literal[
1295
+ "market",
1296
+ "limit",
1297
+ "post_only",
1298
+ "fok",
1299
+ "ioc",
1300
+ "optimal_limit_ioc",
1301
+ "mmp",
1302
+ "mmp_and_post_only",
1303
+ "op_fok",
1304
+ ],
1305
+ sz: str,
1306
+ ccy: str | None = None,
1307
+ cl_ord_id: str | None = None,
1308
+ tag: str | None = None,
1309
+ pos_side: Literal["net", "long", "short"] | None = None,
1310
+ px: str | None = None,
1311
+ px_usd: str | None = None,
1312
+ px_vol: str | None = None,
1313
+ reduce_only: bool | None = None,
1314
+ tgt_ccy: Literal["base_ccy", "quote_ccy"] | None = None,
1315
+ ban_amend: bool | None = None,
1316
+ px_amend_type: Literal["0", "1"] | None = None,
1317
+ trade_quote_ccy: str | None = None,
1318
+ stp_mode: Literal["cancel_maker", "cancel_taker", "cancel_both"] | None = None,
1319
+ quick_mgn_type: str | None = None,
1320
+ attach_algo_orders: list[dict[str, Any]] | None = None,
1321
+ extra_params: dict[str, Any] | None = None,
1322
+ ) -> dict:
1323
+ """Создание ордера.
1324
+
1325
+ https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-place-order
1326
+ """
1327
+ data: dict[str, Any] = {
1328
+ "instId": inst_id,
1329
+ "tdMode": td_mode,
1330
+ "side": side,
1331
+ "ordType": ord_type,
1332
+ "sz": sz,
1333
+ "ccy": ccy,
1334
+ "clOrdId": cl_ord_id,
1335
+ "tag": tag,
1336
+ "posSide": pos_side,
1337
+ "px": px,
1338
+ "pxUsd": px_usd,
1339
+ "pxVol": px_vol,
1340
+ "reduceOnly": reduce_only,
1341
+ "tgtCcy": tgt_ccy,
1342
+ "banAmend": ban_amend,
1343
+ "pxAmendType": px_amend_type,
1344
+ "tradeQuoteCcy": trade_quote_ccy,
1345
+ "stpMode": stp_mode,
1346
+ "quickMgnType": quick_mgn_type,
1347
+ }
1348
+ if attach_algo_orders is not None:
1349
+ data["attachAlgoOrds"] = [filter_params(order) for order in attach_algo_orders]
1350
+ if extra_params:
1351
+ data.update(extra_params)
1352
+
1353
+ return await self._make_request(
1354
+ "POST",
1355
+ endpoint="/api/v5/trade/order",
1356
+ data=filter_params(data),
1357
+ signed=True,
1358
+ )
1359
+
1360
+ async def place_multiple_orders(self, orders: list[dict[str, Any]]) -> dict:
1361
+ """Создание ордеров пакетно.
1362
+
1363
+ https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-place-multiple-orders
1364
+ """
1365
+ data = [filter_params(order) for order in orders]
1366
+
1367
+ return await self._make_request(
1368
+ "POST",
1369
+ endpoint="/api/v5/trade/batch-orders",
1370
+ data=data, # type: ignore
1371
+ signed=True,
1372
+ )
1373
+
1374
+ async def cancel_order(
1375
+ self,
1376
+ inst_id: str,
1377
+ ord_id: str | None = None,
1378
+ cl_ord_id: str | None = None,
1379
+ ) -> dict:
1380
+ """Отмена ордера.
1381
+
1382
+ https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-cancel-order
1383
+ """
1384
+ if not ord_id and not cl_ord_id:
1385
+ raise ValueError("Either ord_id or cl_ord_id must be provided")
1386
+
1387
+ data = filter_params(
1388
+ {
1389
+ "instId": inst_id,
1390
+ "ordId": ord_id,
1391
+ "clOrdId": cl_ord_id,
1392
+ }
1393
+ )
1394
+
1395
+ return await self._make_request(
1396
+ "POST",
1397
+ endpoint="/api/v5/trade/cancel-order",
1398
+ data=data,
1399
+ signed=True,
1400
+ )
1401
+
1402
+ async def cancel_multiple_orders(self, orders: list[dict[str, Any]]) -> dict:
1403
+ """Отмена ордеров пакетно.
1404
+
1405
+ https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-cancel-multiple-orders
1406
+ """
1407
+ data = [filter_params(order) for order in orders]
1408
+
1409
+ return await self._make_request(
1410
+ "POST",
1411
+ endpoint="/api/v5/trade/cancel-batch-orders",
1412
+ data=data, # type: ignore
1413
+ signed=True,
1414
+ )
1415
+
1416
+ async def amend_order(
1417
+ self,
1418
+ inst_id: str,
1419
+ ord_id: str | None = None,
1420
+ cl_ord_id: str | None = None,
1421
+ *,
1422
+ new_sz: str | None = None,
1423
+ new_px: str | None = None,
1424
+ new_px_usd: str | None = None,
1425
+ new_px_vol: str | None = None,
1426
+ cxl_on_fail: bool | None = None,
1427
+ req_id: str | None = None,
1428
+ px_amend_type: Literal["0", "1"] | None = None,
1429
+ attach_algo_orders: list[dict[str, Any]] | None = None,
1430
+ extra_params: dict[str, Any] | None = None,
1431
+ ) -> dict:
1432
+ """Изменение параметров ордера.
1433
+
1434
+ https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-amend-order
1435
+ """
1436
+ if not ord_id and not cl_ord_id:
1437
+ raise ValueError("Either ord_id or cl_ord_id must be provided")
1438
+
1439
+ data: dict[str, Any] = {
1440
+ "instId": inst_id,
1441
+ "ordId": ord_id,
1442
+ "clOrdId": cl_ord_id,
1443
+ "newSz": new_sz,
1444
+ "newPx": new_px,
1445
+ "newPxUsd": new_px_usd,
1446
+ "newPxVol": new_px_vol,
1447
+ "cxlOnFail": cxl_on_fail,
1448
+ "reqId": req_id,
1449
+ "pxAmendType": px_amend_type,
1450
+ }
1451
+ if attach_algo_orders is not None:
1452
+ data["attachAlgoOrds"] = [filter_params(order) for order in attach_algo_orders]
1453
+ if extra_params:
1454
+ data.update(extra_params)
1455
+
1456
+ return await self._make_request(
1457
+ "POST",
1458
+ endpoint="/api/v5/trade/amend-order",
1459
+ data=filter_params(data),
1460
+ signed=True,
1461
+ )
1462
+
1463
+ async def amend_multiple_orders(self, orders: list[dict[str, Any]]) -> dict:
1464
+ """Изменение параметров ордеров пакетно.
1465
+
1466
+ https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-amend-multiple-orders
1467
+ """
1468
+ data = [filter_params(order) for order in orders]
1469
+
1470
+ return await self._make_request(
1471
+ "POST",
1472
+ endpoint="/api/v5/trade/amend-batch-orders",
1473
+ data=data, # type: ignore
1474
+ signed=True,
1475
+ )
1476
+
1477
+ async def close_positions(
1478
+ self,
1479
+ inst_id: str,
1480
+ mgn_mode: Literal["cross", "isolated"],
1481
+ pos_side: Literal["net", "long", "short"] | None = None,
1482
+ ccy: str | None = None,
1483
+ auto_cxl: bool | None = None,
1484
+ cl_ord_id: str | None = None,
1485
+ tag: str | None = None,
1486
+ extra_params: dict[str, Any] | None = None,
1487
+ ) -> dict:
1488
+ """Закрытие позиции рыночным ордером.
1489
+
1490
+ https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-close-positions
1491
+ """
1492
+ data: dict[str, Any] = {
1493
+ "instId": inst_id,
1494
+ "mgnMode": mgn_mode,
1495
+ "posSide": pos_side,
1496
+ "ccy": ccy,
1497
+ "autoCxl": auto_cxl,
1498
+ "clOrdId": cl_ord_id,
1499
+ "tag": tag,
1500
+ }
1501
+ if extra_params:
1502
+ data.update(extra_params)
1503
+
1504
+ return await self._make_request(
1505
+ "POST",
1506
+ endpoint="/api/v5/trade/close-position",
1507
+ data=filter_params(data),
1508
+ signed=True,
1509
+ )
1510
+
1511
+ async def get_order(
1512
+ self,
1513
+ inst_id: str,
1514
+ ord_id: str | None = None,
1515
+ cl_ord_id: str | None = None,
1516
+ ) -> dict:
1517
+ """Получение информации об ордере.
1518
+
1519
+ https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-order-details
1520
+ """
1521
+ if not ord_id and not cl_ord_id:
1522
+ raise ValueError("Either ord_id or cl_ord_id must be provided")
1523
+
1524
+ params = filter_params(
1525
+ {
1526
+ "instId": inst_id,
1527
+ "ordId": ord_id,
1528
+ "clOrdId": cl_ord_id,
1529
+ }
1530
+ )
1531
+
1532
+ return await self._make_request(
1533
+ "GET",
1534
+ endpoint="/api/v5/trade/order",
1535
+ params=params,
1536
+ signed=True,
1537
+ )
1538
+
1539
+ async def get_order_list(
1540
+ self,
1541
+ inst_type: str | None = None,
1542
+ inst_family: str | None = None,
1543
+ inst_id: str | None = None,
1544
+ ord_type: str | None = None,
1545
+ state: Literal["live", "partially_filled"] | None = None,
1546
+ after: str | None = None,
1547
+ before: str | None = None,
1548
+ limit: int | None = None,
1549
+ ) -> dict:
1550
+ """Получение списка активных ордеров.
1551
+
1552
+ https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-order-list
1553
+ """
1554
+ params = filter_params(
1555
+ {
1556
+ "instType": inst_type,
1557
+ "instFamily": inst_family,
1558
+ "instId": inst_id,
1559
+ "ordType": ord_type,
1560
+ "state": state,
1561
+ "after": after,
1562
+ "before": before,
1563
+ "limit": limit,
1564
+ }
1565
+ )
1566
+
1567
+ return await self._make_request(
1568
+ "GET",
1569
+ endpoint="/api/v5/trade/orders-pending",
1570
+ params=params,
1571
+ signed=True,
1572
+ )
1573
+
1574
+ async def get_orders_history(
1575
+ self,
1576
+ inst_type: str,
1577
+ inst_family: str | None = None,
1578
+ inst_id: str | None = None,
1579
+ ord_type: str | None = None,
1580
+ state: str | None = None,
1581
+ category: str | None = None,
1582
+ after: str | None = None,
1583
+ before: str | None = None,
1584
+ begin: int | None = None,
1585
+ end: int | None = None,
1586
+ limit: int | None = None,
1587
+ ) -> dict:
1588
+ """Получение истории ордеров за 7 дней.
1589
+
1590
+ https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-order-history-last-7-days
1591
+ """
1592
+ params = filter_params(
1593
+ {
1594
+ "instType": inst_type,
1595
+ "instFamily": inst_family,
1596
+ "instId": inst_id,
1597
+ "ordType": ord_type,
1598
+ "state": state,
1599
+ "category": category,
1600
+ "after": after,
1601
+ "before": before,
1602
+ "begin": begin,
1603
+ "end": end,
1604
+ "limit": limit,
1605
+ }
1606
+ )
1607
+
1608
+ return await self._make_request(
1609
+ "GET",
1610
+ endpoint="/api/v5/trade/orders-history",
1611
+ params=params,
1612
+ signed=True,
1613
+ )
1614
+
1615
+ async def get_orders_history_archive(
1616
+ self,
1617
+ inst_type: str,
1618
+ inst_family: str | None = None,
1619
+ inst_id: str | None = None,
1620
+ ord_type: str | None = None,
1621
+ state: str | None = None,
1622
+ category: str | None = None,
1623
+ after: str | None = None,
1624
+ before: str | None = None,
1625
+ begin: int | None = None,
1626
+ end: int | None = None,
1627
+ limit: int | None = None,
1628
+ ) -> dict:
1629
+ """Получение истории ордеров за 3 месяца.
1630
+
1631
+ https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-order-history-last-3-months
1632
+ """
1633
+ params = filter_params(
1634
+ {
1635
+ "instType": inst_type,
1636
+ "instFamily": inst_family,
1637
+ "instId": inst_id,
1638
+ "ordType": ord_type,
1639
+ "state": state,
1640
+ "category": category,
1641
+ "after": after,
1642
+ "before": before,
1643
+ "begin": begin,
1644
+ "end": end,
1645
+ "limit": limit,
1646
+ }
1647
+ )
1648
+
1649
+ return await self._make_request(
1650
+ "GET",
1651
+ endpoint="/api/v5/trade/orders-history-archive",
1652
+ params=params,
1653
+ signed=True,
1654
+ )
1655
+
1656
+ async def get_fills(
1657
+ self,
1658
+ inst_type: str | None = None,
1659
+ inst_family: str | None = None,
1660
+ inst_id: str | None = None,
1661
+ ord_id: str | None = None,
1662
+ sub_type: str | None = None,
1663
+ after: str | None = None,
1664
+ before: str | None = None,
1665
+ begin: int | None = None,
1666
+ end: int | None = None,
1667
+ limit: int | None = None,
1668
+ ) -> dict:
1669
+ """Получение сделок за 3 дня.
1670
+
1671
+ https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-transaction-details-last-3-days
1672
+ """
1673
+ params = filter_params(
1674
+ {
1675
+ "instType": inst_type,
1676
+ "instFamily": inst_family,
1677
+ "instId": inst_id,
1678
+ "ordId": ord_id,
1679
+ "subType": sub_type,
1680
+ "after": after,
1681
+ "before": before,
1682
+ "begin": begin,
1683
+ "end": end,
1684
+ "limit": limit,
1685
+ }
1686
+ )
1687
+
1688
+ return await self._make_request(
1689
+ "GET",
1690
+ endpoint="/api/v5/trade/fills",
1691
+ params=params,
1692
+ signed=True,
1693
+ )
1694
+
1695
+ async def get_fills_history(
1696
+ self,
1697
+ inst_type: str,
1698
+ inst_family: str | None = None,
1699
+ inst_id: str | None = None,
1700
+ ord_id: str | None = None,
1701
+ sub_type: str | None = None,
1702
+ after: str | None = None,
1703
+ before: str | None = None,
1704
+ begin: int | None = None,
1705
+ end: int | None = None,
1706
+ limit: int | None = None,
1707
+ ) -> dict:
1708
+ """Получение сделок за 3 месяца.
1709
+
1710
+ https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-transaction-details-last-3-months
1711
+ """
1712
+ params = filter_params(
1713
+ {
1714
+ "instType": inst_type,
1715
+ "instFamily": inst_family,
1716
+ "instId": inst_id,
1717
+ "ordId": ord_id,
1718
+ "subType": sub_type,
1719
+ "after": after,
1720
+ "before": before,
1721
+ "begin": begin,
1722
+ "end": end,
1723
+ "limit": limit,
1724
+ }
1725
+ )
1726
+
1727
+ return await self._make_request(
1728
+ "GET",
1729
+ endpoint="/api/v5/trade/fills-history",
1730
+ params=params,
1731
+ signed=True,
1732
+ )
1733
+
1734
+ async def get_easy_convert_currency_list(self, source: Literal["1", "2"] | None = None) -> dict:
1735
+ """Получение списка валют для Easy Convert.
1736
+
1737
+ https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-easy-convert-currency-list
1738
+ """
1739
+ params = filter_params({"source": source})
1740
+
1741
+ return await self._make_request(
1742
+ "GET",
1743
+ endpoint="/api/v5/trade/easy-convert-currency-list",
1744
+ params=params,
1745
+ signed=True,
1746
+ )
1747
+
1748
+ async def easy_convert(
1749
+ self,
1750
+ from_ccy: list[str],
1751
+ to_ccy: str,
1752
+ source: Literal["1", "2"] | None = None,
1753
+ ) -> dict:
1754
+ """Конвертация мелких остатков через Easy Convert.
1755
+
1756
+ https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-place-easy-convert
1757
+ """
1758
+ data = filter_params(
1759
+ {
1760
+ "fromCcy": from_ccy,
1761
+ "toCcy": to_ccy,
1762
+ "source": source,
1763
+ }
1764
+ )
1765
+
1766
+ return await self._make_request(
1767
+ "POST",
1768
+ endpoint="/api/v5/trade/easy-convert",
1769
+ data=data,
1770
+ signed=True,
1771
+ )
1772
+
1773
+ async def get_easy_convert_history(
1774
+ self,
1775
+ after: str | None = None,
1776
+ before: str | None = None,
1777
+ limit: int | None = None,
1778
+ ) -> dict:
1779
+ """Получение истории Easy Convert.
1780
+
1781
+ https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-easy-convert-history
1782
+ """
1783
+ params = filter_params(
1784
+ {
1785
+ "after": after,
1786
+ "before": before,
1787
+ "limit": limit,
1788
+ }
1789
+ )
1790
+
1791
+ return await self._make_request(
1792
+ "GET",
1793
+ endpoint="/api/v5/trade/easy-convert-history",
1794
+ params=params,
1795
+ signed=True,
1796
+ )
1797
+
1798
+ async def get_one_click_repay_currency_list(
1799
+ self,
1800
+ debt_type: Literal["cross", "isolated"] | None = None,
1801
+ ) -> dict:
1802
+ """Получение списка валют для One-click Repay.
1803
+
1804
+ https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-one-click-repay-currency-list
1805
+ """
1806
+ params = filter_params({"debtType": debt_type})
1807
+
1808
+ return await self._make_request(
1809
+ "GET",
1810
+ endpoint="/api/v5/trade/one-click-repay-currency-list",
1811
+ params=params,
1812
+ signed=True,
1813
+ )
1814
+
1815
+ async def trade_one_click_repay(
1816
+ self,
1817
+ debt_ccy: list[str],
1818
+ repay_ccy: str,
1819
+ ) -> dict:
1820
+ """Совершение One-click Repay.
1821
+
1822
+ https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-trade-one-click-repay
1823
+ """
1824
+ data = filter_params({"debtCcy": debt_ccy, "repayCcy": repay_ccy})
1825
+
1826
+ return await self._make_request(
1827
+ "POST",
1828
+ endpoint="/api/v5/trade/one-click-repay",
1829
+ data=data,
1830
+ signed=True,
1831
+ )
1832
+
1833
+ async def get_one_click_repay_history(
1834
+ self,
1835
+ after: str | None = None,
1836
+ before: str | None = None,
1837
+ limit: int | None = None,
1838
+ ) -> dict:
1839
+ """Получение истории One-click Repay.
1840
+
1841
+ https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-one-click-repay-history
1842
+ """
1843
+ params = filter_params(
1844
+ {
1845
+ "after": after,
1846
+ "before": before,
1847
+ "limit": limit,
1848
+ }
1849
+ )
1850
+
1851
+ return await self._make_request(
1852
+ "GET",
1853
+ endpoint="/api/v5/trade/one-click-repay-history",
1854
+ params=params,
1855
+ signed=True,
1856
+ )
1857
+
1858
+ async def get_one_click_repay_currency_list_v2(self) -> dict:
1859
+ """Получение списка валют для One-click Repay (v2).
1860
+
1861
+ https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-one-click-repay-currency-list-new
1862
+ """
1863
+ return await self._make_request(
1864
+ "GET",
1865
+ endpoint="/api/v5/trade/one-click-repay-currency-list-v2",
1866
+ signed=True,
1867
+ )
1868
+
1869
+ async def trade_one_click_repay_v2(
1870
+ self,
1871
+ debt_ccy: str,
1872
+ repay_ccy_list: list[str],
1873
+ ) -> dict:
1874
+ """Совершение One-click Repay (v2).
1875
+
1876
+ https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-trade-one-click-repay-new
1877
+ """
1878
+ data = filter_params({"debtCcy": debt_ccy, "repayCcyList": repay_ccy_list})
1879
+
1880
+ return await self._make_request(
1881
+ "POST",
1882
+ endpoint="/api/v5/trade/one-click-repay-v2",
1883
+ data=data,
1884
+ signed=True,
1885
+ )
1886
+
1887
+ async def get_one_click_repay_history_v2(
1888
+ self,
1889
+ after: str | None = None,
1890
+ before: str | None = None,
1891
+ limit: int | None = None,
1892
+ ) -> dict:
1893
+ """Получение истории One-click Repay (v2).
1894
+
1895
+ https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-one-click-repay-history-new
1896
+ """
1897
+ params = filter_params(
1898
+ {
1899
+ "after": after,
1900
+ "before": before,
1901
+ "limit": limit,
1902
+ }
1903
+ )
1904
+
1905
+ return await self._make_request(
1906
+ "GET",
1907
+ endpoint="/api/v5/trade/one-click-repay-history-v2",
1908
+ params=params,
1909
+ signed=True,
1910
+ )
1911
+
1912
+ async def mass_cancel_orders(
1913
+ self,
1914
+ inst_type: Literal["OPTION"],
1915
+ inst_family: str,
1916
+ lock_interval: str | None = None,
1917
+ ) -> dict:
1918
+ """Массовое снятие MMP-ордеров.
1919
+
1920
+ https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-mass-cancel-order
1921
+ """
1922
+ data = filter_params(
1923
+ {
1924
+ "instType": inst_type,
1925
+ "instFamily": inst_family,
1926
+ "lockInterval": lock_interval,
1927
+ }
1928
+ )
1929
+
1930
+ return await self._make_request(
1931
+ "POST",
1932
+ endpoint="/api/v5/trade/mass-cancel",
1933
+ data=data,
1934
+ signed=True,
1935
+ )
1936
+
1937
+ async def cancel_all_after(
1938
+ self,
1939
+ time_out: str,
1940
+ tag: str | None = None,
1941
+ ) -> dict:
1942
+ """Установка Cancel All After.
1943
+
1944
+ https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-cancel-all-after
1945
+ """
1946
+ data = filter_params({"timeOut": time_out, "tag": tag})
1947
+
1948
+ return await self._make_request(
1949
+ "POST",
1950
+ endpoint="/api/v5/trade/cancel-all-after",
1951
+ data=data,
1952
+ signed=True,
1953
+ )
1954
+
1955
+ async def get_account_rate_limit(self) -> dict:
1956
+ """Получение информации о лимитах запросов аккаунта.
1957
+
1958
+ https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-account-rate-limit
1959
+ """
1960
+ return await self._make_request(
1961
+ "GET",
1962
+ endpoint="/api/v5/trade/account-rate-limit",
1963
+ signed=True,
1964
+ )
1965
+
1966
+ async def order_precheck(
1967
+ self,
1968
+ inst_id: str,
1969
+ td_mode: Literal["cross", "isolated", "cash", "spot_isolated"],
1970
+ side: Literal["buy", "sell"],
1971
+ ord_type: Literal[
1972
+ "market",
1973
+ "limit",
1974
+ "post_only",
1975
+ "fok",
1976
+ "ioc",
1977
+ "optimal_limit_ioc",
1978
+ ],
1979
+ sz: str,
1980
+ pos_side: Literal["net", "long", "short"] | None = None,
1981
+ px: str | None = None,
1982
+ reduce_only: bool | None = None,
1983
+ tgt_ccy: Literal["base_ccy", "quote_ccy"] | None = None,
1984
+ attach_algo_orders: list[dict[str, Any]] | None = None,
1985
+ extra_params: dict[str, Any] | None = None,
1986
+ ) -> dict:
1987
+ """Превентивная проверка перед размещением ордера.
1988
+
1989
+ https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-order-precheck
1990
+ """
1991
+ data: dict[str, Any] = {
1992
+ "instId": inst_id,
1993
+ "tdMode": td_mode,
1994
+ "side": side,
1995
+ "ordType": ord_type,
1996
+ "sz": sz,
1997
+ "posSide": pos_side,
1998
+ "px": px,
1999
+ "reduceOnly": reduce_only,
2000
+ "tgtCcy": tgt_ccy,
2001
+ }
2002
+ if attach_algo_orders is not None:
2003
+ data["attachAlgoOrds"] = [filter_params(order) for order in attach_algo_orders]
2004
+ if extra_params:
2005
+ data.update(extra_params)
2006
+
2007
+ return await self._make_request(
2008
+ "POST",
2009
+ endpoint="/api/v5/trade/order-precheck",
2010
+ data=filter_params(data),
2011
+ signed=True,
2012
+ )
2013
+
2014
+ # topic: Order Book Trading (Market Data)
2015
+
2016
+ async def get_tickers(
212
2017
  self,
213
2018
  inst_type: Literal["SPOT", "SWAP", "FUTURES", "OPTION"],
214
- inst_family: Literal["FUTURES", "SWAP", "OPTION"] | None = None,
2019
+ inst_family: str | None = None,
2020
+ ) -> dict:
2021
+ """Получение списка тикеров с основными метриками.
2022
+
2023
+ https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-tickers
2024
+ """
2025
+ params = {
2026
+ "instType": inst_type,
2027
+ "instFamily": inst_family,
2028
+ }
2029
+
2030
+ return await self._make_request(
2031
+ "GET",
2032
+ endpoint="/api/v5/market/tickers",
2033
+ params=params,
2034
+ )
2035
+
2036
+ async def get_ticker(self, inst_id: str) -> dict:
2037
+ """Получение тикера инструмента с данными за 24 часа.
2038
+
2039
+ https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-ticker
2040
+ """
2041
+ params = {
2042
+ "instId": inst_id,
2043
+ }
2044
+
2045
+ return await self._make_request(
2046
+ "GET",
2047
+ endpoint="/api/v5/market/ticker",
2048
+ params=params,
2049
+ )
2050
+
2051
+ async def get_order_book(self, inst_id: str, sz: int | None = None) -> dict:
2052
+ """Получение книги ордеров с обновлением каждые 50 мс.
2053
+
2054
+ https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-order-book
2055
+ """
2056
+ params = {
2057
+ "instId": inst_id,
2058
+ "sz": sz,
2059
+ }
2060
+
2061
+ return await self._make_request(
2062
+ "GET",
2063
+ endpoint="/api/v5/market/books",
2064
+ params=params,
2065
+ )
2066
+
2067
+ async def get_full_order_book(self, inst_id: str, sz: int | None = None) -> dict:
2068
+ """Получение полной книги ордеров с глубиной до 5000 уровней.
2069
+
2070
+ https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-full-order-book
2071
+ """
2072
+ params = {
2073
+ "instId": inst_id,
2074
+ "sz": sz,
2075
+ }
2076
+
2077
+ return await self._make_request(
2078
+ "GET",
2079
+ endpoint="/api/v5/market/books-full",
2080
+ params=params,
2081
+ )
2082
+
2083
+ async def get_candlesticks(
2084
+ self,
2085
+ inst_id: str,
2086
+ bar: str | None = None,
2087
+ after: int | None = None,
2088
+ before: int | None = None,
2089
+ limit: int | None = None,
2090
+ ) -> dict:
2091
+ """Получение списка свечей с максимальной глубиной в 1440 записей.
2092
+
2093
+ https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-candlesticks
2094
+ """
2095
+ params = {
2096
+ "instId": inst_id,
2097
+ "bar": bar,
2098
+ "after": after,
2099
+ "before": before,
2100
+ "limit": limit,
2101
+ }
2102
+
2103
+ return await self._make_request(
2104
+ "GET",
2105
+ endpoint="/api/v5/market/candles",
2106
+ params=params,
2107
+ )
2108
+
2109
+ async def get_candlesticks_history(
2110
+ self,
2111
+ inst_id: str,
2112
+ after: int | None = None,
2113
+ before: int | None = None,
2114
+ bar: str | None = None,
2115
+ limit: int | None = None,
2116
+ ) -> dict:
2117
+ """Получение исторических свечей за прошлые периоды.
2118
+
2119
+ https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-candlesticks-history
2120
+ """
2121
+ params = {
2122
+ "instId": inst_id,
2123
+ "after": after,
2124
+ "before": before,
2125
+ "bar": bar,
2126
+ "limit": limit,
2127
+ }
2128
+
2129
+ return await self._make_request(
2130
+ "GET",
2131
+ endpoint="/api/v5/market/history-candles",
2132
+ params=params,
2133
+ )
2134
+
2135
+ async def get_trades(self, inst_id: str, limit: int | None = None) -> dict:
2136
+ """Получение последних сделок по инструменту.
2137
+
2138
+ https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-trades
2139
+ """
2140
+ params = {
2141
+ "instId": inst_id,
2142
+ "limit": limit,
2143
+ }
2144
+
2145
+ return await self._make_request(
2146
+ "GET",
2147
+ endpoint="/api/v5/market/trades",
2148
+ params=params,
2149
+ )
2150
+
2151
+ async def get_trades_history(
2152
+ self,
2153
+ inst_id: str,
2154
+ type_: Literal["1", "2"] | None = None,
2155
+ after: str | None = None,
2156
+ before: str | None = None,
2157
+ limit: int | None = None,
2158
+ ) -> dict:
2159
+ """Получение истории сделок с пагинацией за последние три месяца.
2160
+
2161
+ https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-trades-history
2162
+ """
2163
+ params = {
2164
+ "instId": inst_id,
2165
+ "type": type_,
2166
+ "after": after,
2167
+ "before": before,
2168
+ "limit": limit,
2169
+ }
2170
+
2171
+ return await self._make_request(
2172
+ "GET",
2173
+ endpoint="/api/v5/market/history-trades",
2174
+ params=params,
2175
+ )
2176
+
2177
+ async def get_option_trades_by_family(self, inst_family: str) -> dict:
2178
+ """Получение сделок по всем опционам в рамках семьи инструментов.
2179
+
2180
+ https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-option-trades-by-instrument-family
2181
+ """
2182
+ params = {
2183
+ "instFamily": inst_family,
2184
+ }
2185
+
2186
+ return await self._make_request(
2187
+ "GET",
2188
+ endpoint="/api/v5/market/option/instrument-family-trades",
2189
+ params=params,
2190
+ )
2191
+
2192
+ async def get_option_trades(
2193
+ self,
2194
+ inst_id: str | None = None,
2195
+ inst_family: str | None = None,
2196
+ opt_type: Literal["C", "P"] | None = None,
2197
+ ) -> dict:
2198
+ """Получение сделок по выбранным опционам.
2199
+
2200
+ https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-option-trades
2201
+ """
2202
+ params = {
2203
+ "instId": inst_id,
2204
+ "instFamily": inst_family,
2205
+ "optType": opt_type,
2206
+ }
2207
+
2208
+ return await self._make_request(
2209
+ "GET",
2210
+ endpoint="/api/v5/public/option-trades",
2211
+ params=params,
2212
+ )
2213
+
2214
+ async def get_24h_total_volume(self) -> dict:
2215
+ """Получение совокупного 24-часового объема торгов по платформе.
2216
+
2217
+ https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-24h-total-volume
2218
+ """
2219
+ return await self._make_request(
2220
+ "GET",
2221
+ endpoint="/api/v5/market/platform-24-volume",
2222
+ )
2223
+
2224
+ async def get_call_auction_details(self, inst_id: str) -> dict:
2225
+ """Получение данных по предторговому аукциону инструмента.
2226
+
2227
+ https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-call-auction-details
2228
+ """
2229
+ params = {
2230
+ "instId": inst_id,
2231
+ }
2232
+
2233
+ return await self._make_request(
2234
+ "GET",
2235
+ endpoint="/api/v5/market/call-auction-details",
2236
+ params=params,
2237
+ )
2238
+
2239
+ # topic: Public Data
2240
+
2241
+ async def get_instruments(
2242
+ self,
2243
+ inst_type: Literal["SPOT", "MARGIN", "SWAP", "FUTURES", "OPTION"],
2244
+ inst_family: str | None = None,
2245
+ inst_id: str | None = None,
2246
+ ) -> dict:
2247
+ """Получение списка доступных публичных инструментов.
2248
+
2249
+ https://www.okx.com/docs-v5/en/#public-data-rest-api-get-instruments
2250
+ """
2251
+ params = {
2252
+ "instType": inst_type,
2253
+ "instFamily": inst_family,
2254
+ "instId": inst_id,
2255
+ }
2256
+
2257
+ return await self._make_request(
2258
+ "GET",
2259
+ endpoint="/api/v5/public/instruments",
2260
+ params=params,
2261
+ )
2262
+
2263
+ async def get_estimated_delivery_price(self, inst_id: str) -> dict:
2264
+ """Получение оценочной цены поставки или исполнения опциона.
2265
+
2266
+ https://www.okx.com/docs-v5/en/#public-data-rest-api-get-estimated-delivery-exercise-price
2267
+ """
2268
+ params = {
2269
+ "instId": inst_id,
2270
+ }
2271
+
2272
+ return await self._make_request(
2273
+ "GET",
2274
+ endpoint="/api/v5/public/estimated-price",
2275
+ params=params,
2276
+ )
2277
+
2278
+ async def get_delivery_exercise_history(
2279
+ self,
2280
+ inst_type: Literal["FUTURES", "OPTION"],
2281
+ inst_family: str,
2282
+ after: int | None = None,
2283
+ before: int | None = None,
2284
+ limit: int | None = None,
2285
+ ) -> dict:
2286
+ """Получение истории поставок и исполнений за последние три месяца.
2287
+
2288
+ https://www.okx.com/docs-v5/en/#public-data-rest-api-get-delivery-exercise-history
2289
+ """
2290
+ params = {
2291
+ "instType": inst_type,
2292
+ "instFamily": inst_family,
2293
+ "after": after,
2294
+ "before": before,
2295
+ "limit": limit,
2296
+ }
2297
+
2298
+ return await self._make_request(
2299
+ "GET",
2300
+ endpoint="/api/v5/public/delivery-exercise-history",
2301
+ params=params,
2302
+ )
2303
+
2304
+ async def get_estimated_settlement_info(self, inst_id: str) -> dict:
2305
+ """Получение оценочной цены ближайшего расчета по фьючерсу.
2306
+
2307
+ https://www.okx.com/docs-v5/en/#public-data-rest-api-get-estimated-future-settlement-price
2308
+ """
2309
+ params = {
2310
+ "instId": inst_id,
2311
+ }
2312
+
2313
+ return await self._make_request(
2314
+ "GET",
2315
+ endpoint="/api/v5/public/estimated-settlement-info",
2316
+ params=params,
2317
+ )
2318
+
2319
+ async def get_futures_settlement_history(
2320
+ self,
2321
+ inst_family: str,
2322
+ after: int | None = None,
2323
+ before: int | None = None,
2324
+ limit: int | None = None,
2325
+ ) -> dict:
2326
+ """Получение истории расчетов фьючерсов за последние три месяца.
2327
+
2328
+ https://www.okx.com/docs-v5/en/#public-data-rest-api-get-futures-settlement-history
2329
+ """
2330
+ params = {
2331
+ "instFamily": inst_family,
2332
+ "after": after,
2333
+ "before": before,
2334
+ "limit": limit,
2335
+ }
2336
+
2337
+ return await self._make_request(
2338
+ "GET",
2339
+ endpoint="/api/v5/public/settlement-history",
2340
+ params=params,
2341
+ )
2342
+
2343
+ async def get_funding_rate(self, inst_id: str) -> dict:
2344
+ """Получение текущей ставки финансирования.
2345
+
2346
+ https://www.okx.com/docs-v5/en/#public-data-rest-api-get-funding-rate
2347
+ """
2348
+ params = {
2349
+ "instId": inst_id,
2350
+ }
2351
+
2352
+ return await self._make_request(
2353
+ "GET",
2354
+ endpoint="/api/v5/public/funding-rate",
2355
+ params=params,
2356
+ )
2357
+
2358
+ async def get_funding_rate_history(
2359
+ self,
2360
+ inst_id: str,
2361
+ before: int | None = None,
2362
+ after: int | None = None,
2363
+ limit: int | None = None,
2364
+ ) -> dict:
2365
+ """Получение истории ставок финансирования за последние три месяца.
2366
+
2367
+ https://www.okx.com/docs-v5/en/#public-data-rest-api-get-funding-rate-history
2368
+ """
2369
+ params = {
2370
+ "instId": inst_id,
2371
+ "before": before,
2372
+ "after": after,
2373
+ "limit": limit,
2374
+ }
2375
+
2376
+ return await self._make_request(
2377
+ "GET",
2378
+ endpoint="/api/v5/public/funding-rate-history",
2379
+ params=params,
2380
+ )
2381
+
2382
+ async def get_open_interest(
2383
+ self,
2384
+ inst_type: Literal["SWAP", "FUTURES", "OPTION"],
2385
+ inst_family: str | None = None,
2386
+ inst_id: str | None = None,
2387
+ ) -> dict:
2388
+ """Получение общего открытого интереса по контрактам OKX.
2389
+
2390
+ https://www.okx.com/docs-v5/en/#public-data-rest-api-get-open-interest
2391
+ """
2392
+ params = {
2393
+ "instType": inst_type,
2394
+ "instFamily": inst_family,
2395
+ "instId": inst_id,
2396
+ }
2397
+
2398
+ return await self._make_request(
2399
+ "GET",
2400
+ endpoint="/api/v5/public/open-interest",
2401
+ params=params,
2402
+ )
2403
+
2404
+ async def get_price_limit(self, inst_id: str) -> dict:
2405
+ """Получение верхнего и нижнего лимитов цен для инструмента.
2406
+
2407
+ https://www.okx.com/docs-v5/en/#public-data-rest-api-get-limit-price
2408
+ """
2409
+ params = {
2410
+ "instId": inst_id,
2411
+ }
2412
+
2413
+ return await self._make_request(
2414
+ "GET",
2415
+ endpoint="/api/v5/public/price-limit",
2416
+ params=params,
2417
+ )
2418
+
2419
+ async def get_option_market_data(
2420
+ self,
2421
+ inst_family: str,
2422
+ exp_time: str | None = None,
215
2423
  ) -> dict:
216
- """Получение информации о тикерах.
2424
+ """Получение сводных рыночных данных по опционам.
217
2425
 
218
- https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-tickers
2426
+ https://www.okx.com/docs-v5/en/#public-data-rest-api-get-option-market-data
2427
+ """
2428
+ params = {
2429
+ "instFamily": inst_family,
2430
+ "expTime": exp_time,
2431
+ }
2432
+
2433
+ return await self._make_request(
2434
+ "GET",
2435
+ endpoint="/api/v5/public/opt-summary",
2436
+ params=params,
2437
+ )
2438
+
2439
+ async def get_discount_rate_quota(
2440
+ self,
2441
+ ccy: str | None = None,
2442
+ discount_lv: str | None = None,
2443
+ ) -> dict:
2444
+ """Получение ставок скидок и беспроцентных квот.
2445
+
2446
+ https://www.okx.com/docs-v5/en/#public-data-rest-api-get-discount-rate-and-interest-free-quota
2447
+ """
2448
+ params = {
2449
+ "ccy": ccy,
2450
+ "discountLv": discount_lv,
2451
+ }
2452
+
2453
+ return await self._make_request(
2454
+ "GET",
2455
+ endpoint="/api/v5/public/discount-rate-interest-free-quota",
2456
+ params=params,
2457
+ )
2458
+
2459
+ async def get_system_time(self) -> dict:
2460
+ """Получение времени сервера OKX.
2461
+
2462
+ https://www.okx.com/docs-v5/en/#public-data-rest-api-get-system-time
2463
+ """
2464
+ return await self._make_request(
2465
+ "GET",
2466
+ endpoint="/api/v5/public/time",
2467
+ )
2468
+
2469
+ async def get_mark_price(
2470
+ self,
2471
+ inst_type: Literal["MARGIN", "SWAP", "FUTURES", "OPTION"],
2472
+ inst_family: str | None = None,
2473
+ inst_id: str | None = None,
2474
+ ) -> dict:
2475
+ """Получение маржинальной цены инструмента.
2476
+
2477
+ https://www.okx.com/docs-v5/en/#public-data-rest-api-get-mark-price
2478
+ """
2479
+ params = {
2480
+ "instType": inst_type,
2481
+ "instFamily": inst_family,
2482
+ "instId": inst_id,
2483
+ }
2484
+
2485
+ return await self._make_request(
2486
+ "GET",
2487
+ endpoint="/api/v5/public/mark-price",
2488
+ params=params,
2489
+ )
2490
+
2491
+ async def get_position_tiers(
2492
+ self,
2493
+ inst_type: Literal["MARGIN", "SWAP", "FUTURES", "OPTION"],
2494
+ td_mode: Literal["cross", "isolated"],
2495
+ inst_family: str | None = None,
2496
+ inst_id: str | None = None,
2497
+ ccy: str | None = None,
2498
+ tier: str | None = None,
2499
+ ) -> dict:
2500
+ """Получение уровней позиций и допустимого плеча.
2501
+
2502
+ https://www.okx.com/docs-v5/en/#public-data-rest-api-get-position-tiers
2503
+ """
2504
+ params = {
2505
+ "instType": inst_type,
2506
+ "tdMode": td_mode,
2507
+ "instFamily": inst_family,
2508
+ "instId": inst_id,
2509
+ "ccy": ccy,
2510
+ "tier": tier,
2511
+ }
2512
+
2513
+ return await self._make_request(
2514
+ "GET",
2515
+ endpoint="/api/v5/public/position-tiers",
2516
+ params=params,
2517
+ )
2518
+
2519
+ async def get_interest_rate_loan_quota(self) -> dict:
2520
+ """Получение ставок и квот заимствования.
2521
+
2522
+ https://www.okx.com/docs-v5/en/#public-data-rest-api-get-interest-rate-and-loan-quota
2523
+ """
2524
+ return await self._make_request(
2525
+ "GET",
2526
+ endpoint="/api/v5/public/interest-rate-loan-quota",
2527
+ )
2528
+
2529
+ async def get_underlying(self, inst_type: Literal["SWAP", "FUTURES", "OPTION"]) -> dict:
2530
+ """Получение списка базовых активов по типу инструмента.
2531
+
2532
+ https://www.okx.com/docs-v5/en/#public-data-rest-api-get-underlying
2533
+ """
2534
+ params = {
2535
+ "instType": inst_type,
2536
+ }
2537
+
2538
+ return await self._make_request(
2539
+ "GET",
2540
+ endpoint="/api/v5/public/underlying",
2541
+ params=params,
2542
+ )
2543
+
2544
+ async def get_insurance_fund(
2545
+ self,
2546
+ inst_type: Literal["MARGIN", "SWAP", "FUTURES", "OPTION"],
2547
+ type_: Literal[
2548
+ "regular_update",
2549
+ "liquidation_balance_deposit",
2550
+ "bankruptcy_loss",
2551
+ "platform_revenue",
2552
+ "adl",
2553
+ ]
2554
+ | None = None,
2555
+ inst_family: str | None = None,
2556
+ ccy: str | None = None,
2557
+ before: int | None = None,
2558
+ after: int | None = None,
2559
+ limit: int | None = None,
2560
+ ) -> dict:
2561
+ """Получение данных страхового фонда.
219
2562
 
2563
+ https://www.okx.com/docs-v5/en/#public-data-rest-api-get-insurance-fund
220
2564
  """
221
2565
  params = {
222
2566
  "instType": inst_type,
2567
+ "type": type_,
2568
+ "instFamily": inst_family,
2569
+ "ccy": ccy,
2570
+ "before": before,
2571
+ "after": after,
2572
+ "limit": limit,
2573
+ }
2574
+
2575
+ return await self._make_request(
2576
+ "GET",
2577
+ endpoint="/api/v5/public/insurance-fund",
2578
+ params=params,
2579
+ )
2580
+
2581
+ async def convert_contract_coin(
2582
+ self,
2583
+ inst_id: str,
2584
+ sz: str,
2585
+ type_: Literal["1", "2"] | None = None,
2586
+ px: str | None = None,
2587
+ unit: Literal["coin", "usds"] | None = None,
2588
+ op_type: Literal["open", "close"] | None = None,
2589
+ ) -> dict:
2590
+ """Конвертация размера контракта и количества монет.
2591
+
2592
+ https://www.okx.com/docs-v5/en/#public-data-rest-api-unit-convert
2593
+ """
2594
+ params = {
2595
+ "type": type_,
2596
+ "instId": inst_id,
2597
+ "sz": sz,
2598
+ "px": px,
2599
+ "unit": unit,
2600
+ "opType": op_type,
2601
+ }
2602
+
2603
+ return await self._make_request(
2604
+ "GET",
2605
+ endpoint="/api/v5/public/convert-contract-coin",
2606
+ params=params,
2607
+ )
2608
+
2609
+ async def get_option_tick_bands(self, inst_family: str | None = None) -> dict:
2610
+ """Получение доступных ценовых диапазонов опционов.
2611
+
2612
+ https://www.okx.com/docs-v5/en/#public-data-rest-api-get-option-tick-bands
2613
+ """
2614
+ params = {
2615
+ "instType": "OPTION",
223
2616
  "instFamily": inst_family,
224
2617
  }
225
- return await self._make_request("GET", endpoint="/api/v5/market/tickers", params=params)
226
2618
 
227
- async def candles(
2619
+ return await self._make_request(
2620
+ "GET",
2621
+ endpoint="/api/v5/public/instrument-tick-bands",
2622
+ params=params,
2623
+ )
2624
+
2625
+ async def get_premium_history(
2626
+ self,
2627
+ inst_id: str,
2628
+ after: int | None = None,
2629
+ before: int | None = None,
2630
+ limit: int | None = None,
2631
+ ) -> dict:
2632
+ """Получение истории премии индекса за полгода.
2633
+
2634
+ https://www.okx.com/docs-v5/en/#public-data-rest-api-get-premium-history
2635
+ """
2636
+ params = {
2637
+ "instId": inst_id,
2638
+ "after": after,
2639
+ "before": before,
2640
+ "limit": limit,
2641
+ }
2642
+
2643
+ return await self._make_request(
2644
+ "GET",
2645
+ endpoint="/api/v5/public/premium-history",
2646
+ params=params,
2647
+ )
2648
+
2649
+ async def get_index_tickers(
2650
+ self,
2651
+ quote_ccy: str | None = None,
2652
+ inst_id: str | None = None,
2653
+ ) -> dict:
2654
+ """Получение индексов и ключевых метрик по ним.
2655
+
2656
+ https://www.okx.com/docs-v5/en/#public-data-rest-api-get-index-tickers
2657
+ """
2658
+ params = {
2659
+ "quoteCcy": quote_ccy,
2660
+ "instId": inst_id,
2661
+ }
2662
+
2663
+ return await self._make_request(
2664
+ "GET",
2665
+ endpoint="/api/v5/market/index-tickers",
2666
+ params=params,
2667
+ )
2668
+
2669
+ async def get_index_candlesticks(
228
2670
  self,
229
2671
  inst_id: str,
2672
+ after: int | None = None,
2673
+ before: int | None = None,
230
2674
  bar: str | None = None,
2675
+ limit: int | None = None,
2676
+ ) -> dict:
2677
+ """Получение свечей по индексным значениям.
2678
+
2679
+ https://www.okx.com/docs-v5/en/#public-data-rest-api-get-index-candlesticks
2680
+ """
2681
+ params = {
2682
+ "instId": inst_id,
2683
+ "after": after,
2684
+ "before": before,
2685
+ "bar": bar,
2686
+ "limit": limit,
2687
+ }
2688
+
2689
+ return await self._make_request(
2690
+ "GET",
2691
+ endpoint="/api/v5/market/index-candles",
2692
+ params=params,
2693
+ )
2694
+
2695
+ async def get_index_candlesticks_history(
2696
+ self,
2697
+ inst_id: str,
231
2698
  after: int | None = None,
232
2699
  before: int | None = None,
2700
+ bar: str | None = None,
233
2701
  limit: int | None = None,
234
2702
  ) -> dict:
235
- """Получение свечей.
2703
+ """Получение исторических свечей по индексам.
236
2704
 
237
- https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-candlesticks
2705
+ https://www.okx.com/docs-v5/en/#public-data-rest-api-get-index-candlesticks-history
238
2706
  """
239
2707
  params = {
240
2708
  "instId": inst_id,
2709
+ "after": after,
2710
+ "before": before,
241
2711
  "bar": bar,
2712
+ "limit": limit,
2713
+ }
2714
+
2715
+ return await self._make_request(
2716
+ "GET",
2717
+ endpoint="/api/v5/market/history-index-candles",
2718
+ params=params,
2719
+ )
2720
+
2721
+ async def get_mark_price_candlesticks(
2722
+ self,
2723
+ inst_id: str,
2724
+ after: int | None = None,
2725
+ before: int | None = None,
2726
+ bar: str | None = None,
2727
+ limit: int | None = None,
2728
+ ) -> dict:
2729
+ """Получение свечей по маржинальной цене инструмента.
2730
+
2731
+ https://www.okx.com/docs-v5/en/#public-data-rest-api-get-mark-price-candlesticks
2732
+ """
2733
+ params = {
2734
+ "instId": inst_id,
242
2735
  "after": after,
243
2736
  "before": before,
2737
+ "bar": bar,
244
2738
  "limit": limit,
245
2739
  }
246
- return await self._make_request("GET", endpoint="/api/v5/market/candles", params=params)
247
2740
 
248
- # topic: Public Data
249
- # sub-topic: REST API
2741
+ return await self._make_request(
2742
+ "GET",
2743
+ endpoint="/api/v5/market/mark-price-candles",
2744
+ params=params,
2745
+ )
250
2746
 
251
- async def get_funding_rate(self, inst_id: str) -> dict:
252
- """Получение информации о ставке финансирования.
2747
+ async def get_mark_price_candlesticks_history(
2748
+ self,
2749
+ inst_id: str,
2750
+ after: int | None = None,
2751
+ before: int | None = None,
2752
+ bar: str | None = None,
2753
+ limit: int | None = None,
2754
+ ) -> dict:
2755
+ """Получение исторических свечей по маржинальной цене.
253
2756
 
254
- https://www.okx.com/docs-v5/en/#public-data-rest-api-get-funding-rate
2757
+ https://www.okx.com/docs-v5/en/#public-data-rest-api-get-mark-price-candlesticks-history
255
2758
  """
256
2759
  params = {
257
2760
  "instId": inst_id,
2761
+ "after": after,
2762
+ "before": before,
2763
+ "bar": bar,
2764
+ "limit": limit,
258
2765
  }
2766
+
2767
+ return await self._make_request(
2768
+ "GET",
2769
+ endpoint="/api/v5/market/history-mark-price-candles",
2770
+ params=params,
2771
+ )
2772
+
2773
+ async def get_exchange_rate(self) -> dict:
2774
+ """Получение средневзвешенного курса USD/CNY за две недели.
2775
+
2776
+ https://www.okx.com/docs-v5/en/#public-data-rest-api-get-exchange-rate
2777
+ """
259
2778
  return await self._make_request(
260
- "GET", endpoint="/api/v5/public/funding-rate", params=params
2779
+ "GET",
2780
+ endpoint="/api/v5/market/exchange-rate",
261
2781
  )
262
2782
 
263
- async def get_open_interest(
2783
+ async def get_index_components(self, index: str) -> dict:
2784
+ """Получение состава выбранного индекса.
2785
+
2786
+ https://www.okx.com/docs-v5/en/#public-data-rest-api-get-index-components
2787
+ """
2788
+ params = {
2789
+ "index": index,
2790
+ }
2791
+
2792
+ return await self._make_request(
2793
+ "GET",
2794
+ endpoint="/api/v5/market/index-components",
2795
+ params=params,
2796
+ )
2797
+
2798
+ async def get_economic_calendar(
264
2799
  self,
265
- inst_type: Literal["SWAP", "FUTURES", "OPTION"],
266
- inst_family: str | None = None,
267
- inst_id: str | None = None,
2800
+ region: str | None = None,
2801
+ importance: Literal["1", "2", "3"] | None = None,
2802
+ before: int | None = None,
2803
+ after: int | None = None,
2804
+ limit: int | None = None,
268
2805
  ) -> dict:
269
- """Получение информации по открытому интересу.
2806
+ """Получение данных макроэкономического календаря.
270
2807
 
271
- https://www.okx.com/docs-v5/en/#public-data-rest-api-get-open-interest
2808
+ https://www.okx.com/docs-v5/en/#public-data-rest-api-get-economic-calendar-data
2809
+ """
2810
+ params = {
2811
+ "region": region,
2812
+ "importance": importance,
2813
+ "before": before,
2814
+ "after": after,
2815
+ "limit": limit,
2816
+ }
2817
+
2818
+ return await self._make_request(
2819
+ "GET",
2820
+ endpoint="/api/v5/public/economic-calendar",
2821
+ params=params,
2822
+ signed=True,
2823
+ )
2824
+
2825
+ async def get_market_data_history(
2826
+ self,
2827
+ module: Literal["1", "2", "3", "6"],
2828
+ inst_type: Literal["SPOT", "FUTURES", "SWAP", "OPTION"],
2829
+ begin: int,
2830
+ end: int,
2831
+ inst_id_list: str | None = None,
2832
+ inst_family_list: str | None = None,
2833
+ date_aggr_type: Literal["daily", "monthly"] = "daily",
2834
+ ) -> dict:
2835
+ """Получение ссылок на исторические рыночные данные OKX.
2836
+
2837
+ https://www.okx.com/docs-v5/en/#public-data-rest-api-get-historical-market-data
272
2838
  """
273
2839
  params = {
2840
+ "module": module,
274
2841
  "instType": inst_type,
275
- "instFamily": inst_family,
276
- "instId": inst_id,
2842
+ "instIdList": inst_id_list,
2843
+ "instFamilyList": inst_family_list,
2844
+ "dateAggrType": date_aggr_type,
2845
+ "begin": begin,
2846
+ "end": end,
277
2847
  }
2848
+
278
2849
  return await self._make_request(
279
- "GET", endpoint="/api/v5/public/open-interest", params=params
2850
+ "GET",
2851
+ endpoint="/api/v5/public/market-data-history",
2852
+ params=params,
280
2853
  )