Implement strategy-controlled stake sizes. Expose self.wallet to a strategy.

This commit is contained in:
Rokas Kupstys
2021-07-11 12:20:31 +03:00
parent 2f33b97b95
commit 0e4466ca1e
7 changed files with 136 additions and 19 deletions

View File

@@ -304,6 +304,23 @@ class IStrategy(ABC, HyperStrategyMixin):
"""
return None
def custom_stake_amount(self, pair: str, current_time: datetime, current_rate: float,
proposed_stake: float, min_stake: float, max_stake: float,
**kwargs) -> float:
"""
Customize stake size for each new trade. This method is not called when edge module is
enabled.
:param pair: Pair that's currently analyzed
:param current_time: datetime object, containing the current datetime
:param current_rate: Rate, calculated based on pricing settings in ask_strategy.
:param proposed_stake: A stake amount proposed by the bot.
:param min_stake: Minimal stake size allowed by exchange.
:param max_stake: Balance available for trading.
:return: A stake size, which is between min_stake and max_stake.
"""
return proposed_stake
def informative_pairs(self) -> ListPairsWithTimeframes:
"""
Define additional, informative pair/interval combinations to be cached from the exchange.