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

Method set_margin

python/ccxt/phemex.py:4159–4186  ·  view source on GitHub ↗

Either adds or reduces margin in an isolated position in order to set the margin to a specific value https://github.com/phemex/phemex-api-docs/blob/master/Public-Contract-API-en.md#assign-position-balance-in-isolated-marign-mode :param str symbol: unified market symbol of

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

Source from the content-addressed store, hash-verified

4157 }
4158
4159 def set_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
4160 """
4161 Either adds or reduces margin in an isolated position in order to set the margin to a specific value
4162
4163 https://github.com/phemex/phemex-api-docs/blob/master/Public-Contract-API-en.md#assign-position-balance-in-isolated-marign-mode
4164
4165 :param str symbol: unified market symbol of the market to set margin in
4166 :param float amount: the amount to set the margin to
4167 :param dict [params]: parameters specific to the exchange API endpoint
4168 :returns dict: A `margin structure <https://docs.ccxt.com/?id=margin-structure>`
4169 """
4170 self.load_markets()
4171 market = self.market(symbol)
4172 request = {
4173 'symbol': market['id'],
4174 'posBalanceEv': self.to_ev(amount, market),
4175 }
4176 response = self.privatePostPositionsAssign(self.extend(request, params))
4177 #
4178 # {
4179 # "code": 0,
4180 # "msg": "",
4181 # "data": "OK"
4182 # }
4183 #
4184 return self.extend(self.parse_margin_modification(response, market), {
4185 'amount': amount,
4186 })
4187
4188 def parse_margin_status(self, status):
4189 statuses = {

Callers

nothing calls this directly

Calls 6

to_evMethod · 0.95
load_marketsMethod · 0.45
marketMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected