kraken._apply_leverage_to_stake_amount

This commit is contained in:
Sam Germain 2021-09-12 00:03:02 -06:00
parent b0e05b92d3
commit 5b84298e03
2 changed files with 12 additions and 3 deletions

View File

@ -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

View File

@ -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),