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

Method modify_margin_helper

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

Source from the content-addressed store, hash-verified

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

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