From 40e3a13e981058e586a0407b1fde6e7960a9551a Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 6 Feb 2023 20:19:40 +0100 Subject: [PATCH] Amend some additions from #288 --- .../strategies/futures/VolatilitySystem.py | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/user_data/strategies/futures/VolatilitySystem.py b/user_data/strategies/futures/VolatilitySystem.py index f339299..15ce247 100644 --- a/user_data/strategies/futures/VolatilitySystem.py +++ b/user_data/strategies/futures/VolatilitySystem.py @@ -23,14 +23,15 @@ class VolatilitySystem(IStrategy): Volatility System strategy. Based on https://www.tradingview.com/script/3hhs0XbR/ + Leverage is optional but the lower the better to limit liquidations """ - can_short: bool = True + can_short = True minimal_roi = { "0": 100 } - stoploss = -0.10 + stoploss = -1 # Optimal ticker interval for the strategy timeframe = '1h' @@ -131,9 +132,26 @@ class VolatilitySystem(IStrategy): # Only enlarge position on new signal. if ( last_candle[signal_name] == 1 - and previous_candle[signal_name] != 1 + and previous_candle[signal_name] != 1 and trade.nr_of_successful_entries < 2 and trade.orders[-1].order_date_utc < prior_date ): return trade.stake_amount return None + + def leverage(self, pair: str, current_time: datetime, current_rate: float, + proposed_leverage: float, max_leverage: float, side: str, + **kwargs) -> float: + """ + Customize leverage for each new trade. This method is only called in futures mode. + + :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 exit_pricing. + :param proposed_leverage: A leverage proposed by the bot. + :param max_leverage: Max leverage allowed on this pair + :param entry_tag: Optional entry_tag (buy_tag) if provided with the buy signal. + :param side: 'long' or 'short' - indicating the direction of the proposed trade + :return: A leverage amount, which is between 1.0 and max_leverage. + """ + return 2.0