From 5b84298e0305c84d1ff2dee56e150a05c030f320 Mon Sep 17 00:00:00 2001 From: Sam Germain Date: Sun, 12 Sep 2021 00:03:02 -0600 Subject: [PATCH] kraken._apply_leverage_to_stake_amount --- freqtrade/exchange/kraken.py | 9 +++++++++ tests/exchange/test_exchange.py | 6 +++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/freqtrade/exchange/kraken.py b/freqtrade/exchange/kraken.py index b72a92070..14ebedef0 100644 --- a/freqtrade/exchange/kraken.py +++ b/freqtrade/exchange/kraken.py @@ -163,6 +163,15 @@ class Kraken(Exchange): leverages[pair] = leverage_buy self._leverage_brackets = leverages + def _apply_leverage_to_stake_amount(self, stake_amount: float, leverage: float): + """ + Takes the minimum stake amount for a pair with no leverage and returns the minimum + stake amount when leverage is considered + :param stake_amount: The stake amount for a pair before leverage is considered + :param leverage: The amount of leverage being used on the current trade + """ + return stake_amount / leverage + def get_max_leverage(self, pair: Optional[str], nominal_value: Optional[float]) -> float: """ Returns the maximum leverage that a pair can be traded at diff --git a/tests/exchange/test_exchange.py b/tests/exchange/test_exchange.py index 239704bdd..330793822 100644 --- a/tests/exchange/test_exchange.py +++ b/tests/exchange/test_exchange.py @@ -2974,9 +2974,9 @@ def test_calculate_backoff(retrycount, max_retries, expected): ('binance', 20.0, 5.0, 4.0), ('binance', 100.0, 100.0, 1.0), # Kraken - ('kraken', 9.0, 3.0, 9.0), - ('kraken', 20.0, 5.0, 20.0), - ('kraken', 100.0, 100.0, 100.0), + ('kraken', 9.0, 3.0, 3.0), + ('kraken', 20.0, 5.0, 4.0), + ('kraken', 100.0, 100.0, 1.0), # FTX ('ftx', 9.0, 3.0, 9.0), ('ftx', 20.0, 5.0, 20.0),