(self, leverage: int, marginMode: str, symbol: Str = None, params={})
| 2856 | return self.modify_leverage_and_margin_mode(leverage, marginMode, symbol, params) |
| 2857 | |
| 2858 | def modify_leverage_and_margin_mode(self, leverage: int, marginMode: str, symbol: Str = None, params={}): |
| 2859 | self.load_markets() |
| 2860 | if (marginMode != 'cross') and (marginMode != 'isolated'): |
| 2861 | raise BadRequest(self.id + ' modifyLeverageAndMarginMode() requires a marginMode parameter that must be either cross or isolated') |
| 2862 | apiKeyIndex = None |
| 2863 | apiKeyIndex, params = self.handle_api_key_index(params, 'modifyLeverageAndMarginMode', 'apiKeyIndex', 'api_key_index') |
| 2864 | if symbol is None: |
| 2865 | raise ArgumentsRequired(self.id + ' modifyLeverageAndMarginMode() requires a symbol argument') |
| 2866 | accountIndex = None |
| 2867 | accountIndex, params = self.handle_account_index(params, 'modifyLeverageAndMarginMode', 'accountIndex', 'account_index') |
| 2868 | strAccountIndex = self.number_to_string(accountIndex) |
| 2869 | strApiKeyIndex = self.number_to_string(apiKeyIndex) |
| 2870 | signer = self.load_account(self.options['chainId'], self.get_lighter_private_key(strAccountIndex, strApiKeyIndex), strApiKeyIndex, strAccountIndex, params) |
| 2871 | market = self.market(symbol) |
| 2872 | nonce = self.fetch_nonce(accountIndex, apiKeyIndex, params) |
| 2873 | signRaw = { |
| 2874 | 'market_index': self.parse_to_int(market['id']), |
| 2875 | 'initial_margin_fraction': self.parse_to_int(10000 / leverage), |
| 2876 | 'margin_mode': 0 if (marginMode == 'cross') else 1, # 0: CROSS, 1: ISOLATED |
| 2877 | 'nonce': nonce, |
| 2878 | 'api_key_index': apiKeyIndex, |
| 2879 | 'account_index': accountIndex, |
| 2880 | } |
| 2881 | txType, txInfo = self.lighter_sign_update_leverage(signer, self.extend(signRaw, params)) |
| 2882 | request = { |
| 2883 | 'tx_type': txType, |
| 2884 | 'tx_info': txInfo, |
| 2885 | } |
| 2886 | return self.publicPostSendTx(request) |
| 2887 | |
| 2888 | def cancel_order(self, id: str, symbol: Str = None, params={}): |
| 2889 | """ |
no test coverage detected