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

Method get_margin_mode

python/ccxt/gate.py:1868–1895  ·  view source on GitHub ↗

@ignore Gets the margin type for self api call :param bool trigger: True if for a trigger order :param dict [params]: Request params :returns: The marginMode and the updated request params with marginMode removed, marginMode value is the value that can be read by th

(self, trigger, params)

Source from the content-addressed store, hash-verified

1866 return [request, query]
1867
1868 def get_margin_mode(self, trigger, params):
1869 """
1870 @ignore
1871 Gets the margin type for self api call
1872 :param bool trigger: True if for a trigger order
1873 :param dict [params]: Request params
1874 :returns: The marginMode and the updated request params with marginMode removed, marginMode value is the value that can be read by the "account" property specified in gates api docs
1875 """
1876 defaultMarginMode = self.safe_string_lower_2(self.options, 'defaultMarginMode', 'marginMode', 'spot') # 'margin' is isolated margin on gate's api
1877 marginMode = self.safe_string_lower_2(params, 'marginMode', 'account', defaultMarginMode)
1878 params = self.omit(params, ['marginMode', 'account'])
1879 if marginMode == 'cross':
1880 marginMode = 'cross_margin'
1881 elif marginMode == 'isolated':
1882 marginMode = 'margin'
1883 elif marginMode == '':
1884 marginMode = 'spot'
1885 if trigger:
1886 if marginMode == 'spot':
1887 # gate spot trigger orders use the term normal instead of spot
1888 marginMode = 'normal'
1889 if marginMode == 'cross_margin':
1890 raise BadRequest(self.id + ' getMarginMode() does not support trigger orders for cross margin')
1891 isUnifiedAccount = False
1892 isUnifiedAccount, params = self.handle_option_and_params(params, 'getMarginMode', 'unifiedAccount')
1893 if isUnifiedAccount:
1894 marginMode = 'unified'
1895 return [marginMode, params]
1896
1897 def get_settlement_currencies(self, type, method):
1898 options = self.safe_value(self.options, type, {}) # ['BTC', 'USDT'] unified codes

Callers 5

fetch_balanceMethod · 0.95
fetch_my_tradesMethod · 0.95
create_order_requestMethod · 0.95

Calls 4

BadRequestClass · 0.90
safe_string_lower_2Method · 0.80
omitMethod · 0.45

Tested by

no test coverage detected