Closed Bennch closed 3 months ago
Hi! Here's a way to do it:
def set_leverage(self, symbol: str, leverage: float):
new_leverage = round(leverage, 2)
initialMarginRate = str(round(1 / new_leverage, 5))
response = self.apex_ex.set_initial_margin_rate_v2(symbol=symbol, initialMarginRate=initialMarginRate)
try:
if type(response.get("timeCost")) == int:
return True
else:
return False
except Exception as e:
raise Exception(f"Apex set_leverage -> {e}")
And here's handle: https://api-docs.pro.apex.exchange/#privateapi_v2-post-sets-the-initial-margin-rate-of-a-contract-v2
Isn't it possible to change the leverage via API ?