From 53a6ce881cabd02c6b825d758e82b50fab10eb30 Mon Sep 17 00:00:00 2001 From: Sam Germain Date: Sun, 8 Aug 2021 19:34:33 -0600 Subject: [PATCH] Added set_leverage function to exchange --- freqtrade/exchange/exchange.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index 4032dc030..ad8398e26 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -732,7 +732,6 @@ class Exchange: order = self._api.create_order(pair, ordertype, side, amount, rate_for_order, params) self._log_exchange_response('create_order', order) - return order except ccxt.InsufficientFunds as e: @@ -1521,6 +1520,15 @@ class Exchange: # TODO-mg: implement return 0.0005 + def set_leverage(self, pair, leverage): + """ + Binance Futures must set the leverage before making a futures trade, in order to not + have the same leverage on every trade + # TODO-lev: This may be the case for any futures exchange, or even margin trading on + # TODO-lev: some exchanges, so check this + """ + self._api.set_leverage(symbol=pair, leverage=leverage) + def is_exchange_known_ccxt(exchange_name: str, ccxt_module: CcxtModuleType = None) -> bool: return exchange_name in ccxt_exchanges(ccxt_module)