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/extended.py at master · ccxt/ccxt Expand file tree/ Copy pathextended.pyMore file actions 3395 lines (3233 loc) · 157 KB / Copy pathextended.pyFile metadata and controls3395 lines (3233 loc) · 157 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.extended import ImplicitAPI import math import json from ccxt.base.types import Account, Balances, Currencies, Currency, CurrencyInterface, FundingHistory, Int, LedgerEntry, Leverage, Market, Num, Order, OrderBook, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, OpenInterest, Trade, TradingFeeInterface, TradingFees, 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.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.decimal_to_precision import NO_PADDING from ccxt.base.precise import Precise class extended(Exchange, ImplicitAPI): def describe(self) -> dict: return self.deep_extend(super(extended, self).describe(), { 'id': 'extended', 'name': 'Extended', 'countries': ['SG'], 'version': 'v2', 'rateLimit': 600, # Default Tier 1,000 requests/minute ≈ 1.67 request per second 'precisionMode': TICK_SIZE, 'certified': False, 'pro': True, 'dex': True, 'has': { 'CORS': None, 'spot': False, # venue retired spot trading; SPOT rows are still parsed, see parseMarket 'margin': False, 'swap': True, 'future': False, 'option': False, 'addMargin': False, 'borrowCrossMargin': False, 'borrowIsolatedMargin': False, 'cancelAllOrders': True, 'cancelAllOrdersAfter': True, 'cancelOrder': True, 'cancelOrders': True, 'closeAllPositions': False, 'closePosition': False, 'createConvertTrade': False, 'createDepositAddress': False, 'createMarketBuyOrderWithCost': False, 'createMarketOrderWithCost': False, 'createMarketSellOrderWithCost': False, 'createOrder': True, 'createOrders': False, 'createOrderWithTakeProfitAndStopLoss': False, 'createPostOnlyOrder': False, 'createReduceOnlyOrder': False, 'createStopLimitOrder': False, 'createStopLossOrder': False, 'createStopMarketOrder': False, 'createStopOrder': False, 'createTakeProfitOrder': False, 'createTrailingAmountOrder': False, 'createTrailingPercentOrder': False, 'createTriggerOrder': False, 'editOrder': True, 'fetchAccounts': True, 'fetchBalance': True, 'fetchBorrowInterest': False, 'fetchBorrowRateHistories': False, 'fetchBorrowRateHistory': False, 'fetchCanceledAndClosedOrders': False, 'fetchCanceledOrders': True, 'fetchClosedOrders': True, 'fetchConvertCurrencies': False, 'fetchConvertQuote': False, 'fetchConvertTrade': False, 'fetchConvertTradeHistory': False, 'fetchCrossBorrowRate': False, 'fetchCrossBorrowRates': False, 'fetchCurrencies': True, 'fetchDeposit': False, 'fetchDepositAddress': False, 'fetchDepositAddresses': False, 'fetchDepositAddressesByNetwork': False, 'fetchDeposits': True, 'fetchDepositsWithdrawals': False, 'fetchDepositWithdrawFee': False, 'fetchDepositWithdrawFees': False, 'fetchFundingHistory': True, 'fetchFundingInterval': False, 'fetchFundingIntervals': False, 'fetchFundingRate': False, 'fetchFundingRateHistory': True, 'fetchFundingRates': False, 'fetchIndexOHLCV': True, 'fetchIsolatedBorrowRate': False, 'fetchIsolatedBorrowRates': False, 'fetchLedger': True, 'fetchLeverage': True, 'fetchLeverageTiers': False, 'fetchLiquidations': False, 'fetchLongShortRatio': False, 'fetchLongShortRatioHistory': False, 'fetchMarginAdjustmentHistory': False, 'fetchMarginMode': False, 'fetchMarketLeverageTiers': False, 'fetchMarkets': True, 'fetchMarkOHLCV': True, 'fetchMarkPrice': False, 'fetchMyLiquidations': False, 'fetchMyTrades': True, 'fetchOHLCV': True, 'fetchOpenInterest': False, 'fetchOpenInterestHistory': True, 'fetchOpenOrders': True, 'fetchOrder': True, 'fetchOrderBook': True, 'fetchOrderBooks': False, 'fetchOrders': True, 'fetchOrderTrades': False, 'fetchPosition': True, 'fetchPositionHistory': False, 'fetchPositionMode': False, 'fetchPositions': True, 'fetchPositionsHistory': True, 'fetchPositionsRisk': False, 'fetchPremiumIndexOHLCV': False, 'fetchStatus': False, 'fetchTicker': True, 'fetchTickers': True, 'fetchTime': False, 'fetchTrades': True, 'fetchTradingFee': True, 'fetchTradingFees': True, 'fetchTransactions': True, 'fetchTransfer': False, 'fetchTransfers': True, 'fetchWithdrawAddresses': False, 'fetchWithdrawal': False, 'fetchWithdrawals': True, 'reduceMargin': False, 'repayCrossMargin': False, 'repayIsolatedMargin': False, 'setLeverage': True, 'setMargin': False, 'setMarginMode': False, 'setPositionMode': False, 'signIn': False, 'transfer': True, 'withdraw': True, }, 'features': {}, 'timeframes': { '1m': 'PT1M', '5m': 'PT5M', '15m': 'PT15M', '30m': 'PT30M', '1h': 'PT1H', '2h': 'PT2H', '4h': 'PT4H', '8h': 'PT8H', '12h': 'PT12H', '1d': 'PT24H', '1w': 'P7D', '1M': 'P30D', }, 'hostname': 'extended.exchange', 'urls': { 'logo': 'https://github.com/user-attachments/assets/e2fe2bdf-6b28-4af8-b30f-38db496dc079', 'api': { 'rest': 'https://api.starknet.{hostname}', }, 'test': { 'rest': 'https://api.starknet.sepolia.{hostname}', }, 'www': 'https://app.extended.exchange', 'doc': 'https://api.docs.extended.exchange', 'fees': 'https://docs.extended.exchange/extended-resources/trading/trading-fees-and-rebates', 'referral': '', }, 'api': { 'v1': { 'public': { 'get': { 'info/markets': {'cost': 1}, 'info/assets': {'cost': 1}, 'info/assets/{asset}/price': {'cost': 1}, 'info/markets/{market}/stats': {'cost': 1}, 'info/markets/{market}/orderbook': {'cost': 1}, 'info/markets/{market}/trades': {'cost': 1}, 'info/candles/{market}/{candleType}': {'cost': 1}, 'info/{market}/funding': {'cost': 1}, 'info/{market}/open-interests': {'cost': 1}, 'info/builder/dashboard': {'cost': 1}, 'interest/info/rate-curves': {'cost': 1}, 'interest/info/latest-rate-curves': {'cost': 1}, }, }, 'private': { 'get': { 'user/accounts': {'cost': 1}, 'user/account/info': {'cost': 1}, 'user/balance': {'cost': 1}, 'user/spot/balances': {'cost': 1}, 'user/assetOperations': {'cost': 1}, 'user/positions': {'cost': 1}, 'user/positions/history': {'cost': 1}, 'user/orders': {'cost': 1}, 'user/orders/history': {'cost': 1}, 'user/orders/{id}': {'cost': 1}, 'user/orders/external/{externalId}': {'cost': 1}, 'user/trades': {'cost': 1}, 'user/funding/history': {'cost': 1}, 'user/rebates/stats': {'cost': 1}, 'user/leverage': {'cost': 1}, 'user/fees': {'cost': 1}, 'user/bridge/config': {'cost': 1}, 'user/bridge/quote': {'cost': 1}, 'user/affiliate': {'cost': 1}, 'user/referrals/status': {'cost': 1}, 'user/referrals/links': {'cost': 1}, 'user/referrals/dashboard': {'cost': 1}, 'user/rewards/earned': {'cost': 1}, 'user/rewards/leaderboard/stats': {'cost': 1}, 'portfolio/charts/equities': {'cost': 1}, 'portfolio/charts/pnl': {'cost': 1}, 'portfolio/charts/pnl/percentage': {'cost': 1}, 'portfolio/charts/pnl/cumulative': {'cost': 1}, 'portfolio/charts/pnl/cumulative/percentage': {'cost': 1}, 'portfolio/charts/vault-equities': {'cost': 1}, 'portfolio/charts/max-drawdown': {'cost': 1}, 'portfolio/charts/funding': {'cost': 1}, 'portfolio/accounts/summary': {'cost': 1}, 'portfolio/accounts/health': {'cost': 1}, 'portfolio/accounts/performance': {'cost': 1}, 'portfolio/funding/stats': {'cost': 1}, 'portfolio/funding/history': {'cost': 1}, 'vault/public/performance': {'cost': 1}, 'vault/public/summary': {'cost': 1}, 'builder/trades': {'cost': 1}, 'interest/key-metrics': {'cost': 1}, 'interest/daily-metrics': {'cost': 1}, 'interest/payment-chart': {'cost': 1}, 'interest/payments': {'cost': 1}, }, 'post': { 'user/order': {'cost': 1}, 'user/order/rfq': {'cost': 1}, 'user/order/massCancel': {'cost': 1}, 'user/deadmanswitch': {'cost': 1}, 'user/bridge/quote': {'cost': 1}, 'user/withdrawal': {'cost': 1}, 'user/transfer': {'cost': 1}, 'user/referrals/use': {'cost': 1}, 'user/referrals': {'cost': 1}, }, 'put': { 'user/referrals': {'cost': 1}, }, 'patch': { 'user/leverage': {'cost': 1}, }, 'delete': { 'user/order/{id}': {'cost': 1}, 'user/order': {'cost': 1}, }, }, }, }, 'fees': { 'taker': self.parse_number('0.00025'), 'maker': self.parse_number('0'), 'rwa': { 'taker': self.parse_number('0.0001'), }, }, 'requiredCredentials': { 'apiKey': True, 'secret': False, 'privateKey': True, }, 'exceptions': { 'exact': { '1000': InvalidOrder, # Asset not found. '1001': InvalidOrder, # Market not found. '1002': InvalidOrder, # Market is disabled. '1003': InvalidOrder, # Market group not found. '1004': InvalidOrder, # Account not found. '1005': InvalidOrder, # Not supported interval. '1006': ExchangeError, # Application error. '1008': InvalidOrder, # Client not found. '1009': InvalidOrder, # Action is not allowed. '1010': ExchangeError, # Maintenance mode. '1011': InvalidOrder, # Post only mode. '1012': InvalidOrder, # Reduce only mode. '1013': InvalidOrder, # Percentage should be between 0 and 1. '1014': InvalidOrder, # Market is in reduce only mode, non-reduce only orders are not allowed. '1049': InvalidOrder, # Leverage below min leverage. '1050': InvalidOrder, # Leverage exceeds max leverage. '10501': InvalidOrder, # Max position value exceeded for new leverage. '1052': InvalidOrder, # Insufficient margin for new leverage. '1053': InvalidOrder, # Leverage has invalid precision. '1100': InvalidOrder, # Invalid Starknet public key. '1101': InvalidOrder, # Invalid Starknet signature. '1102': InvalidOrder, # Invalid Starknet vault. '1120': InvalidOrder, # Order quantity less than min trade size, based on market-specific trading rules. '1121': InvalidOrder, # Invalid quantity due to the wrong size increment, based on market-specific Minimum Change in Trade Size trading rule. '1122': InvalidOrder, # Order value exceeds max order value, based on market-specific trading rules. '1123': InvalidOrder, # Invalid quantity precision, currently equals to market-specific Minimum Change in Trade Size. '1124': InvalidOrder, # Invalid price due to wrong price movement, based on market-specific Minimum Price Change trading rule. '1125': InvalidOrder, # Invalid price precision, currently equals to market-specific Minimum Price Change. '1126': InvalidOrder, # Max open orders number exceeded, currently 200 orders per market. '1127': InvalidOrder, # Max position value exceeded, based on the Margin schedule. '1128': InvalidOrder, # Trading fees are invalid. Refer to Order management section for details. '1129': InvalidOrder, # Invalid quantity for position TP/SL. '1130': InvalidOrder, # Order price is missing. '1131': InvalidOrder, # TP/SL order trigger is missing. '1132': InvalidOrder, # Order type is not allowed. '1133': InvalidOrder, # Invalid order parameters. '1134': InvalidOrder, # Duplicate Order. '1135': InvalidOrder, # Order expiration date must be within 90 days for the Mainnet, 28 days for the Testnet. '1136': InvalidOrder, # Reduce-only order size exceeds open position size. '1137': InvalidOrder, # Position is missing for a reduce-only order. '1138': InvalidOrder, # Position is the same side as a reduce-only order. '1139': InvalidOrder, # Market order must have time in force IOC. '1140': InsufficientFunds, # New order cost exceeds available balance. '1141': InvalidOrder, # Invalid price value. '1142': InvalidOrder, # Edit order not found. '1143': InvalidOrder, # Conditional order trigger is missing. '1144': InvalidOrder, # Conditional market order can't be Post-only. '1145': InvalidOrder, # Non reduce-only orders are not allowed. '1146': InvalidOrder, # Twap order must have time in force GTT. '1147': InvalidOrder, # Open loss exceeds equity. '1148': InvalidOrder, # TP/SL open loss exceeds equity. '1500': InvalidOrder, # Account not selected. '1600': BadRequest, # Withdrawal amount must be positive. '1601': BadRequest, # Withdrawal description is too long. '1602': BadRequest, # Withdrawal request does not match settlement. '1604': BadRequest, # Withdrawal expiration time is below the 14 days minimum. '1605': BadRequest, # Withdrawal asset is not valid. '1607': BadRequest, # Withdrawals blocked for the account. Please contact the team on Discord to unblock the withdrawals. '1608': BadRequest, # The withdrawal address does not match the account address. '1650': BadRequest, # Vault transfer amount is incorrect. '1700': BadRequest, # Referral code already exist. '1701': BadRequest, # Referral code is not valid. '1703': BadRequest, # Referral program is not enabled. '1704': BadRequest, # Referral code already applied. }, 'broad': { }, }, 'options': { 'builderFee': True, 'builderFeeRate': '0.0001', 'builderId': '257624', }, }) def load_markets(self, reload=False, params: dict = {}): markets = super(extended, self).load_markets(reload, params) currenciesByNumericId = self.safe_dict(self.options, 'currenciesByNumericId') if (currenciesByNumericId is None) or reload: self.options['currenciesByNumericId'] = self.index_by_stringified_numeric_id(self.currencies) return markets def index_by_stringified_numeric_id(self, input: dict) -> dict: result = {} if input is None: return None keys = list(input.keys()) for i in range(0, len(keys)): key = keys[i] item = self.safe_dict(input, key, {}) numericIdString = self.safe_string(item, 'numericId') if numericIdString is None: continue result[numericIdString] = item return result def fetch_markets(self, params: dict = {}) -> list[Market]: """ retrieves data on all markets for extended https://api.docs.extended.exchange/#get-markets https://docs.extended.exchange/extended-resources/trading/trading-fees-and-rebates :param dict [params]: extra parameters specific to the exchange API endpoint :returns dict[]: an array of objects representing market data """ response = self.v1PublicGetInfoMarkets(params) # # { # "status": "OK", # "data": [ # { # "name": "BTC-USD", # "uiName": "BTC-USD", # "category": "Crypto", # "subCategory": "L1", # "assetName": "BTC", # "assetPrecision": 5, # "collateralAssetName": "USD", # "collateralAssetPrecision": 6, # "description": "Bitcoin", # "active": true, # "status": "ACTIVE", # "marketStats": { # "dailyVolume": "231016077.512960", # "dailyVolumeBase": "3025.00058", # "dailyPriceChange": "420", # "dailyPriceChangePercentage": "0.0055", # "dailyLow": "75635", # "dailyHigh": "77399", # "lastPrice": "77259", # "askPrice": "77260", # "bidPrice": "77259", # "markPrice": "77259.680250000004", # "indexPrice": "77299.020412500001", # "fundingRate": "0.000013", # "nextFundingRate": 1777442400000, # "openInterest": "115861923.311902", # "openInterestBase": "1500.40958", # "deleverageLevels": { # "shortPositions": [ # { # "level": 1, # "rankingLowerBound": "-815.7788" # }, # { # "level": 2, # "rankingLowerBound": "-2.1328" # }, # { # "level": 3, # "rankingLowerBound": "-0.9297" # }, # { # "level": 4, # "rankingLowerBound": "0.0000" # } # ], # "longPositions": [ # { # "level": 1, # "rankingLowerBound": "-47234.9095" # }, # { # "level": 2, # "rankingLowerBound": "-0.0030" # }, # { # "level": 3, # "rankingLowerBound": "0.0020" # }, # { # "level": 4, # "rankingLowerBound": "0.0033" # } # ] # } # }, # "tradingConfig": { # "minOrderSize": "0.0001", # "minOrderSizeChange": "0.00001", # "minPriceChange": "1", # "maxMarketOrderValue": "3000000", # "maxLimitOrderValue": "15000000", # "maxPositionValue": "60000000", # "maxLeverage": "50.00", # "hourlyFundingRateCap": "0.25", # "maxNumOrders": "200", # "limitPriceCap": "0.05", # "limitPriceFloor": "0.05", # "riskFactorConfig": [ # { # "upperBound": "4000000", # "riskFactor": "0.02", # "isAvailableForUsers": true # } # ] # }, # "l2Config": { # "type": "STARKX", # "collateralId": "0x1", # "syntheticId": "0x4254432d3600000000000000000000", # "syntheticResolution": 1000000, # "collateralResolution": 1000000 # }, # "visibleOnUi": true, # "createdAt": 1752829532673 # } # ] # } # data = self.safe_list(response, 'data', []) return self.parse_markets(data) def parse_market(self, market: dict) -> Market: # # { # "name": "BTC-USD", # "uiName": "BTC-USD", # "category": "Crypto", # "subCategory": "L1", # "assetName": "BTC", # "assetPrecision": 5, # "collateralAssetName": "USD", # "collateralAssetPrecision": 6, # "description": "Bitcoin", # "active": true, # "status": "ACTIVE", # "marketStats": { ... }, # "tradingConfig": { # "minOrderSize": "0.0001", # "minOrderSizeChange": "0.00001", # "minPriceChange": "1", # "maxMarketOrderValue": "3000000", # "maxLimitOrderValue": "15000000", # "maxPositionValue": "60000000", # "maxLeverage": "50.00", # "hourlyFundingRateCap": "0.25", # "maxNumOrders": "200", # "limitPriceCap": "0.05", # "limitPriceFloor": "0.05", # "riskFactorConfig": [ # { # "upperBound": "4000000", # "riskFactor": "0.02", # "isAvailableForUsers": true # } # ] # }, # "l2Config": { ... }, # "visibleOnUi": true, # "createdAt": 1752829532673 # } # tradingConfig = self.safe_dict(market, 'tradingConfig', {}) marketId = self.safe_string(market, 'name') baseId = self.safe_string(market, 'assetName', '') if baseId.find('SPOT') >= 0: baseId = baseId.replace('SPOT', '') quoteId = self.safe_string(market, 'collateralAssetName') base = self.safe_currency_code(baseId) quote = self.safe_currency_code(quoteId) if quoteId == 'USD': quote = 'USDC' if (base is None) or (quote is None): return None status = self.safe_string(market, 'status') active = (status == 'ACTIVE') amountPrecision = self.safe_number(tradingConfig, 'minOrderSizeChange') pricePrecision = self.safe_number(tradingConfig, 'minPriceChange') maxLeverage = self.safe_number(tradingConfig, 'maxLeverage') minAmount = self.safe_number(tradingConfig, 'minOrderSize') maxCost = self.safe_number(tradingConfig, 'maxLimitOrderValue') created = self.safe_integer(market, 'createdAt') category = self.safe_string_lower(market, 'category') takerFees = self.safe_dict(self.fees, 'rwa', {}) if (category == 'rwa') else self.fees settleId = None settle = None symbol = base + '/' + quote isSpot = False type = self.safe_string_lower(market, 'type') contractSize = None linear = None inverse = None # SPOT rows are still parsed on purpose even though has['spot'] is false - that flag # only advertises the capability and gates the unified spot tests, it does not filter # markets, so accounts still holding spot balances keep resolving their symbols if type == 'spot': isSpot = True else: type = 'swap' settleId = quoteId settle = quote symbol += ':' + settle contractSize = self.parse_number('1') linear = True inverse = False return self.safe_market_structure({ 'id': marketId, 'symbol': symbol, 'base': base, 'quote': quote, 'settle': settle, 'baseId': baseId, 'quoteId': quoteId, 'settleId': settleId, 'type': type, 'spot': isSpot, 'margin': False, 'swap': not isSpot, 'future': False, 'option': False, 'active': active, 'contract': not isSpot, 'linear': linear, 'inverse': inverse, 'taker': self.safe_number(takerFees, 'taker'), 'maker': self.safe_number(self.fees, 'maker'), 'contractSize': contractSize, 'expiry': None, 'expiryDatetime': None, 'strike': None, 'optionType': None, 'precision': { 'amount': amountPrecision, 'price': pricePrecision, }, 'limits': { 'leverage': { 'min': self.parse_number('1'), 'max': maxLeverage, }, 'amount': { 'min': minAmount, 'max': None, }, 'price': { 'min': None, 'max': None, }, 'cost': { 'min': None, 'max': maxCost, }, }, 'created': created, 'info': market, }) def fetch_currencies(self, params: dict = {}) -> Currencies: """ fetches all available currencies on an exchange https://api.docs.extended.exchange/#get-assets :param dict [params]: extra parameters specific to the exchange API endpoint :returns dict: an associative dictionary of currencies """ response = self.v1PublicGetInfoAssets(params) # # { # "status": "OK", # "data": [ # { # "id": 1, # "name": "USD", # "symbol": "USD", # "description": "USD Collateral", # "precision": 6, # "isActive": true, # "isCollateral": true, # "starkexId": "0x1", # "starkexResolution": 1000000, # "l1Id": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", # "l1Resolution": 1000000, # "version": 3, # "createdAt": 1752829532673, # "type": "SPOT", # "canBeUsedAsCollateral": true, # "riskFactors": [], # "availableForTradeFactors": [] # } # ] # } # data = self.safe_list(response, 'data', []) return self.parse_currencies(data) def parse_currency(self, currency: dict) -> CurrencyInterface: # # { # "id": 1, # "name": "USD", # "symbol": "USD", # "description": "USD Collateral", # "precision": 6, # "isActive": true, # "isCollateral": true, # "starkexId": "0x1", # "starkexResolution": 1000000, # "l1Id": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", # "l1Resolution": 1000000, # "version": 3, # "createdAt": 1752829532673, # "type": "SPOT", # "canBeUsedAsCollateral": true, # "riskFactors": [], # "availableForTradeFactors": [] # } # currencyId = self.safe_string(currency, 'symbol') if (currencyId is not None) and (currencyId.find('SPOT') >= 0): currencyId = currencyId.replace('SPOT', '') code = self.safe_currency_code(currencyId) if currencyId == 'USD': code = 'USDC' name = self.safe_string(currency, 'name') precision = self.safe_integer(currency, 'precision', 0) isActive = self.safe_bool(currency, 'isActive') return self.safe_currency_structure({ 'id': currencyId, 'code': code, 'numericId': self.safe_integer(currency, 'id'), 'name': name, 'active': isActive, 'deposit': True, 'withdraw': True, 'precision': math.pow(10, precision * -1), 'type': 'other', 'margin': self.safe_bool(currency, 'canBeUsedAsCollateral'), 'info': currency, }) 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://api.docs.extended.exchange/#get-market-statistics :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>` """ self.load_markets() market = self.market(symbol) request = { 'market': market['id'], } response = self.v1PublicGetInfoMarketsMarketStats(self.extend(request, params)) # # { # "status": "OK", # "data": { # "dailyVolume": "231216165.666600", # "dailyVolumeBase": "3027.36710", # "dailyPriceChange": "181", # "dailyPriceChangePercentage": "0.0024", # "dailyLow": "75635", # "dailyHigh": "77399", # "lastPrice": "77026", # "askPrice": "77026", # "bidPrice": "77025", # "markPrice": "77006.091897999984", # "indexPrice": "77050.739529925005", # "fundingRate": "0.000012", # "nextFundingRate": 1777446000000, # "openInterest": "114851569.088316", # "openInterestBase": "1491.33012", # "deleverageLevels": { # "shortPositions": [ # { "level": 1, "rankingLowerBound": "-784.2884" }, # { "level": 2, "rankingLowerBound": "-2.1078" }, # { "level": 3, "rankingLowerBound": "-0.8754" }, # { "level": 4, "rankingLowerBound": "0.0000" } # ], # "longPositions": [ # { "level": 1, "rankingLowerBound": "-47747.2010" }, # { "level": 2, "rankingLowerBound": "-0.0131" }, # { "level": 3, "rankingLowerBound": "0.0019" }, # { "level": 4, "rankingLowerBound": "0.0032" } # ] # } # } # } # data = self.safe_dict(response, 'data', {}) return self.parse_ticker(data, market) def fetch_tickers(self, symbols: Strings = None, params: dict = {}) -> Tickers: """ fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for all markets https://api.docs.extended.exchange/#get-markets :param str[] [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned :param dict [params]: extra parameters specific to the exchange API endpoint :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/?id=ticker-structure>` """ self.load_markets() symbolsNormalized = self.market_symbols(symbols) request = {} if symbolsNormalized is not None: marketIds = [] for i in range(0, len(symbolsNormalized)): market = self.market(symbolsNormalized[i]) marketIds.append(market['id']) request['market'] = marketIds response = self.v1PublicGetInfoMarkets(self.extend(request, params)) # # { # "status": "OK", # "data": [ # { # "name": "BTC-USD", # "assetName": "BTC", # "collateralAssetName": "USD", # "marketStats": { # "dailyVolume": "231016077.512960", # ... # }, # ... # } # ] # } # data = self.safe_list(response, 'data', []) tickers = {} for i in range(0, len(data)): marketData = self.safe_dict(data, i) marketId = self.safe_string(marketData, 'name') market = self.safe_market(marketId) stats = self.safe_dict(marketData, 'marketStats', {}) ticker = self.parse_ticker(stats, market) symbol = ticker['symbol'] if symbol is not None: tickers[symbol] = ticker return self.filter_by_array_tickers(tickers, 'symbol', symbolsNormalized) def parse_ticker(self, ticker: dict, market: Market = None) -> Ticker: # # { # "dailyVolume": "231216165.666600", # "dailyVolumeBase": "3027.36710", # "dailyPriceChange": "181", # "dailyPriceChangePercentage": "0.0024", # "dailyLow": "75635", # "dailyHigh": "77399", # "lastPrice": "77026", # "askPrice": "77026", # "bidPrice": "77025", # "markPrice": "77006.091897999984", # "indexPrice": "77050.739529925005", # "fundingRate": "0.000012", # "nextFundingRate": 1777446000000, # "openInterest": "114851569.088316", # "openInterestBase": "1491.33012", # "deleverageLevels": { # "shortPositions": [ # { "level": 1, "rankingLowerBound": "-784.2884" }, # { "level": 2, "rankingLowerBound": "-2.1078" }, # { "level": 3, "rankingLowerBound": "-0.8754" }, # { "level": 4, "rankingLowerBound": "0.0000" } # ], # "longPositions": [ # { "level": 1, "rankingLowerBound": "-47747.2010" }, # { "level": 2, "rankingLowerBound": "-0.0131" }, # { "level": 3, "rankingLowerBound": "0.0019" }, # { "level": 4, "rankingLowerBound": "0.0032" } # ] # } # } # symbol = self.safe_symbol(None, market) last = self.safe_number(ticker, 'lastPrice') percentageRaw = self.safe_string(ticker, 'dailyPriceChangePercentage') percentage = Precise.string_mul(percentageRaw, '100') if (percentageRaw is not None) else None return self.safe_ticker({ 'symbol': symbol, 'timestamp': None, 'datetime': None, 'high': self.safe_number(ticker, 'dailyHigh'), 'low': self.safe_number(ticker, 'dailyLow'), 'bid': self.safe_number(ticker, 'bidPrice'), 'bidVolume': None, 'ask': self.safe_number(ticker, 'askPrice'), 'askVolume': None, 'vwap': None, 'open': None, 'close': last, 'last': last, 'previousClose': None, 'change': self.safe_number(ticker, 'dailyPriceChange'), 'percentage': percentage, 'average': None, 'baseVolume': self.safe_number(ticker, 'dailyVolumeBase'), 'quoteVolume': self.safe_number(ticker, 'dailyVolume'), 'markPrice': self.safe_number(ticker, 'markPrice'), 'indexPrice': self.safe_number(ticker, 'indexPrice'), 'info': ticker, }, market) def fetch_order_book(self, symbol: str, limit: Int = None, params: dict = {}) -> OrderBook: """ fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data https://api.docs.extended.exchange/#get-market-order-book :param str symbol: unified symbol of the market to fetch the order book for :param int [limit]: the maximum amount of order book entries to return :param dict [params]: extra parameters specific to the exchange API endpoint :returns dict: an `order book structure <https://docs.ccxt.com/?id=order-book-structure>` """ self.load_markets() market = self.market(symbol) request = { 'market': market['id'], } response = self.v1PublicGetInfoMarketsMarketOrderbook(self.extend(request, params)) # # { # "status": "OK", # "data": { # "market": "BTC-USD", # "bid": [ # { # "qty": "14.46084", # "price": "76214" # } # ], # "ask": [ # { # "qty": "0.11585", # "price": "76215" # } # ] # } # } # data = self.safe_dict(response, 'data', {}) timestamp = self.milliseconds() orderbook = self.parse_order_book(data, market['symbol'], timestamp, 'bid', 'ask', 'price', 'qty') if limit is not None: orderbook['bids'] = self.array_slice(orderbook['bids'], 0, limit) orderbook['asks'] = self.array_slice(orderbook['asks'], 0, limit) return orderbook def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params: dict = {}) -> list[Trade]: """ get the list of most recent trades for a particular symbol https://api.docs.extended.exchange/#get-market-last-trades :param str symbol: unified symbol of the market to fetch trades for :param int [since]: timestamp in ms of the earliest trade to fetch :param int [limit]: the maximum amount of trades to fetch :param dict [params]: extra parameters specific to the exchange API endpoint :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/?id=public-trades>` """ self.load_markets() market = self.market(symbol) request = { 'market': market['id'], } response = self.v1PublicGetInfoMarketsMarketTrades(self.extend(request, params)) # # { # "status": "OK", # "data": [ # { # "i": 2.049676905958871e+18, # "m": "BTC-USD", # "S": "SELL", # "tT": "TRADE", # "T": 1777516030193, # "p": "76140", # "q": "0.00165" # } # ] # } # data = self.safe_list(response, 'data', []) return self.parse_trades(data, market, since, limit) def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params: dict = {}) -> list[Trade]: """ fetch all trades made by the user https://api.docs.extended.exchange/#get-trades :param str [symbol]: unified market symbol of the trades :param int [since]: the earliest time in ms to fetch trades for :param int [limit]: the maximum number of trade structures to retrieve :param dict [params]: extra parameters specific to the exchange API endpoint :param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params) :returns Trade[]: a list of `trade structures <https://docs.ccxt.com/?id=trade-structure>` """ self.load_markets() paginate, paramsPaginate = self.handle_option_bool_and_params(params, 'fetchMyTrades', 'paginate', False) if paginate: return self.fetch_paginated_call_cursor('fetchMyTrades', symbol, since, limit, paramsPaginate, 'cursor', 'cursor', None, 100) market = None request = {} if symbol is not None: market = self.market(symbol) request['market'] = market['id'] if limit is not None: request['limit'] = limit response = self.v1PrivateGetUserTrades(self.extend(paramsPaginate, request)) # # { # "status": "OK", |
| 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. |