GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — ccxt/python/ccxt/deribit.py at master · ccxt/ccxt Expand file tree/ Copy pathderibit.pyMore file actions 3850 lines (3697 loc) · 177 KB / Copy pathderibit.pyFile metadata and controls3850 lines (3697 loc) · 177 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 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.deribit import ImplicitAPI import hashlib from ccxt.base.types import Account, Balances, Currencies, Currency, CurrencyInterface, DepositAddress, Greeks, Int, Liquidation, Market, Num, Option, OptionChain, Order, OrderBook, OrderSide, OrderType, Position, Status, Str, Strings, Ticker, Tickers, FundingRate, OpenInterest, Trade, TradingFees, DepositWithdrawFees, Transaction, FundingRateHistory, MarketInterface, TransferEntry from ccxt.base.errors import ExchangeError from ccxt.base.errors import AuthenticationError from ccxt.base.errors import PermissionDenied from ccxt.base.errors import ArgumentsRequired from ccxt.base.errors import BadRequest from ccxt.base.errors import InsufficientFunds from ccxt.base.errors import InvalidAddress from ccxt.base.errors import InvalidOrder from ccxt.base.errors import OrderNotFound from ccxt.base.errors import NotSupported from ccxt.base.errors import DDoSProtection from ccxt.base.errors import ExchangeNotAvailable from ccxt.base.errors import OnMaintenance from ccxt.base.decimal_to_precision import TICK_SIZE from ccxt.base.precise import Precise class deribit(Exchange, ImplicitAPI): def describe(self) -> dict: return self.deep_extend(super(deribit, self).describe(), { 'id': 'deribit', 'name': 'Deribit', 'countries': ['NL'], # Netherlands 'version': 'v2', 'userAgent': None, # 20 requests per second for non-matching-engine endpoints, 1000ms / 20 = 50ms between requests # 5 requests per second for matching-engine endpoints, cost = (1000ms / rateLimit) / 5 = 4 'rateLimit': 50, 'pro': True, 'has': { 'CORS': True, 'spot': True, 'margin': False, 'swap': True, 'future': True, 'option': True, 'cancelAllOrders': True, 'cancelOrder': True, 'cancelOrders': False, 'createDepositAddress': True, 'createOrder': True, 'createReduceOnlyOrder': True, 'createStopLimitOrder': True, 'createStopMarketOrder': True, 'createStopOrder': True, 'createTrailingAmountOrder': True, 'editOrder': True, 'fetchAccounts': True, 'fetchBalance': True, 'fetchBorrowRateHistories': False, 'fetchBorrowRateHistory': False, 'fetchClosedOrders': True, 'fetchCrossBorrowRate': False, 'fetchCrossBorrowRates': False, 'fetchCurrencies': True, 'fetchDeposit': False, 'fetchDepositAddress': True, 'fetchDepositAddresses': False, 'fetchDepositAddressesByNetwork': False, 'fetchDeposits': True, 'fetchDepositWithdrawFees': True, 'fetchFundingRate': True, 'fetchFundingRateHistory': True, 'fetchGreeks': True, 'fetchIndexOHLCV': False, 'fetchIsolatedBorrowRate': False, 'fetchIsolatedBorrowRates': False, 'fetchLeverageTiers': False, 'fetchLiquidations': True, 'fetchMarginMode': False, 'fetchMarkets': True, 'fetchMarkOHLCV': False, 'fetchMyLiquidations': True, 'fetchMySettlementHistory': False, 'fetchMyTrades': True, 'fetchOHLCV': True, 'fetchOpenInterest': True, 'fetchOpenInterests': False, 'fetchOpenOrders': True, 'fetchOption': True, 'fetchOptionChain': True, 'fetchOrder': True, 'fetchOrderBook': True, 'fetchOrders': False, 'fetchOrderTrades': True, 'fetchPosition': True, 'fetchPositionMode': False, 'fetchPositions': True, 'fetchPremiumIndexOHLCV': False, 'fetchStatus': True, 'fetchTicker': True, 'fetchTickers': True, 'fetchTime': True, 'fetchTrades': True, 'fetchTradingFee': False, 'fetchTradingFees': True, 'fetchTransactions': False, 'fetchTransfer': False, 'fetchTransfers': True, 'fetchUnderlyingAssets': False, 'fetchVolatilityHistory': True, 'fetchWithdrawal': False, 'fetchWithdrawals': True, 'sandbox': True, 'transfer': True, 'withdraw': True, }, 'timeframes': { '1m': '1', '3m': '3', '5m': '5', '10m': '10', '15m': '15', '30m': '30', '1h': '60', '2h': '120', '3h': '180', '6h': '360', '12h': '720', '1d': '1D', }, 'urls': { 'test': { 'rest': 'https://test.deribit.com', }, 'logo': 'https://user-images.githubusercontent.com/1294454/41933112-9e2dd65a-798b-11e8-8440-5bab2959fcb8.jpg', 'api': { 'rest': 'https://www.deribit.com', }, 'www': 'https://www.deribit.com', 'doc': [ 'https://docs.deribit.com', 'https://github.com/deribit', ], 'fees': 'https://www.deribit.com/pages/information/fees', 'referral': { 'url': 'https://www.deribit.com/reg-1189.4038', 'discount': 0.1, }, }, 'api': { 'public': { 'get': { # Authentication 'auth': {'cost': 1}, 'exchange_token': {'cost': 1}, 'fork_token': {'cost': 1}, # Session management 'set_heartbeat': {'cost': 1}, 'disable_heartbeat': {'cost': 1}, # Supporting 'get_time': {'cost': 1}, 'hello': {'cost': 1}, 'status': {'cost': 1}, 'test': {'cost': 1}, # Subscription management 'subscribe': {'cost': 1}, 'unsubscribe': {'cost': 1}, 'unsubscribe_all': {'cost': 1}, # Account management 'get_announcements': {'cost': 1}, # Market data 'get_apr_history': {'cost': 1}, 'get_book_summary_by_currency': {'cost': 1}, 'get_book_summary_by_instrument': {'cost': 1}, 'get_contract_size': {'cost': 1}, 'get_currencies': {'cost': 1}, 'get_delivery_prices': {'cost': 1}, 'get_expirations': {'cost': 1}, 'get_funding_chart_data': {'cost': 1}, 'get_funding_rate_history': {'cost': 1}, 'get_funding_rate_value': {'cost': 1}, 'get_historical_volatility': {'cost': 1}, 'get_index': {'cost': 1}, 'get_index_chart_data': {'cost': 1}, 'get_index_price': {'cost': 1}, 'get_index_price_names': {'cost': 1}, 'get_instrument': {'cost': 1}, 'get_instruments': {'cost': 1}, 'get_last_settlements_by_currency': {'cost': 1}, 'get_last_settlements_by_instrument': {'cost': 1}, 'get_last_trades_by_currency': {'cost': 1}, 'get_last_trades_by_currency_and_time': {'cost': 1}, 'get_last_trades_by_instrument': {'cost': 1}, 'get_last_trades_by_instrument_and_time': {'cost': 1}, 'get_mark_price_history': {'cost': 1}, 'get_order_book': {'cost': 1}, 'get_supported_index_names': {'cost': 1}, 'get_trade_volumes': {'cost': 1}, 'get_tradingview_chart_data': {'cost': 1}, 'get_volatility_index_data': {'cost': 1}, 'ticker': {'cost': 1}, }, }, 'private': { 'get': { # Authentication 'logout': {'cost': 1}, # Session management 'enable_cancel_on_disconnect': {'cost': 1}, 'disable_cancel_on_disconnect': {'cost': 1}, 'get_cancel_on_disconnect': {'cost': 1}, # Subscription management 'subscribe': {'cost': 1}, 'unsubscribe': {'cost': 1}, 'unsubscribe_all': {'cost': 1}, # Account management 'change_api_key_name': {'cost': 1}, 'change_scope_in_api_key': {'cost': 1}, 'change_subaccount_name': {'cost': 1}, 'create_api_key': {'cost': 1}, 'create_subaccount': {'cost': 1}, 'disable_api_key': {'cost': 1}, 'disable_tfa_for_subaccount': {'cost': 1}, 'enable_affiliate_program': {'cost': 1}, 'enable_api_key': {'cost': 1}, 'get_access_log': {'cost': 1}, 'get_account_summary': {'cost': 1}, 'get_account_summaries': {'cost': 1}, 'get_affiliate_program_info': {'cost': 1}, 'get_currencies': {'cost': 1}, 'get_email_language': {'cost': 1}, 'get_new_announcements': {'cost': 1}, 'get_portfolio_margins': {'cost': 1}, 'get_position': {'cost': 1}, 'get_positions': {'cost': 1}, 'get_subaccounts': {'cost': 1}, 'get_subaccounts_details': {'cost': 1}, 'get_transaction_log': {'cost': 1}, 'list_api_keys': {'cost': 1}, 'remove_api_key': {'cost': 1}, 'remove_subaccount': {'cost': 1}, 'reset_api_key': {'cost': 1}, 'set_announcement_as_read': {'cost': 1}, 'set_api_key_as_default': {'cost': 1}, 'set_disabled_trading_products': {'cost': 1}, 'set_email_for_subaccount': {'cost': 1}, 'set_email_language': {'cost': 1}, 'set_password_for_subaccount': {'cost': 1}, 'simulate_portfolio': {'cost': 1}, 'toggle_notifications_from_subaccount': {'cost': 1}, 'toggle_subaccount_login': {'cost': 1}, # Block Trade 'approve_block_trade': {'cost': 1}, 'execute_block_trade': {'cost': 4}, 'get_block_trade': {'cost': 1}, 'get_block_trade_requests': {'cost': 1}, 'get_block_trades': {'cost': 1}, 'get_last_block_trades_by_currency': {'cost': 1}, 'invalidate_block_trade_signature': {'cost': 1}, 'reject_block_trade': {'cost': 1}, 'simulate_block_trade': {'cost': 4}, 'verify_block_trade': {'cost': 4}, # Trading 'buy': {'cost': 4}, 'sell': {'cost': 4}, 'edit': {'cost': 4}, 'edit_by_label': {'cost': 4}, 'cancel': {'cost': 4}, 'cancel_all': {'cost': 4}, 'cancel_all_by_currency': {'cost': 4}, 'cancel_all_by_instrument': {'cost': 4}, 'cancel_by_label': {'cost': 4}, 'cancel_quotes': {'cost': 4}, 'close_position': {'cost': 4}, 'get_margins': {'cost': 1}, 'get_mmp_config': {'cost': 1}, 'get_mmp_status': {'cost': 1}, 'get_open_orders': {'cost': 1}, 'get_open_orders_by_currency': {'cost': 1}, 'get_open_orders_by_instrument': {'cost': 1}, 'get_open_orders_by_label': {'cost': 1}, 'get_order_history_by_currency': {'cost': 1}, 'get_order_history_by_instrument': {'cost': 1}, 'get_order_margin_by_ids': {'cost': 1}, 'get_order_state': {'cost': 1}, 'get_order_state_by_label': {'cost': 1}, 'get_stop_order_history': {'cost': 1}, # deprecated 'get_trigger_order_history': {'cost': 1}, 'get_user_trades_by_currency': {'cost': 1}, 'get_user_trades_by_currency_and_time': {'cost': 1}, 'get_user_trades_by_instrument': {'cost': 1}, 'get_user_trades_by_instrument_and_time': {'cost': 1}, 'get_user_trades_by_order': {'cost': 1}, 'mass_quote': {'cost': 4}, 'move_positions': {'cost': 4}, 'reset_mmp': {'cost': 1}, 'set_mmp_config': {'cost': 1}, 'get_settlement_history_by_instrument': {'cost': 1}, 'get_settlement_history_by_currency': {'cost': 1}, # Wallet 'add_to_address_book': {'cost': 1}, 'cancel_transfer_by_id': {'cost': 1}, 'cancel_withdrawal': {'cost': 1}, 'create_deposit_address': {'cost': 1}, 'get_address_book': {'cost': 1}, 'get_current_deposit_address': {'cost': 1}, 'get_deposits': {'cost': 1}, 'get_reward_eligibility': {'cost': 1}, 'get_transfers': {'cost': 1}, 'get_withdrawals': {'cost': 1}, 'remove_from_address_book': {'cost': 1}, 'set_clearance_originator': {'cost': 1}, 'submit_transfer_to_subaccount': {'cost': 1}, 'submit_transfer_to_user': {'cost': 1}, 'update_in_address_book': {'cost': 1}, 'withdraw': {'cost': 1}, }, }, }, 'features': { 'default': { 'sandbox': True, 'createOrder': { 'marginMode': False, 'triggerPrice': True, # todo # todo implement 'triggerPriceType': { 'last': True, 'mark': True, 'index': True, }, 'triggerDirection': False, 'stopLossPrice': False, # todo 'takeProfitPrice': False, # todo 'attachedStopLossTakeProfit': None, 'timeInForce': { 'IOC': True, 'FOK': True, 'PO': True, 'GTD': True, }, 'hedged': False, 'selfTradePrevention': False, 'trailing': True, # todo 'leverage': False, 'marketBuyByCost': True, # todo 'marketBuyRequiresPrice': False, 'iceberg': True, # todo }, 'createOrders': None, 'fetchMyTrades': { 'marginMode': False, 'limit': 100, # todo: revise 'daysBack': 100000, 'untilDays': 100000, 'symbolRequired': True, # todo }, 'fetchOrder': { 'marginMode': False, 'trigger': False, 'trailing': False, 'symbolRequired': True, # todo }, 'fetchOpenOrders': { 'marginMode': False, 'limit': None, 'trigger': False, 'trailing': False, 'symbolRequired': True, # todo }, 'fetchOrders': None, 'fetchClosedOrders': { 'marginMode': False, 'limit': 100, 'daysBack': 100000, 'daysBackCanceled': 1, 'untilDays': 100000, 'trigger': False, 'trailing': False, 'symbolRequired': True, # todo }, 'fetchOHLCV': { 'limit': 1000, # todo: recheck }, }, 'spot': { 'extends': 'default', }, 'swap': { 'linear': { 'extends': 'default', }, 'inverse': { 'extends': 'default', }, }, 'future': { 'linear': { 'extends': 'default', }, 'inverse': { 'extends': 'default', }, }, }, 'exceptions': { # 0 or absent Success, No error. '9999': PermissionDenied, # 'api_not_enabled' User didn't enable API for the Account. '10000': AuthenticationError, # 'authorization_required' Authorization issue, invalid or absent signature etc. '10001': ExchangeError, # 'error' Some general failure, no public information available. '10002': InvalidOrder, # 'qty_too_low' Order quantity is too low. '10003': InvalidOrder, # 'order_overlap' Rejection, order overlap is found and self-trading is not enabled. '10004': OrderNotFound, # 'order_not_found' Attempt to operate with order that can't be found by specified id. '10005': InvalidOrder, # 'price_too_low <Limit>' Price is too low, <Limit> defines current limit for the operation. '10006': InvalidOrder, # 'price_too_low4idx <Limit>' Price is too low for current index, <Limit> defines current bottom limit for the operation. '10007': InvalidOrder, # 'price_too_high <Limit>' Price is too high, <Limit> defines current up limit for the operation. '10008': InvalidOrder, # 'price_too_high4idx <Limit>' Price is too high for current index, <Limit> defines current up limit for the operation. '10009': InsufficientFunds, # 'not_enough_funds' Account has not enough funds for the operation. '10010': OrderNotFound, # 'already_closed' Attempt of doing something with closed order. '10011': InvalidOrder, # 'price_not_allowed' This price is not allowed for some reason. '10012': InvalidOrder, # 'book_closed' Operation for instrument which order book had been closed. '10013': PermissionDenied, # 'pme_max_total_open_orders <Limit>' Total limit of open orders has been exceeded, it is applicable for PME users. '10014': PermissionDenied, # 'pme_max_future_open_orders <Limit>' Limit of count of futures' open orders has been exceeded, it is applicable for PME users. '10015': PermissionDenied, # 'pme_max_option_open_orders <Limit>' Limit of count of options' open orders has been exceeded, it is applicable for PME users. '10016': PermissionDenied, # 'pme_max_future_open_orders_size <Limit>' Limit of size for futures has been exceeded, it is applicable for PME users. '10017': PermissionDenied, # 'pme_max_option_open_orders_size <Limit>' Limit of size for options has been exceeded, it is applicable for PME users. '10018': PermissionDenied, # 'non_pme_max_future_position_size <Limit>' Limit of size for futures has been exceeded, it is applicable for non-PME users. '10019': PermissionDenied, # 'locked_by_admin' Trading is temporary locked by admin. '10020': ExchangeError, # 'invalid_or_unsupported_instrument' Instrument name is not valid. '10021': InvalidOrder, # 'invalid_amount' Amount is not valid. '10022': InvalidOrder, # 'invalid_quantity' quantity was not recognized as a valid number (for API v1). '10023': InvalidOrder, # 'invalid_price' price was not recognized as a valid number. '10024': InvalidOrder, # 'invalid_max_show' max_show parameter was not recognized as a valid number. '10025': InvalidOrder, # 'invalid_order_id' Order id is missing or its format was not recognized as valid. '10026': InvalidOrder, # 'price_precision_exceeded' Extra precision of the price is not supported. '10027': InvalidOrder, # 'non_integer_contract_amount' Futures contract amount was not recognized as integer. '10028': DDoSProtection, # 'too_many_requests' Allowed request rate has been exceeded. '10029': OrderNotFound, # 'not_owner_of_order' Attempt to operate with not own order. '10030': ExchangeError, # 'must_be_websocket_request' REST request where Websocket is expected. '10031': ExchangeError, # 'invalid_args_for_instrument' Some of arguments are not recognized as valid. '10032': InvalidOrder, # 'whole_cost_too_low' Total cost is too low. '10033': NotSupported, # 'not_implemented' Method is not implemented yet. '10034': InvalidOrder, # 'stop_price_too_high' Stop price is too high. '10035': InvalidOrder, # 'stop_price_too_low' Stop price is too low. '10036': InvalidOrder, # 'invalid_max_show_amount' Max Show Amount is not valid. '10040': ExchangeNotAvailable, # 'retry' Request can't be processed right now and should be retried. '10041': OnMaintenance, # 'settlement_in_progress' Settlement is in progress. Every day at settlement time for several seconds, the system calculates user profits and updates balances. That time trading is paused for several seconds till the calculation is completed. '10043': InvalidOrder, # 'price_wrong_tick' Price has to be rounded to a certain tick size. '10044': InvalidOrder, # 'stop_price_wrong_tick' Stop Price has to be rounded to a certain tick size. '10045': InvalidOrder, # 'can_not_cancel_liquidation_order' Liquidation order can't be canceled. '10046': InvalidOrder, # 'can_not_edit_liquidation_order' Liquidation order can't be edited. '10047': DDoSProtection, # 'matching_engine_queue_full' Reached limit of pending Matching Engine requests for user. '10048': ExchangeError, # 'not_on_this_server' The requested operation is not available on this server. '11008': InvalidOrder, # 'already_filled' This request is not allowed in regards to the filled order. '11029': BadRequest, # 'invalid_arguments' Some invalid input has been detected. '11030': ExchangeError, # 'other_reject <Reason>' Some rejects which are not considered as very often, more info may be specified in <Reason>. '11031': ExchangeError, # 'other_error <Error>' Some errors which are not considered as very often, more info may be specified in <Error>. '11035': DDoSProtection, # 'no_more_stops <Limit>' Allowed amount of stop orders has been exceeded. '11036': InvalidOrder, # 'invalid_stoppx_for_index_or_last' Invalid StopPx (too high or too low) as to current index or market. '11037': BadRequest, # 'outdated_instrument_for_IV_order' Instrument already not available for trading. '11038': InvalidOrder, # 'no_adv_for_futures' Advanced orders are not available for futures. '11039': InvalidOrder, # 'no_adv_postonly' Advanced post-only orders are not supported yet. '11041': InvalidOrder, # 'not_adv_order' Advanced order properties can't be set if the order is not advanced. '11042': PermissionDenied, # 'permission_denied' Permission for the operation has been denied. '11043': BadRequest, # 'bad_argument' Bad argument has been passed. '11044': InvalidOrder, # 'not_open_order' Attempt to do open order operations with the not open order. '11045': BadRequest, # 'invalid_event' Event name has not been recognized. '11046': BadRequest, # 'outdated_instrument' At several minutes to instrument expiration, corresponding advanced implied volatility orders are not allowed. '11047': BadRequest, # 'unsupported_arg_combination' The specified combination of arguments is not supported. '11048': ExchangeError, # 'wrong_max_show_for_option' Wrong Max Show for options. '11049': BadRequest, # 'bad_arguments' Several bad arguments have been passed. '11050': BadRequest, # 'bad_request' Request has not been parsed properly. '11051': OnMaintenance, # 'system_maintenance' System is under maintenance. '11052': ExchangeError, # 'subscribe_error_unsubscribed' Subscription error. However, subscription may fail without this error, please check list of subscribed channels returned, as some channels can be not subscribed due to wrong input or lack of permissions. '11053': ExchangeError, # 'transfer_not_found' Specified transfer is not found. '11090': InvalidAddress, # 'invalid_addr' Invalid address. '11091': InvalidAddress, # 'invalid_transfer_address' Invalid addres for the transfer. '11092': InvalidAddress, # 'address_already_exist' The address already exists. '11093': DDoSProtection, # 'max_addr_count_exceeded' Limit of allowed addresses has been reached. '11094': ExchangeError, # 'internal_server_error' Some unhandled error on server. Please report to admin. The details of the request will help to locate the problem. '11095': ExchangeError, # 'disabled_deposit_address_creation' Deposit address creation has been disabled by admin. '11096': ExchangeError, # 'address_belongs_to_user' Withdrawal instead of transfer. '12000': AuthenticationError, # 'bad_tfa' Wrong TFA code '12001': DDoSProtection, # 'too_many_subaccounts' Limit of subbacounts is reached. '12002': ExchangeError, # 'wrong_subaccount_name' The input is not allowed as name of subaccount. '12998': AuthenticationError, # 'tfa_over_limit' The number of failed TFA attempts is limited. '12003': AuthenticationError, # 'login_over_limit' The number of failed login attempts is limited. '12004': AuthenticationError, # 'registration_over_limit' The number of registration requests is limited. '12005': AuthenticationError, # 'country_is_banned' The country is banned (possibly via IP check). '12100': ExchangeError, # 'transfer_not_allowed' Transfer is not allowed. Possible wrong direction or other mistake. '12999': AuthenticationError, # 'tfa_used' TFA code is correct but it is already used. Please, use next code. '13000': AuthenticationError, # 'invalid_login' Login name is invalid (not allowed or it contains wrong characters). '13001': AuthenticationError, # 'account_not_activated' Account must be activated. '13002': PermissionDenied, # 'account_blocked' Account is blocked by admin. '13003': AuthenticationError, # 'tfa_required' This action requires TFA authentication. '13004': AuthenticationError, # 'invalid_credentials' Invalid credentials has been used. '13005': AuthenticationError, # 'pwd_match_error' Password confirmation error. '13006': AuthenticationError, # 'security_error' Invalid Security Code. '13007': AuthenticationError, # 'user_not_found' User's security code has been changed or wrong. '13008': ExchangeError, # 'request_failed' Request failed because of invalid input or internal failure. '13009': AuthenticationError, # 'unauthorized' Wrong or expired authorization token or bad signature. For example, please check scope of the token, 'connection' scope can't be reused for other connections. '13010': BadRequest, # 'value_required' Invalid input, missing value. '13011': BadRequest, # 'value_too_short' Input is too short. '13012': PermissionDenied, # 'unavailable_in_subaccount' Subaccount restrictions. '13013': BadRequest, # 'invalid_phone_number' Unsupported or invalid phone number. '13014': BadRequest, # 'cannot_send_sms' SMS sending failed -- phone number is wrong. '13015': BadRequest, # 'invalid_sms_code' Invalid SMS code. '13016': BadRequest, # 'invalid_input' Invalid input. '13017': ExchangeError, # 'subscription_failed' Subscription hailed, invalid subscription parameters. '13018': ExchangeError, # 'invalid_content_type' Invalid content type of the request. '13019': ExchangeError, # 'orderbook_closed' Closed, expired order book. '13020': ExchangeError, # 'not_found' Instrument is not found, invalid instrument name. '13021': PermissionDenied, # 'forbidden' Not enough permissions to execute the request, forbidden. '13025': ExchangeError, # 'method_switched_off_by_admin' API method temporarily switched off by administrator. '-32602': BadRequest, # 'Invalid params' see JSON-RPC spec. '-32601': BadRequest, # 'Method not found' see JSON-RPC spec. '-32700': BadRequest, # 'Parse error' see JSON-RPC spec. '-32000': BadRequest, # 'Missing params' see JSON-RPC spec. '11054': InvalidOrder, # 'post_only_reject' post order would be filled immediately }, 'precisionMode': TICK_SIZE, 'options': { 'code': 'BTC', 'fetchBalance': { 'code': 'BTC', }, 'transfer': { 'method': 'privateGetSubmitTransferToSubaccount', # or 'privateGetSubmitTransferToUser' }, }, }) def create_expired_option_market(self, symbol: str) -> MarketInterface: # support expired option contracts quote = 'USD' settle = '' optionParts = symbol.split('-') symbolBase = symbol.split('/') hasSlash = symbol.find('/') > -1 hasUsdc = symbol.find('USDC') > -1 base = None expiry = None if hasSlash: base = self.safe_string(symbolBase, 0, '') expiry = self.safe_string(optionParts, 1) else: base = self.safe_string(optionParts, 0, '') expiry = self.convert_market_id_expire_date(self.safe_string(optionParts, 1)) if base is None: raise ExchangeError(self.id + ' createExpiredOptionMarket() missing base') # the slash form of a usdc instrument carries its settlement currency in the base baseSuffix = '' if hasSlash and hasUsdc: baseSuffix = '_USDC' baseResolved = base + baseSuffix if hasUsdc: quote = 'USDC' settle = 'USDC' else: # no usdc suffix on this path, so the resolved base is the settle currency settle = baseResolved # the part of the base before the first underscore, or the whole base when it has none splitBase = self.safe_string(baseResolved.split('_'), 0, '') strike = self.safe_string(optionParts, 2, '') optionType = self.safe_string(optionParts, 3, '') datetime = self.convert_expire_date(expiry) return { 'id': baseResolved + '-' + self.convert_expire_date_to_market_id_date(expiry) + ('-' + strike + '-' + optionType), 'symbol': splitBase + '/' + quote + ':' + settle + '-' + expiry + ('-' + strike + '-' + optionType), 'base': baseResolved, 'quote': quote, 'settle': settle, 'baseId': baseResolved, 'quoteId': quote, 'settleId': settle, 'active': False, 'type': 'option', 'linear': None, 'inverse': None, 'spot': False, 'swap': False, 'future': False, 'option': True, 'margin': False, 'contract': True, 'contractSize': None, 'expiry': self.parse8601(datetime), 'expiryDatetime': datetime, 'optionType': 'call' if (optionType == 'C') else 'put', 'strike': self.parse_number(strike), 'precision': { 'amount': None, 'price': None, }, 'limits': { 'amount': { 'min': None, 'max': None, }, 'price': { 'min': None, 'max': None, }, 'cost': { 'min': None, 'max': None, }, }, 'info': None, } def safe_market(self, marketId: Str = None, market: Market = None, delimiter: Str = None, marketType: Str = None) -> MarketInterface: isOption = (marketId is not None) and ((marketId.endswith('-C')) or (marketId.endswith('-P'))) if isOption and ((self.markets_by_id is None) or not (marketId in self.markets_by_id)): # handle expired option contracts return self.create_expired_option_market(marketId) return super(deribit, self).safe_market(marketId, market, delimiter, marketType) def fetch_time(self, params: dict = {}) -> Int: """ fetches the current integer timestamp in milliseconds from the exchange server https://docs.deribit.com/api-reference/supporting/public-get_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.publicGetGetTime(params) # # { # "jsonrpc": "2.0", # "result": 1583922446019, # "usIn": 1583922446019955, # "usOut": 1583922446019956, # "usDiff": 1, # "testnet": false # } # return self.safe_integer(response, 'result') def fetch_currencies(self, params: dict = {}) -> Currencies: """ fetches all available currencies on an exchange https://docs.deribit.com/api-reference/market-data/public-get_currencies :param dict [params]: extra parameters specific to the exchange API endpoint :returns dict: an associative dictionary of currencies """ response = self.publicGetGetCurrencies(params) # # { # "jsonrpc": "2.0", # "result": [ # { # "currency": "XRP", # "network_fee": "1.5e-5", # "min_withdrawal_fee": "0.0001", # "apr": "0.0", # "withdrawal_fee": "0.0001", # "network_currency": "XRP", # "coin_type": "XRP", # "withdrawal_priorities": [], # "min_confirmations": "1", # "currency_long": "XRP", # "in_cross_collateral_pool": false # }, # ], # "usIn": "1760110326693923", # "usOut": "1760110326944891", # "usDiff": "250968", # "testnet": false # } # data = self.safe_list(response, 'result', []) return self.parse_currencies(data) def parse_currency(self, rawCurrency: dict) -> CurrencyInterface: currencyId = self.safe_string(rawCurrency, 'currency') code = self.safe_currency_code(currencyId) return self.safe_currency_structure({ 'info': rawCurrency, 'code': code, 'id': currencyId, 'name': self.safe_string(rawCurrency, 'currency_long'), 'active': None, 'deposit': None, 'withdraw': None, 'type': 'crypto', 'fee': self.safe_number(rawCurrency, 'withdrawal_fee'), 'precision': None, 'limits': { 'amount': { 'min': None, 'max': None, }, 'withdraw': { 'min': None, 'max': None, }, 'deposit': { 'min': None, 'max': None, }, }, 'networks': None, }) def code_from_options(self, methodName: Str, params: dict = {}) -> Str: defaultCode = self.safe_string(self.options, 'code', 'BTC') options = self.safe_dict(self.options, methodName, {}) code = self.safe_string(options, 'code', defaultCode) return self.safe_string(params, 'code', code) def fetch_status(self, params: dict = {}) -> Status: """ the latest known information on the availability of the exchange API https://docs.deribit.com/api-reference/supporting/public-status :param dict [params]: extra parameters specific to the exchange API endpoint :returns dict: a `status structure <https://docs.ccxt.com/?id=exchange-status-structure>` """ response = self.publicGetStatus(params) # # { # "jsonrpc": "2.0", # "result": { # "locked": "false" // true, partial, false # }, # "usIn": 1650641690226788, # "usOut": 1650641690226836, # "usDiff": 48, # "testnet": false # } # result = self.safe_dict(response, 'result') locked = self.safe_string(result, 'locked') updateTime = self.safe_integer_product(response, 'usIn', 0.001, self.milliseconds()) return { 'status': 'ok' if (locked == 'false') else 'maintenance', 'updated': updateTime, 'eta': None, 'url': None, 'info': response, } def fetch_accounts(self, params: dict = {}) -> list[Account]: """ fetch all the accounts associated with a profile https://docs.deribit.com/api-reference/account-management/private-get_subaccounts :param dict [params]: extra parameters specific to the exchange API endpoint :returns dict: a dictionary of `account structures <https://docs.ccxt.com/?id=account-structure>` indexed by the account type """ if self.markets is None: self.load_markets() response = self.privateGetGetSubaccounts(params) # # { # "jsonrpc": "2.0", # "result": [{ # "username": "someusername", # "type": "main", # "system_name": "someusername", # "security_keys_enabled": false, # "security_keys_assignments": [], # "receive_notifications": false, # "login_enabled": true, # "is_password": true, # "id": "238216", # "email": "[email protected]" # }, # { # "username": "someusername_1", # "type": "subaccount", # "system_name": "someusername_1", # "security_keys_enabled": false, # "security_keys_assignments": [], # "receive_notifications": false, # "login_enabled": false, # "is_password": false, # "id": "245499", # "email": "[email protected]" # } # ], # "usIn": "1652736468292006", # "usOut": "1652736468292377", # "usDiff": "371", # "testnet": false # } # result = self.safe_list(response, 'result', []) return self.parse_accounts(result) def parse_account(self, account: dict) -> Account: # # { # "username": "someusername_1", # "type": "subaccount", # "system_name": "someusername_1", # "security_keys_enabled": false, # "security_keys_assignments": [], # "receive_notifications": false, # "login_enabled": false, # "is_password": false, # "id": "245499", # "email": "[email protected]" # } # return { 'info': account, 'id': self.safe_string(account, 'id'), 'type': self.safe_string(account, 'type'), 'code': None, } def fetch_markets(self, params: dict = {}) -> list[Market]: """ retrieves data on all markets for deribit https://docs.deribit.com/api-reference/market-data/public-get_currencies https://docs.deribit.com/api-reference/market-data/public-get_instruments :param dict [params]: extra parameters specific to the exchange API endpoint :returns dict[]: an array of objects representing market data """ instrumentsResponses = [] result = [] parsedMarkets = {} fetchAllMarkets, paramsFetchAllMarkets = self.handle_option_bool_and_params(params, 'fetchMarkets', 'fetchAllMarkets', True) if fetchAllMarkets: instrumentsResponse = self.publicGetGetInstruments(paramsFetchAllMarkets) instrumentsResponses.append(instrumentsResponse) else: currenciesResponse = self.publicGetGetCurrencies(paramsFetchAllMarkets) # # { # "jsonrpc": "2.0", # "result": [ # { # "withdrawal_priorities": [ # { value: 0.15, name: "very_low" }, # { value: 1.5, name: "very_high" }, # ], # "withdrawal_fee": 0.0005, # "min_withdrawal_fee": 0.0005, # "min_confirmations": 1, # "fee_precision": 4, # "currency_long": "Bitcoin", # "currency": "BTC", # "coin_type": "BITCOIN" # } # ], # "usIn": 1583761588590479, # "usOut": 1583761588590544, # "usDiff": 65, # "testnet": false # } # currenciesResult = self.safe_list(currenciesResponse, 'result', []) for i in range(0, len(currenciesResult)): currencyId = self.safe_string(currenciesResult[i], 'currency') request = { 'currency': currencyId, } instrumentsResponse = self.publicGetGetInstruments(self.extend(request, paramsFetchAllMarkets)) # # { # "jsonrpc":"2.0", # "result":[ # { # "tick_size":0.0005, # "taker_commission":0.0003, # "strike":52000.0, # "settlement_period":"month", # "settlement_currency":"BTC", # "quote_currency":"BTC", # "option_type":"put", // put, call # "min_trade_amount":0.1, # "maker_commission":0.0003, # "kind":"option", # "is_active":true, # "instrument_name":"BTC-24JUN22-52000-P", # "expiration_timestamp":1656057600000, # "creation_timestamp":1648199543000, # "counter_currency":"USD", # "contract_size":1.0, # "block_trade_commission":0.0003, # "base_currency":"BTC" # }, # { # "tick_size":0.5, # "taker_commission":0.0005, # "settlement_period":"month", // month, week # "settlement_currency":"BTC", # "quote_currency":"USD", # "min_trade_amount":10.0, # "max_liquidation_commission":0.0075, # "max_leverage":50, # "maker_commission":0.0, # "kind":"future", # "is_active":true, # "instrument_name":"BTC-27MAY22", # "future_type":"reversed", # "expiration_timestamp":1653638400000, # "creation_timestamp":1648195209000, # "counter_currency":"USD", # "contract_size":10.0, # "block_trade_commission":0.0001, # "base_currency":"BTC" # }, # { # "tick_size":0.5, # "taker_commission":0.0005, # "settlement_period":"perpetual", # "settlement_currency":"BTC", # "quote_currency":"USD", # "min_trade_amount":10.0, # "max_liquidation_commission":0.0075, # "max_leverage":50, # "maker_commission":0.0, # "kind":"future", # "is_active":true, # "instrument_name":"BTC-PERPETUAL", # "future_type":"reversed", # "expiration_timestamp":32503708800000, # "creation_timestamp":1534242287000, # "counter_currency":"USD", # "contract_size":10.0, # "block_trade_commission":0.0001, # "base_currency":"BTC" # }, # ], # "usIn":1648691472831791, # "usOut":1648691472831896, # "usDiff":105, # "testnet":false # } # instrumentsResponses.append(instrumentsResponse) for i in range(0, len(instrumentsResponses)): instrumentsResult = self.safe_list(instrumentsResponses[i], 'result', []) for k in range(0, len(instrumentsResult)): market = instrumentsResult[k] kind = self.safe_string(market, 'kind') isSpot = (kind == 'spot') id = self.safe_string(market, 'instrument_name') baseId = self.safe_string(market, 'base_currency') quoteId = self.safe_string(market, 'counter_currency') settleId = self.safe_string(market, 'settlement_currency') base = self.safe_currency_code(baseId) quote = self.safe_currency_code(quoteId) if (base is None) or (quote is None): continue settle = self.safe_currency_code(settleId) settlementPeriod = self.safe_string(market, 'settlement_period') swap = (settlementPeriod == 'perpetual') if kind is None: raise ExchangeError(self.id + ' method() missing kind') future = not swap and (kind.find('future') >= 0) if kind is None: raise ExchangeError(self.id + ' method() missing kind') option = (kind.find('option') >= 0) if kind is None: raise ExchangeError(self.id + ' method() missing kind') isComboMarket = kind.find('combo') >= 0 expiry = self.safe_integer(market, 'expiration_timestamp') strike = None optionType = None symbol = id type = 'swap' if future: type = 'future' elif option: type = 'option' elif isSpot: type = 'spot' inverse = None linear = None if isSpot: symbol = base + '/' + quote elif not isComboMarket: symbol = base + '/' + quote + ':' + settle if option or future: symbol = symbol + '-' + self.yymmdd(expiry, '') if option: strike = self.safe_number(market, 'strike') optionType = self.safe_string(market, 'option_type') letter = 'C' if (optionType == 'call') else 'P' symbol = symbol + '-' + self.number_to_string(strike) + '-' + letter inverse = (quote != settle) linear = (settle == quote) parsedMarketValue = self.safe_bool(parsedMarkets, symbol) if parsedMarketValue is not None: continue if symbol is not None: parsedMarkets[symbol] = True |
| 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. |