Elffuss BraidHub

kikocis/freqtrade-strategies public

Bump to 5.2
Changeset7b6cc455e763e27568419edabb08971140366cd140c9ff3cf9a71cf9e1ed9989
AuthorBryan Chain <bryan.chain@cerner.com> · 2021-05-15 21:38 -04:00
CommitterBryan Chain <bryan.chain@cerner.com> · 2021-05-15 21:38 -04:00
Parents0c747663ac13

Browse the files at this changeset

2 files changed

modified README.md +11 −0
@@ -90,6 +90,17 @@
9090
9191 ### v5
9292
93+May 14, 2021 (version 5.2):
94+- **General**
95+ - Slight modification to hyperopt params (added load=True)
96+ - Added @rk to credits because he is the best!
97+- **Custom Sell**
98+ - Issue: https://github.com/freqtrade/freqtrade/issues/4920 has been addressed and code has been updated without workaround, should work as designed once it is merged to develop.
99+ - Moved the "bailout" and "timeout" (sells for loss) portion of the custom sell back into `custom_stoploss`
100+ - Changed `sell_profit_only` to true now that the sell for loss is back in `custom_stoploss`
101+ - Minor tweak to in how `custom_sell` sets `had-trend` back to false.
102+ - Changed `ignore_roi_if_buy_signal` to true because it probably can't hurt?
103+
93104 May 13, 2021 (version 5.1.4):
94105 - **General**
95106 - It seems there is an issue with hyperopt when calling it from a child strategy. As such, it is recommended to call the strategy directly during hyperopt (e.g. --strategy Solipsis5), you can still put the found parameters into the child strategy for live/dry run if you prefer and this is still my recommended way to configure the strategy. Especially if running multiple instances.
modified strategies/Solipsis_v5.py +65 −55
@@ -27,14 +27,15 @@
2727 Solipsis - By @werkkrew
2828
2929 Credits -
30-@JimmyNixx for many of the ideas used throughout as well as helping me stay motivated throughout development!
30+@JimmyNixx for many of the ideas used throughout as well as helping me stay motivated throughout development!
31+@rk for submitting many PR's that have made this strategy possible!
3132
3233 I ask for nothing in return except that if you make changes which bring you greater success than what has been provided, you share those ideas back to
3334 the community. Also, please don't nag me with a million questions and especially don't blame me if you lose a ton of money using this.
3435
3536 I take no responsibility for any success or failure you have using this strategy.
3637
37-VERSION: 5.1.4
38+VERSION: 5.2
3839 """
3940
4041 class Solipsis5(IStrategy):
@@ -42,38 +43,38 @@
4243 ## Buy Space Hyperopt Variables
4344
4445 # Base Pair Params
45- base_mp = IntParameter(10, 50, default=30, space='buy')
46- base_rmi_max = IntParameter(30, 60, default=50, space='buy')
47- base_rmi_min = IntParameter(0, 30, default=20, space='buy')
48- base_ma_streak = IntParameter(1, 4, default=1, space='buy')
49- base_rmi_streak = IntParameter(3, 8, default=3, space='buy')
50- base_trigger = CategoricalParameter(['pcc', 'rmi', 'none'], default='rmi', space='buy', optimize=True)
51- inf_pct_adr = DecimalParameter(0.70, 0.99, default=0.80, space='buy')
46+ base_mp = IntParameter(10, 50, default=30, space='buy', load=True, optimize=True)
47+ base_rmi_max = IntParameter(30, 60, default=50, space='buy', load=True, optimize=True)
48+ base_rmi_min = IntParameter(0, 30, default=20, space='buy', load=True, optimize=True)
49+ base_ma_streak = IntParameter(1, 4, default=1, space='buy', load=True, optimize=True)
50+ base_rmi_streak = IntParameter(3, 8, default=3, space='buy', load=True, optimize=True)
51+ base_trigger = CategoricalParameter(['pcc', 'rmi', 'none'], default='rmi', space='buy', load=True, optimize=True)
52+ inf_pct_adr = DecimalParameter(0.70, 0.99, default=0.80, space='buy', load=True, optimize=True)
5253 # BTC Informative
5354 xbtc_guard = CategoricalParameter(['strict', 'lazy', 'none'], default='lazy', space='buy', optimize=True)
54- xbtc_base_rmi = IntParameter(20, 70, default=40, space='buy')
55+ xbtc_base_rmi = IntParameter(20, 70, default=40, space='buy', load=True, optimize=True)
5556 # BTC / ETH Stake Parameters
56- xtra_base_stake_rmi = IntParameter(10, 50, default=50, space='buy')
57- xtra_base_fiat_rmi = IntParameter(30, 70, default=50, space='buy')
57+ xtra_base_stake_rmi = IntParameter(10, 50, default=50, space='buy', load=True, optimize=True)
58+ xtra_base_fiat_rmi = IntParameter(30, 70, default=50, space='buy', load=True, optimize=True)
5859
5960 ## Sell Space Params are being used for both custom_stoploss and custom_sell
6061
6162 # Custom Sell Profit (formerly Dynamic ROI)
62- csell_roi_type = CategoricalParameter(['static', 'decay', 'step'], default='step', space='sell', optimize=True)
63- csell_roi_time = IntParameter(720, 1440, default=720, space='sell')
64- csell_roi_start = DecimalParameter(0.01, 0.05, default=0.01, space='sell')
65- csell_roi_end = DecimalParameter(0.0, 0.01, default=0, space='sell')
66- csell_trend_type = CategoricalParameter(['rmi', 'ssl', 'candle', 'any'], default='any', space='sell', optimize=True)
67- csell_pullback = CategoricalParameter([True, False], default=True, space='sell', optimize=True)
68- csell_pullback_amount = DecimalParameter(0.005, 0.03, default=0.01, space='sell')
69- csell_pullback_respect_roi = CategoricalParameter([True, False], default=False, space='sell', optimize=True)
70-
71- # Custom Sell Loss (formerly Custom Stoploss)
72- csell_loss_threshold = DecimalParameter(-0.05, 0, default=-0.03, space='sell')
73- csell_bail_how = CategoricalParameter(['roc', 'time', 'any', 'none'], default='none', space='sell', optimize=True)
74- csell_bail_roc = DecimalParameter(-5.0, -1.0, default=-3.0, space='sell')
75- csell_bail_time = IntParameter(720, 1440, default=720, space='sell')
76- csell_bail_time_trend = CategoricalParameter([True, False], default=True, space='sell', optimize=True)
63+ csell_roi_type = CategoricalParameter(['static', 'decay', 'step'], default='step', space='sell', load=True, optimize=True)
64+ csell_roi_time = IntParameter(720, 1440, default=720, space='sell', load=True, optimize=True)
65+ csell_roi_start = DecimalParameter(0.01, 0.05, default=0.01, space='sell', load=True, optimize=True)
66+ csell_roi_end = DecimalParameter(0.0, 0.01, default=0, space='sell', load=True, optimize=True)
67+ csell_trend_type = CategoricalParameter(['rmi', 'ssl', 'candle', 'any', 'none'], default='any', space='sell', load=True, optimize=True)
68+ csell_pullback = CategoricalParameter([True, False], default=True, space='sell', load=True, optimize=True)
69+ csell_pullback_amount = DecimalParameter(0.005, 0.03, default=0.01, space='sell', load=True, optimize=True)
70+ csell_pullback_respect_roi = CategoricalParameter([True, False], default=False, space='sell', load=True, optimize=True)
71+
72+ # Custom Stoploss
73+ cstop_loss_threshold = DecimalParameter(-0.05, -0.01, default=-0.03, space='sell', load=True, optimize=True)
74+ cstop_bail_how = CategoricalParameter(['roc', 'time', 'any', 'none'], default='none', space='sell', load=True, optimize=True)
75+ cstop_bail_roc = DecimalParameter(-5.0, -1.0, default=-3.0, space='sell', load=True, optimize=True)
76+ cstop_bail_time = IntParameter(60, 1440, default=720, space='sell', load=True, optimize=True)
77+ cstop_bail_time_trend = CategoricalParameter([True, False], default=True, space='sell', load=True, optimize=True)
7778
7879 timeframe = '5m'
7980 inf_timeframe = '1h'
@@ -86,12 +87,13 @@
8687 "0": 100
8788 }
8889
89- stoploss = -0.10
90+ stoploss = -0.99
91+ use_custom_stoploss = True
9092
9193 # Recommended
9294 use_sell_signal = True
93- sell_profit_only = False
94- ignore_roi_if_buy_signal = False
95+ sell_profit_only = True
96+ ignore_roi_if_buy_signal = True
9597
9698 # Required
9799 startup_candle_count: int = 233
@@ -292,10 +294,33 @@
292294
293295 return dataframe
294296
297+ """
298+ Custom Stoploss
299+ """
300+ def custom_stoploss(self, pair: str, trade: 'Trade', current_time: datetime, current_rate: float, current_profit: float, **kwargs) -> float:
301+
302+ dataframe, _ = self.dp.get_analyzed_dataframe(pair=pair, timeframe=self.timeframe)
303+ last_candle = dataframe.iloc[-1].squeeze()
304+ trade_dur = int((current_time.timestamp() - trade.open_date_utc.timestamp()) // 60)
305+ in_trend = self.custom_trade_info[trade.pair]['had-trend']
306+
307+ # Determine how we sell when we are in a loss
308+ if current_profit < self.cstop_loss_threshold.value:
309+ if self.cstop_bail_how.value == 'roc' or self.cstop_bail_how.value == 'any':
310+ # Dynamic bailout based on rate of change
311+ if last_candle['sroc'] <= self.cstop_bail_roc.value:
312+ return 0.01
313+ if self.cstop_bail_how.value == 'time' or self.cstop_bail_how.value == 'any':
314+ # Dynamic bailout based on time, unless time_trend is true and there is a potential reversal
315+ if trade_dur > self.cstop_bail_time.value:
316+ if self.cstop_bail_time_trend.value == True and in_trend == True:
317+ return 1
318+ else:
319+ return 0.01
320+ return 1
321+
295322 """
296323 Custom Sell
297- Current implementation is meant to behave similar to my original "dynamic_roi" concept when in profit
298- or like the original "custom_stoploss" when at a loss.
299324 """
300325 def custom_sell(self, pair: str, trade: 'Trade', current_time: 'datetime', current_rate: float,
301326 current_profit: float, **kwargs):
@@ -303,12 +328,6 @@
303328 dataframe, _ = self.dp.get_analyzed_dataframe(pair=pair, timeframe=self.timeframe)
304329 last_candle = dataframe.iloc[-1].squeeze()
305330
306- # Temporary workaround because current_profit as fed to this method uses candle high
307- # This might get changed in a future freqtrade release
308- # See: https://github.com/freqtrade/freqtrade/issues/4920
309- # Backtest will resolve the sale price, once triggered at the *open* of the *next* candle
310- current_profit = trade.calc_profit_ratio(last_candle['close'])
311-
312331 trade_dur = int((current_time.timestamp() - trade.open_date_utc.timestamp()) // 60)
313332 max_profit = max(0, trade.calc_profit_ratio(trade.max_rate))
314333 pullback_value = max(0, (max_profit - self.csell_pullback_amount.value))
@@ -352,24 +371,15 @@
352371 # We are in a trend and pullback is disabled or has not happened or various criteria were not met, hold
353372 return None
354373 # If we are not in a trend, just use the roi value
355- elif in_trend == False and current_profit > min_roi:
374+ elif in_trend == False:
356375 if self.custom_trade_info[trade.pair]['had-trend']:
357- self.custom_trade_info[trade.pair]['had-trend'] = False
358- return 'trend_roi'
359- else:
376+ if current_profit > min_roi:
377+ self.custom_trade_info[trade.pair]['had-trend'] = False
378+ return 'trend_roi'
379+ elif self.sell_endtrend_respect_roi == False:
380+ self.custom_trade_info[trade.pair]['had-trend'] = False
381+ return 'trend_noroi'
382+ elif current_profit > min_roi:
360383 return 'notrend_roi'
361- # Determine how we sell when we are in a loss
362- elif current_profit < self.csell_loss_threshold.value:
363- if self.csell_bail_how.value == 'roc' or self.csell_bail_how.value == 'any':
364- # Dynamic bailout based on rate of change
365- if last_candle['sroc'] <= self.csell_bail_roc.value:
366- return 'loss_roc'
367- if self.csell_bail_how.value == 'time' or self.csell_bail_how.value == 'any':
368- # Dynamic bailout based on time, unless time_trend is true and there is a potential reversal
369- if trade_dur > self.csell_bail_time.value:
370- if self.csell_bail_time_trend.value == True and in_trend == True:
371- return None
372- else:
373- return 'loss_timeout'
374384 else:
375385 return None
No newline at the end of the file