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

Method modify_margin_helper

python/ccxt/async_support/ascendex.py:2901–2927  ·  view source on GitHub ↗
(self, symbol: str, amount, type, params={})

Source from the content-addressed store, hash-verified

2899 return self.parse_funding_rates(contracts, symbols)
2900
2901 async def modify_margin_helper(self, symbol: str, amount, type, params={}) -> MarginModification:
2902 await self.load_markets()
2903 await self.load_accounts()
2904 market = self.market(symbol)
2905 account = self.safe_dict(self.accounts, 0, {})
2906 accountGroup = self.safe_string(account, 'id')
2907 amount = self.amount_to_precision(symbol, amount)
2908 request = {
2909 'account-group': accountGroup,
2910 'symbol': market['id'],
2911 'amount': amount, # positive value for adding margin, negative for reducing
2912 }
2913 response = await self.v2PrivateAccountGroupPostFuturesIsolatedPositionMargin(self.extend(request, params))
2914 #
2915 # Can only change margin for perpetual futures isolated margin positions
2916 #
2917 # {
2918 # "code": 0
2919 # }
2920 #
2921 if type == 'reduce':
2922 amount = Precise.string_abs(amount)
2923 parsedAmount = self.parse_number(amount)
2924 return self.extend(self.parse_margin_modification(response, market), {
2925 'amount': parsedAmount,
2926 'type': type,
2927 })
2928
2929 def parse_margin_modification(self, data: dict, market: Market = None) -> MarginModification:
2930 #

Callers 2

reduce_marginMethod · 0.95
add_marginMethod · 0.95

Calls 11

safe_dictMethod · 0.80
safe_stringMethod · 0.80
string_absMethod · 0.80
parse_numberMethod · 0.80
load_marketsMethod · 0.45
load_accountsMethod · 0.45
marketMethod · 0.45
amount_to_precisionMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected