MCPcopy Create free account
hub / github.com/ccxt/ccxt / fetch_margin_mode

Method fetch_margin_mode

python/ccxt/pacifica.py:754–792  ·  view source on GitHub ↗

fetches the margin mode of the trading pair :param str symbol: unified symbol of the market to fetch the margin mode for :param dict [params]: extra parameters specific to the exchange API endpoint :param str [params.account]: will default to walletAddress if not pro

(self, symbol: str, params={})

Source from the content-addressed store, hash-verified

752 return settingsBySymbol
753
754 def fetch_margin_mode(self, symbol: str, params={}) -> MarginMode:
755 """
756 fetches the margin mode of the trading pair
757 :param str symbol: unified symbol of the market to fetch the margin mode for
758 :param dict [params]: extra parameters specific to the exchange API endpoint
759 :param str [params.account]: will default to walletAddress if not provided
760 :returns dict: a `margin mode structure <https://docs.ccxt.com/?id=margin-mode-structure>`
761 """
762 self.load_account_settings()
763 userAccount = None
764 userAccount, params = self.handle_origin_and_single_address('fetchMarginMode', params)
765 cacheAddress = self.walletAddress
766 settings = None
767 if userAccount == cacheAddress:
768 settings = self.handle_option('fetchMarginMode', 'settings', None)
769 else:
770 request = {
771 'account': userAccount,
772 }
773 settings = self.fetch_account_settings(self.extend(request, params))
774 # {
775 # "WLFI/USDC:USDC": {
776 # "symbol": "WLFI",
777 # "isolated": False,
778 # "leverage": 5,
779 # "created_at": 1758085929703,
780 # "updated_at": 1758086074002
781 # },
782 # }
783 setting = self.safe_dict(settings, symbol, None)
784 if setting is None:
785 # NOTE: Upon account creation, all markets have margin settings default to cross margin and leverage default to max.
786 # When querying self endpoint, all markets with default margin and leverage settings on self account will return blank.
787 return {
788 'symbol': symbol,
789 'marginMode': self.handle_option('fetchMarginMode', 'defaultMarginMode', 'cross'),
790 }
791 else:
792 return self.parse_margin_mode_from_setting(symbol, setting)
793
794 def parse_margin_mode_from_setting(self, symbol: Str, setting: dict) -> MarginMode:
795 # {

Callers

nothing calls this directly

Calls 7

load_account_settingsMethod · 0.95
handle_optionMethod · 0.80
safe_dictMethod · 0.80
extendMethod · 0.45

Tested by

no test coverage detected