GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — ccxt/python/ccxt/derive.py at master · ccxt/ccxt

Expand file tree

/

derive.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
4114 lines (3964 loc) · 207 KB
/

derive.py

Copy path

File metadata and controls

4114 lines (3964 loc) · 207 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf-8 -*-
# PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
# https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
from ccxt.base.exchange import Exchange
from ccxt.abstract.derive import ImplicitAPI
from ccxt.base.types import Account, Balances, BorrowInterest, Currencies, Currency, CurrencyInterface, FundingHistory, Greeks, Int, Market, Num, Option, Order, OrderSide, OrderType, Position, Str, Strings, Ticker, FundingRate, OpenInterest, Trade, Transaction, FundingRateHistory, TransferEntry
from ccxt.base.errors import ExchangeError
from ccxt.base.errors import AuthenticationError
from ccxt.base.errors import ArgumentsRequired
from ccxt.base.errors import BadRequest
from ccxt.base.errors import InsufficientFunds
from ccxt.base.errors import InvalidOrder
from ccxt.base.errors import OrderNotFound
from ccxt.base.errors import RateLimitExceeded
from ccxt.base.decimal_to_precision import TRUNCATE
from ccxt.base.decimal_to_precision import DECIMAL_PLACES
from ccxt.base.decimal_to_precision import TICK_SIZE
from ccxt.base.precise import Precise
class derive(Exchange, ImplicitAPI):
def describe(self) -> dict:
return self.deep_extend(super(derive, self).describe(), {
'id': 'derive',
'name': 'Derive',
'countries': [],
'version': 'v3',
'rateLimit': 50,
'certified': False,
'pro': True,
'dex': True,
'has': {
'CORS': None,
'spot': True,
'margin': False,
'swap': True,
'future': False,
'option': True,
'addMargin': False,
'borrowCrossMargin': False,
'borrowIsolatedMargin': False,
'cancelAllOrders': True,
'cancelAllOrdersAfter': False,
'cancelOrder': True,
'cancelOrders': False,
'cancelOrdersForSymbols': False,
'closeAllPositions': False,
'closePosition': False,
'createMarketBuyOrderWithCost': False,
'createMarketOrderWithCost': False,
'createMarketSellOrderWithCost': False,
'createOrder': True,
'createOrders': False,
'createOrderWithTakeProfitAndStopLoss': False,
'createPostOnlyOrder': True,
'createReduceOnlyOrder': True,
'createStopLimitOrder': True,
'createStopLossOrder': True,
'createStopMarketOrder': False,
'createStopOrder': True,
'createTakeProfitOrder': True,
'createTrailingAmountOrder': False,
'createTrailingPercentOrder': False,
'createTriggerOrder': True,
'editOrder': True,
'fetchAccounts': True,
'fetchBalance': True,
'fetchBorrowInterest': True,
'fetchBorrowRateHistories': False,
'fetchBorrowRateHistory': True,
'fetchCanceledAndClosedOrders': True,
'fetchCanceledOrders': True,
'fetchClosedOrders': True,
'fetchCrossBorrowRate': False,
'fetchCrossBorrowRates': False,
'fetchCurrencies': True,
'fetchDepositAddress': False,
'fetchDepositAddresses': False,
'fetchDeposits': True,
'fetchDepositWithdrawFee': False,
'fetchDepositWithdrawFees': False,
'fetchFundingHistory': True,
'fetchFundingRate': True,
'fetchFundingRateHistory': True,
'fetchFundingRates': False,
'fetchGreeks': True,
'fetchIndexOHLCV': True,
'fetchIsolatedBorrowRate': False,
'fetchIsolatedBorrowRates': False,
'fetchLedger': False,
'fetchLeverage': False,
'fetchLeverageTiers': False,
'fetchLiquidations': False,
'fetchMarginMode': None,
'fetchMarketLeverageTiers': False,
'fetchMarkets': True,
'fetchMarkOHLCV': False,
'fetchMyLiquidations': False,
'fetchMySettlementHistory': True,
'fetchMyTrades': True,
'fetchOHLCV': True,
'fetchOpenInterest': True,
'fetchOpenInterestHistory': False,
'fetchOpenInterests': False,
'fetchOpenOrders': True,
'fetchOption': True,
'fetchOrder': True,
'fetchOrderBook': False,
'fetchOrders': False,
'fetchOrderTrades': True,
'fetchPosition': False,
'fetchPositionMode': False,
'fetchPositions': True,
'fetchPositionsRisk': False,
'fetchPremiumIndexOHLCV': False,
'fetchSettlementHistory': True,
'fetchTicker': True,
'fetchTickers': False,
'fetchTime': True,
'fetchTrades': True,
'fetchTradingFee': False,
'fetchTradingFees': False,
'fetchTransfer': False,
'fetchTransfers': True,
'fetchWithdrawal': False,
'fetchWithdrawals': True,
'reduceMargin': False,
'repayCrossMargin': False,
'repayIsolatedMargin': False,
'sandbox': True,
'setLeverage': False,
'setMarginMode': False,
'setPositionMode': False,
'transfer': True,
'withdraw': True,
},
'timeframes': {
'1m': '60',
'5m': '300',
'15m': '900',
'30m': '1800',
'1h': '3600',
'4h': '14400',
'8h': '28800',
'1d': '86400',
'1w': '604800',
},
'features': {
'default': {
'sandbox': True,
'createOrder': {
'marginMode': False,
'triggerPrice': True,
'triggerPriceType': {
'last': False,
'mark': True,
'index': False,
},
'triggerDirection': False,
'stopLossPrice': True,
'takeProfitPrice': True,
'attachedStopLossTakeProfit': None,
'timeInForce': {
'IOC': True,
'FOK': True,
'PO': True,
'GTD': False,
},
'hedged': False,
'trailing': False,
'leverage': False,
'marketBuyByCost': False,
'marketBuyRequiresPrice': True,
'selfTradePrevention': False,
'iceberg': False,
},
'createOrders': None,
'fetchMyTrades': {
'marginMode': False,
'limit': 1000,
'daysBack': None,
'untilDays': None,
'symbolRequired': False,
},
'fetchOrder': {
'marginMode': False,
'trigger': False,
'trailing': False,
'symbolRequired': False,
},
'fetchOpenOrders': {
'marginMode': False,
'limit': None,
'trigger': True,
'trailing': False,
'symbolRequired': False,
},
'fetchOrders': None,
'fetchClosedOrders': {
'marginMode': False,
'limit': 1000,
'daysBack': None,
'daysBackCanceled': None,
'untilDays': None,
'trigger': False,
'trailing': False,
'symbolRequired': False,
},
'fetchOHLCV': {
'limit': 5000,
},
},
'spot': {
'extends': 'default',
},
'swap': {
'linear': {
'extends': 'default',
},
'inverse': None,
},
'future': {
'linear': None,
'inverse': None,
},
},
'urls': {
'logo': 'https://github.com/user-attachments/assets/9e640700-c870-41f9-8907-fba58e120fed',
'api': {
'public': 'https://api.derive.xyz/v3/public',
'private': 'https://api.derive.xyz/v3/private',
},
'test': {
'public': 'https://testnet.api.derive.xyz/v3/public',
'private': 'https://testnet.api.derive.xyz/v3/private',
},
'www': 'https://www.derive.xyz/',
'doc': 'https://docs.derive.xyz/',
'fees': 'https://docs.derive.xyz/integrators/trading/trading-fees',
'referral': 'https://www.derive.xyz/invite/3VB0B',
},
'api': {
'public': {
'get': {
'get_all_currencies': {'cost': 1},
},
'post': {
'decode_action': {'cost': 1},
'get_wallets_from_session_key': {'cost': 1},
'get_all_currencies': {'cost': 1},
'get_currency': {'cost': 1},
'get_risk_universes': {'cost': 1},
'get_instrument': {'cost': 1},
'get_all_instruments': {'cost': 1},
'get_all_live_instruments': {'cost': 1},
'get_ticker': {'cost': 1},
'get_tickers': {'cost': 1},
'get_latest_signed_feeds': {'cost': 1},
'get_option_settlement_prices': {'cost': 1},
'get_index_chart_data': {'cost': 1},
'get_tradingview_chart_data': {'cost': 1},
'get_funding_rate_history': {'cost': 1},
'get_trade_history': {'cost': 1},
'get_liquidation_history': {'cost': 1},
'get_interest_rate_history': {'cost': 1},
'get_transaction': {'cost': 1},
'get_onchain_action_history': {'cost': 1},
'get_pending_deposits': {'cost': 1},
'register_deposit_address': {'cost': 1},
'get_margin': {'cost': 1},
'margin_watch': {'cost': 1},
'order_quote': {'cost': 1},
'get_live_auctions': {'cost': 1},
'start_auction': {'cost': 1},
'get_vault': {'cost': 1},
'get_vaults': {'cost': 1},
'get_vault_action_history': {'cost': 1},
'get_vault_performance_history': {'cost': 1},
'set_socialization_feed_data': {'cost': 1},
'withdraw_debug': {'cost': 1},
'send_quote_debug': {'cost': 1},
'execute_quote_debug': {'cost': 1},
'get_all_referral_codes': {'cost': 1},
'get_referral_performance': {'cost': 1},
'get_time': {'cost': 1},
'get_live_incidents': {'cost': 1},
'get_maker_programs': {'cost': 1},
'get_maker_program_scores': {'cost': 1},
},
},
'private': {
'post': {
'get_account': {'cost': 1},
'get_subaccount': {'cost': 1},
'get_subaccounts': {'cost': 1},
'delete_subaccount': {'cost': 1},
'get_all_portfolios': {'cost': 1},
'change_subaccount_label': {'cost': 1},
'withdraw': {'cost': 1},
'transfer_spot': {'cost': 1},
'transfer_spot_external': {'cost': 1},
'transfer_positions': {'cost': 1},
'reject_deposit_request': {'cost': 1},
'update_whitelisted_recipients': {'cost': 1},
'order': {'cost': 1},
'replace': {'cost': 1},
'order_debug': {'cost': 1},
'get_order': {'cost': 1},
'get_open_orders': {'cost': 1},
'get_trigger_orders': {'cost': 1},
'get_algo_orders': {'cost': 1},
'cancel': {'cost': 1},
'cancel_by_label': {'cost': 1},
'cancel_by_nonce': {'cost': 1},
'cancel_by_instrument': {'cost': 1},
'cancel_all': {'cost': 1},
'cancel_trigger_order': {'cost': 1},
'cancel_algo_order': {'cost': 1},
'cancel_all_algo_orders': {'cost': 1},
'cancel_all_trigger_orders': {'cost': 1},
'get_order_history': {'cost': 1},
'get_trade_history': {'cost': 1},
'get_deposit_history': {'cost': 1},
'get_withdrawal_history': {'cost': 1},
'send_rfq': {'cost': 1},
'cancel_rfq': {'cost': 1},
'cancel_batch_rfqs': {'cost': 1},
'get_rfqs': {'cost': 1},
'poll_rfqs': {'cost': 1},
'send_quote': {'cost': 1},
'cancel_quote': {'cost': 1},
'cancel_batch_quotes': {'cost': 1},
'get_quotes': {'cost': 1},
'poll_quotes': {'cost': 1},
'execute_quote': {'cost': 1},
'order_quote': {'cost': 1},
'replace_quote': {'cost': 1},
'rfq_get_best_quote': {'cost': 1},
'get_margin': {'cost': 1},
'get_collaterals': {'cost': 1},
'get_positions': {'cost': 1},
'get_option_settlement_history': {'cost': 1},
'get_subaccount_value_history': {'cost': 1},
'get_funding_history': {'cost': 1},
'get_interest_history': {'cost': 1},
'get_erc20_transfer_history': {'cost': 1},
'get_liquidation_history': {'cost': 1},
'liquidate': {'cost': 1},
'session_keys': {'cost': 1},
'set_session_key': {'cost': 1},
'edit_session_key': {'cost': 1},
'get_mmp_config': {'cost': 1},
'set_mmp_config': {'cost': 1},
'reset_mmp': {'cost': 1},
'create_vault': {'cost': 1},
'update_vault_info': {'cost': 1},
'mint_vault_shares': {'cost': 1},
'burn_vault_shares': {'cost': 1},
'force_burn': {'cost': 1},
'request_vault_deposit': {'cost': 1},
'request_vault_withdraw': {'cost': 1},
'cancel_all_vault_requests': {'cost': 1},
'get_vault_shares': {'cost': 1},
'get_curated_vaults': {'cost': 1},
'get_shareholder_vaults': {'cost': 1},
'get_live_mint_requests': {'cost': 1},
'get_live_burn_requests': {'cost': 1},
'get_live_vault_requests': {'cost': 1},
'get_vault_request_history': {'cost': 1},
},
},
},
'fees': {
},
'requiredCredentials': {
'apiKey': False,
'secret': False,
'walletAddress': True,
'privateKey': True,
},
'exceptions': {
'exact': {
'-32000': RateLimitExceeded, # Rate limit exceeded
'-32100': RateLimitExceeded, # Number of concurrent websocket clients limit exceeded
'-32700': BadRequest, # Parse error
'-32600': BadRequest, # Invalid Request
'-32601': BadRequest, # Method not found
'-32602': InvalidOrder, # {"id":"55e66a3d-6a4e-4a36-a23d-5cf8a91ef478","error":{"code":"","message":"Invalid params"}}
'-32603': InvalidOrder, # {"code":"-32603","message":"Internal error","data":"SubAccount matching query does not exist."}
'9000': InvalidOrder, # Order confirmation timeout
'10000': BadRequest, # Manager not found
'10001': BadRequest, # Asset is not an ERC20 token
'10002': BadRequest, # Sender and recipient wallet do not match
'10003': BadRequest, # Sender and recipient subaccount IDs are the same
'10004': InvalidOrder, # Multiple currencies not supported
'10005': BadRequest, # Maximum number of subaccounts per wallet reached
'10006': BadRequest, # Maximum number of session keys per wallet reached
'10007': BadRequest, # Maximum number of assets per subaccount reached
'10008': BadRequest, # Maximum number of expiries per subaccount reached
'10009': BadRequest, # Recipient subaccount ID of the transfer cannot be 0
'10010': InvalidOrder, # PMRM only supports USDC asset collateral. Cannot trade spot markets.
'10011': InsufficientFunds, # ERC20 allowance is insufficient
'10012': InsufficientFunds, # ERC20 balance is less than transfer amount
'10013': ExchangeError, # There is a pending deposit for this asset
'10014': ExchangeError, # There is a pending withdrawal for this asset
'11000': InsufficientFunds, # Insufficient funds
'11002': InvalidOrder, # Order rejected from queue
'11003': InvalidOrder, # Already cancelled
'11004': InvalidOrder, # Already filled
'11005': InvalidOrder, # Already expired
'11006': OrderNotFound, # {"code":"11006","message":"Does not exist","data":"Open order with id: 804018f3-b092-40a3-a933-b29574fa1ff8 does not exist."}
'11007': InvalidOrder, # Self-crossing disallowed
'11008': InvalidOrder, # Post-only reject
'11009': InvalidOrder, # Zero liquidity for market or IOC/FOK order
'11010': InvalidOrder, # Post-only invalid order type
'11011': InvalidOrder, # {"code":11011,"message":"Invalid signature expiry","data":"Order must expire in 300 sec or more"}
'11012': InvalidOrder, # {"code":"11012","message":"Invalid amount","data":"Amount must be a multiple of 0.01"}
'11013': InvalidOrder, # {"code":"11013","message":"Invalid limit price","data":{"limit":"10000","bandwidth":"92530"}}
'11014': InvalidOrder, # Fill-or-kill not filled
'11015': InvalidOrder, # MMP frozen
'11016': InvalidOrder, # Already consumed
'11017': InvalidOrder, # Non unique nonce
'11018': InvalidOrder, # Invalid nonce date
'11019': InvalidOrder, # Open orders limit exceeded
'11020': InsufficientFunds, # Negative ERC20 balance
'11021': InvalidOrder, # Instrument is not live
'11022': InvalidOrder, # Reject timestamp exceeded
'11023': InvalidOrder, # {"code":"11023","message":"Max fee order param is too low","data":"signed max_fee must be >= 194.420835871999983091712000000000000000"}
'11024': InvalidOrder, # {"code":11024,"message":"Reduce only not supported with this time in force"}
'11025': InvalidOrder, # Reduce only reject
'11026': BadRequest, # Transfer reject
'11027': InvalidOrder, # Subaccount undergoing liquidation
'11028': InvalidOrder, # Replaced order filled amount does not match expected state.
'11029': InvalidOrder, # {"code":11029,"message":"Trade or transfer rejected: open interest cap would be exceeded","data":"open-interest cap exceeded for SpotBorrow on 0x... in universe 1: pre 0, post 2000000000, cap 0"}
'11050': InvalidOrder, # Trigger order was cancelled between the time worker sent order and engine processed order
'11051': InvalidOrder, # {"code":"11051","message":"Trigger price must be higher than the current price for stop orders and vice versa for take orders","data":"Trigger price 9000.0 must be < or > current price 102671.2 depending on trigger type and direction."}
'11052': InvalidOrder, # Trigger order limit exceeded (separate limit from regular orders)
'11053': InvalidOrder, # Index and last-trade trigger price types not supported yet
'11054': InvalidOrder, # {"code":"11054","message":"Trigger orders cannot replace or be replaced"}
'11055': InvalidOrder, # Market order limit_price is unfillable at the given trigger price
'11100': InvalidOrder, # Leg instruments are not unique
'11101': InvalidOrder, # RFQ not found
'11102': InvalidOrder, # Quote not found
'11103': InvalidOrder, # Quote leg does not match RFQ leg
'11104': InvalidOrder, # Requested quote or RFQ is not open
'11105': InvalidOrder, # Requested quote ID references a different RFQ ID
'11106': InvalidOrder, # Invalid RFQ counterparty
'11107': InvalidOrder, # Quote maker total cost too high
'11200': InvalidOrder, # Auction not ongoing
'11201': InvalidOrder, # Open orders not allowed
'11202': InvalidOrder, # Price limit exceeded
'11203': InvalidOrder, # Last trade ID mismatch
'12000': InvalidOrder, # Asset not found
'12001': InvalidOrder, # Instrument not found
'12002': BadRequest, # Currency not found
'12003': BadRequest, # USDC does not have asset caps per manager
'13000': BadRequest, # Invalid channels
'14000': BadRequest, # {"code": 14000, "message": "Account not found"}
'14001': InvalidOrder, # {"code": 14001, "message": "Subaccount not found"}
'14002': BadRequest, # Subaccount was withdrawn
'14008': BadRequest, # Cannot reduce expiry using registerSessionKey RPC route
'14009': BadRequest, # Session key expiry must be > utc_now + 10 min
'14010': BadRequest, # Session key already registered for this account
'14011': BadRequest, # Session key already registered with another account
'14012': BadRequest, # Address must be checksummed
'14013': BadRequest, # String is not a valid ethereum address
'14014': InvalidOrder, # {"code":"14014","message":"Signature invalid for message or transaction","data":"Signature does not match data"}
'14015': BadRequest, # Transaction count for given wallet does not match provided nonce
'14016': BadRequest, # The provided signed raw transaction contains function name that does not match the expected function name
'14017': BadRequest, # The provided signed raw transaction contains contract address that does not match the expected contract address
'14018': BadRequest, # The provided signed raw transaction contains function params that do not match any expected function params
'14019': BadRequest, # The provided signed raw transaction contains function param values that do not match the expected values
'14020': BadRequest, # The X-DeriveWallet header does not match the requested subaccount_id or wallet
'14021': BadRequest, # The X-DeriveWallet header not provided
'14022': AuthenticationError, # Subscription to a private channel failed
'14023': InvalidOrder, # {"code":"14023","message":"Signer in on-chain related request is not wallet owner or registered session key","data":"Session key does not belong to wallet"}
'14024': BadRequest, # Chain ID must match the current roll up chain id
'14025': BadRequest, # The private request is missing a wallet or subaccount_id param
'14026': BadRequest, # Session key not found
'14027': AuthenticationError, # Unauthorized as RFQ maker
'14028': BadRequest, # Cross currency RFQ not supported
'14029': AuthenticationError, # Session key IP not whitelisted
'14030': BadRequest, # Session key expired
'14031': AuthenticationError, # Unauthorized key scope
'14032': BadRequest, # Scope should not be changed
'16000': AuthenticationError, # You are in a restricted region that violates our terms of service.
'16001': AuthenticationError, # Account is disabled due to compliance violations, please contact support to enable it.
'16100': AuthenticationError, # Sentinel authorization is invalid
'17000': BadRequest, # This accoount does not have a shareable invite code
'17001': BadRequest, # Invalid invite code
'17002': BadRequest, # Invite code already registered for this account
'17003': BadRequest, # Invite code has no remaining uses
'17004': BadRequest, # Requirement for successful invite registration not met
'17005': BadRequest, # Account must register with a valid invite code to be elligible for points
'17006': BadRequest, # Point program does not exist
'17007': BadRequest, # Invalid leaderboard page number
'18000': BadRequest, # Invalid block number
'18001': BadRequest, # Failed to estimate block number. Please try again later.
'18002': BadRequest, # The provided smart contract owner does not match the wallet in LightAccountFactory.getAddress()
'18003': BadRequest, # Vault ERC20 asset does not exist
'18004': BadRequest, # Vault ERC20 pool does not exist
'18005': BadRequest, # Must add asset to pool before getting balances
'18006': BadRequest, # Invalid Swell season. Swell seasons are in the form 'swell_season_X'.
'18007': BadRequest, # Vault not found
'19000': BadRequest, # Maker program not found
},
'broad': {
},
},
'precisionMode': TICK_SIZE,
'commonCurrencies': {
},
'options': {
'deriveWalletAddress': '', # the owner wallet "0x"-prefixed hexstring; defaults to the walletAddress credential (v3 has no separate derive wallet), override only when signing with a session key for another owner wallet
'id': '0x0ad42b8e602c2d3d475ae52d678cf63d84ab2749',
'timeDifference': 0, # the difference between system clock and exchange clock
'adjustForTimeDifference': False, # controls the adjustment logic upon instantiation
'maxMarketPages': 25,
'maxMarketsPerPage': 1000,
},
})
def set_sandbox_mode(self, enable: bool):
super(derive, self).set_sandbox_mode(enable)
self.options['sandboxMode'] = enable
def fetch_time(self, params: dict = {}) -> Int:
"""
fetches the current integer timestamp in milliseconds from the exchange server
https://docs.derive.xyz/api-reference/system/publicget_time
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns int: the current integer timestamp in milliseconds from the exchange server
"""
response = self.publicPostGetTime(params)
#
# {
# "id": "8be9f582-7653-48b1-980a-6da11c130d58",
# "result": 1790877292671
# }
#
return self.safe_integer(response, 'result')
def fetch_accounts(self, params: dict = {}) -> list[Account]:
"""
fetch all the subaccounts associated with the wallet
https://docs.derive.xyz/api-reference/subaccounts/privateget_subaccounts
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: a list of `account structures <https://docs.ccxt.com/?id=account-structure>`
"""
deriveWalletAddress, paramsDeriveWalletAddress = self.handle_derive_wallet_address('fetchAccounts', params)
request = {
'wallet': deriveWalletAddress,
}
response = self.privatePostGetSubaccounts(self.extend(request, paramsDeriveWalletAddress))
#
# {
# "id": "1c314a3a-f7f5-47bd-998a-cea5dda11c30",
# "result": {
# "wallet": "0x9050dfA063D1bE7cA711c750b18D51fDD13e90Ee",
# "subaccount_ids": [
# 86814,
# 86815,
# 86820
# ]
# }
# }
#
result = self.safe_dict(response, 'result', {})
subaccountIds = self.safe_list(result, 'subaccount_ids', [])
accounts = []
for i in range(0, len(subaccountIds)):
subaccountId = self.safe_string(subaccountIds, i)
accounts.append({
'id': subaccountId,
'type': None,
'code': None,
'info': result,
})
return accounts
def fetch_currencies(self, params: dict = {}) -> Currencies:
"""
fetches all available currencies on an exchange
https://docs.derive.xyz/api-reference/market-data/publicget_all_currencies
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an associative dictionary of currencies
"""
tokenResponse = self.publicGetGetAllCurrencies(params)
#
# {
# "id": "b343bc1c-8417-485f-9022-e18787909856",
# "result": [
# {
# "currency": "BTC",
# "market_type": "ALL",
# "spot_price": "84829.66932265963",
# "spot_price_24h": "83566.69063592498",
# "managers": [
# {
# "risk_universe_id": 1,
# "risk_universe_name": "PRIME",
# "sm": 1,
# "pm": 5
# }
# ],
# "option": {
# "name": "BTC-OPTION",
# "address": "0xd0711b9eBE84b778483709CDe62BacFDBAE13623",
# "universes": [
# {
# "risk_universe_id": 1,
# "risk_universe_name": "PRIME",
# "oi": {
# "current_open_interest": "6495.655320644765",
# "interest_cap": "300000"
# }
# }
# ]
# },
# "perp": {
# "name": "BTC-PERP",
# "address": "0xDBa83C0C654DB1cd914FA2710bA743e925B53086",
# "universes": [
# {
# "risk_universe_id": 1,
# "risk_universe_name": "PRIME",
# "oi": {
# "current_open_interest": "291.309220426457",
# "interest_cap": "36000"
# },
# "srm_perp_margin_requirements": {
# "im_perp_req": "0.066",
# "mm_perp_req": "0.05",
# "max_leverage": "15.15"
# }
# }
# ]
# },
# "spot": []
# }
# ]
# }
#
currencies = self.safe_list(tokenResponse, 'result', [])
return self.parse_currencies(currencies)
def parse_currency(self, rawCurrency: dict) -> CurrencyInterface:
currencyId = self.safe_string(rawCurrency, 'currency')
code = self.safe_currency_code(currencyId)
return self.safe_currency_structure({
'id': currencyId,
'name': None,
'code': code,
'precision': None,
'active': None,
'fee': None,
'networks': None,
'deposit': None,
'withdraw': None,
'limits': {
'deposit': {
'min': None,
'max': None,
},
'withdraw': {
'min': None,
'max': None,
},
},
'info': rawCurrency,
})
def fetch_markets(self, params: dict = {}) -> list[Market]:
"""
retrieves data on all markets for derive
https://docs.derive.xyz/api-reference/market-data/publicget_all_instruments
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: an array of objects representing market data
"""
if self.safe_bool(self.options, 'adjustForTimeDifference', False):
self.load_time_difference()
spotMarketsPromise = self.fetch_spot_markets(params)
swapMarketsPromise = self.fetch_swap_markets(params)
optionMarketsPromise = self.fetch_option_markets(params)
spotMarkets, swapMarkets, optionMarkets = [spotMarketsPromise, swapMarketsPromise, optionMarketsPromise]
#
# {
# "id": "dd959aa7-d878-45b8-926d-3a247376de90",
# "result": {
# "instruments": [
# {
# "instrument_type": "perp",
# "instrument_name": "ZEC-PERP",
# "scheduled_activation": 1780572941,
# "scheduled_deactivation": 9223372036854775807,
# "is_active": true,
# "tick_size": "0.01",
# "minimum_amount": "1",
# "maximum_amount": "100000",
# "amount_step": "0.01",
# "mark_price_fee_rate_cap": "0",
# "maker_fee_rate": "0.0001",
# "taker_fee_rate": "0.0003",
# "base_fee": "0.01",
# "base_currency": "ZEC",
# "quote_currency": "USDC",
# "option_details": null,
# "perp_details": {
# "index": "ZEC-USD",
# "max_rate_per_hour": "0.000456621005",
# "min_rate_per_hour": "-0.000456621005",
# "aggregate_funding": "26.08805211207",
# "funding_rate": "0",
# "srm_perp_margin_requirements": {
# "im_perp_req": "0.15",
# "mm_perp_req": "0.1",
# "max_leverage": "6.67"
# }
# },
# "erc20_details": null,
# "base_asset_address": "0x7bF0D72275246A434151693c0EBBD38937dFE23b",
# "base_asset_sub_id": "0",
# "pro_rata_fraction": "0",
# "fifo_min_allocation": "0",
# "pro_rata_amount_step": "1"
# }
# ],
# "pagination": {
# "num_pages": 15,
# "count": 15
# }
# }
# }
#
result = self.array_concat(spotMarkets, swapMarkets)
result = self.array_concat(result, optionMarkets)
return result
def fetch_spot_markets(self, params: dict = {}) -> list[Market]:
request = {
'expired': False,
'instrument_type': 'erc20',
}
instruments = self.get_markets_paginated(request, params)
return self.parse_markets(instruments)
def fetch_swap_markets(self, params: dict = {}) -> list[Market]:
request = {
'expired': False,
'instrument_type': 'perp',
}
instruments = self.get_markets_paginated(request, params)
return self.parse_markets(instruments)
def fetch_option_markets(self, params: dict = {}) -> list[Market]:
request = {
'expired': False,
'instrument_type': 'option',
}
instruments = self.get_markets_paginated(request, params)
return self.parse_markets(instruments)
def get_markets_paginated(self, request: dict, params: dict = {}) -> list[dict]:
"""
@ignore
fetches every page of public/get_all_instruments for the given filter and parses the instruments; v3 paginates the endpoint, options alone exceed 5000 entries
:param dict request: the base request with the instrument_type filter
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict[]: an array of raw instrument entries
"""
allInstruments = []
maxPages, paramsMaxPages = self.handle_option_integer_and_params(params, 'getMarketsPaginated', 'maxMarketPages', 25)
pageSize, paramsOmitted = self.handle_option_integer_and_params(paramsMaxPages, 'getMarketsPaginated', 'maxMarketsPerPage', 1000)
for i in range(0, maxPages):
requestExtension = {
'page': i + 1,
'page_size': pageSize,
}
requestExtended = self.extend(self.extend(request, requestExtension), paramsOmitted) # nested because the csharp base defines extend with two arguments only
response = self.publicPostGetAllInstruments(requestExtended)
result = self.safe_dict(response, 'result', {})
data = self.safe_list(result, 'instruments', [])
allInstruments = self.array_concat(allInstruments, data)
pagination = self.safe_dict(result, 'pagination', {})
totalCount = self.safe_integer(pagination, 'count', 0) # not named count: that collides with the php builtin the length mapping expands to
collected = len(allInstruments)
if collected >= totalCount:
break
return allInstruments
def parse_market(self, market: dict) -> Market:
type = self.safe_string(market, 'instrument_type')
marketType = None
spot = False
margin = True
swap = False
option = False
linear = None
inverse = None
baseId = self.safe_string(market, 'base_currency')
quoteId = self.safe_string(market, 'quote_currency')
base = self.safe_currency_code(baseId)
quote = self.safe_currency_code(quoteId)
if (base is None) or (quote is None):
return None
marketId = self.safe_string(market, 'instrument_name')
symbol = base + '/' + quote
settleId = None
settle = None
expiry = None
strike = None
optionType = None
optionLetter = None
if type == 'erc20':
spot = True
marketType = 'spot'
elif type == 'perp':
margin = False
settleId = 'USDC'
settle = self.safe_currency_code(settleId)
if settle is not None:
symbol = base + '/' + quote + ':' + settle
swap = True
linear = True
inverse = False
marketType = 'swap'
elif type == 'option':
settleId = 'USDC'
settle = self.safe_currency_code(settleId)
margin = False
option = True
marketType = 'option'
optionDetails = self.safe_dict(market, 'option_details')
expiry = self.safe_timestamp(optionDetails, 'expiry')
strike = self.safe_number(optionDetails, 'strike') # strikes can be fractional, e.g. XRP-20261225-0_5-P is a 0.5 strike
optionLetter = self.safe_string(optionDetails, 'option_type')
if settle is not None:
symbol = base + '/' + quote + ':' + settle + '-' + self.yymmdd(expiry) + '-' + self.number_to_string(strike) + '-' + optionLetter
if optionLetter == 'P':
optionType = 'put'
else:
optionType = 'call'
linear = True
inverse = False
contractSize = None if (spot) else 1
return self.safe_market_structure({
'id': marketId,
'symbol': symbol,
'base': base,
'quote': quote,
'settle': settle,
'baseId': baseId,
'quoteId': quoteId,
'settleId': settleId,
'type': marketType,
'spot': spot,
'margin': margin,
'swap': swap,
'future': False,
'option': option,
'active': self.safe_bool(market, 'is_active'),
'contract': (swap or option),
'linear': linear,
'inverse': inverse,
'contractSize': contractSize,
'expiry': expiry,
'expiryDatetime': self.iso8601(expiry),
'taker': self.safe_number(market, 'taker_fee_rate'),
'maker': self.safe_number(market, 'maker_fee_rate'),
'strike': strike,
'optionType': optionType,
'precision': {
'amount': self.safe_number(market, 'amount_step'),
'price': self.safe_number(market, 'tick_size'),
},
'limits': {
'leverage': {
'min': None,
'max': None,
},
'amount': {
'min': self.safe_number(market, 'minimum_amount'),
'max': self.safe_number(market, 'maximum_amount'),
},
'price': {
'min': None,
'max': None,
},
'cost': {
'min': None,
'max': None,
},
},
'created': None,
'info': market,
})
def fetch_ticker(self, symbol: str, params: dict = {}) -> Ticker:
"""
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
https://docs.derive.xyz/api-reference/market-data/publicget_ticker
:param str symbol: unified symbol of the market to fetch the ticker for
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: a `ticker structure <https://docs.ccxt.com/?id=ticker-structure>`
"""
if self.markets is None:
self.load_markets()
market = self.market(symbol)
request = {
'instrument_name': market['id'],
}
response = self.publicPostGetTicker(self.extend(request, params))
#
# {
# "id": "45bb6856-54b7-48da-a9c1-1c3ba964888b",
# "result": {
# "t": 1790867526668,
# "A": "0",
# "a": "0",
# "B": "0",
# "b": "0",
# "f": "0.000012500",
# "option_pricing": null,
# "I": "83946.3",
# "M": "83938.8",
# "stats": {
# "c": "16.41",
# "v": "1377350.271",
# "pr": "1377095.872",
# "n": 98,
# "oi": "0",
# "h": "84282",
# "l": "83661.8",
# "p": "0"
# },
# "minp": "82293.1",
# "maxp": "85617.6"
# }
# }
#
data = self.safe_dict(response, 'result', {})
return self.parse_ticker(data, market)
def fetch_open_interest(self, symbol: str, params: dict = {}) -> OpenInterest:
"""
retrieves the open interest of a contract market
https://docs.derive.xyz/api-reference/market-data/publicget_ticker
:param str symbol: unified symbol of the market to fetch the open interest for
:param dict [params]: extra parameters specific to the exchange API endpoint
:returns dict: an `open interest structure <https://docs.ccxt.com/?id=open-interest-structure>`
"""
if self.markets is None:
self.load_markets()
market = self.market(symbol)
if not self.safe_bool(market, 'contract', False):
raise BadRequest(self.id + ' fetchOpenInterest() supports contract markets only')
request = {
'instrument_name': market['id'],
}
response = self.publicPostGetTicker(self.extend(request, params))
#
# {
# "id": "a24f964a-4c80-4389-950e-1f68b9bfb40f",
# "result": {
# "t": 1791026876172,
# "A": "5",
# "a": "84638.2",
# "B": "5",
# "b": "84634.2",
# "f": "0.000012500",
# "option_pricing": null,
# "I": "84622",
# "M": "84636.2",
# "stats": {
# "c": "1.797",
# "v": "154163.312",
# "pr": "154178.972",
# "n": 93,
# "oi": "291.023",
# "h": "87151.3",
# "l": "84034.2",
# "p": "-0.021"
# },
# "minp": "82976.7",
# "maxp": "86328.9"
View remainder of file in raw view
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.