flake8 cleanup
This commit is contained in:
parent
6ac220982c
commit
a3d6b472a7
@ -643,14 +643,23 @@ In order to use these best dynamic ROI parameters found by Hyperopt in backtesti
|
|||||||
If you are optimizing dynamic ROI values, Freqtrade creates the 'dynamic-roi' optimization hyperspace for you. By default, the `enabled` parameter will try both True and False values. The value the `type` vary between `linear`, `exponential`, and `connect`.
|
If you are optimizing dynamic ROI values, Freqtrade creates the 'dynamic-roi' optimization hyperspace for you. By default, the `enabled` parameter will try both True and False values. The value the `type` vary between `linear`, `exponential`, and `connect`.
|
||||||
|
|
||||||
Other values have default ranges of:
|
Other values have default ranges of:
|
||||||
|
|
||||||
| Param | Range |
|
| Param | Range |
|
||||||
|------------|-------------|
|
|------------|-------------|
|
||||||
| decay-time | 180..1440 |
|
|
||||||
| decay-rate | 0.001..0.03 |
|
| decay-rate | 0.001..0.03 |
|
||||||
| start | 0.05..0.25 |
|
| start | 0.05..0.25 |
|
||||||
| end | 0..0.005 |
|
| end | 0..0.005 |
|
||||||
|
|
||||||
Override the `dynamic_roi_space()` method and define the desired range in it if you want values of the dynamic ROI parameters to vary in other ranges during hyperoptimization. A sample for this method can be found in [user_data/hyperopts/sample_hyperopt_advanced.py](https://github.com/freqtrade/freqtrade/blob/develop/freqtrade/templates/sample_hyperopt_advanced.py).
|
Just as the standard ROI table, the time decay value (in minutes) has a range which varies based on your candle size, for example:
|
||||||
|
|
||||||
|
| Candle | Range |
|
||||||
|
|----------|---------------|
|
||||||
|
| 1m | 30..144 |
|
||||||
|
| 5m | 150..720 |
|
||||||
|
| 1h | 1800..8640 |
|
||||||
|
| 1d | 3456..207360 |
|
||||||
|
|
||||||
|
It is **highly** recommended to override the `dynamic_roi_space()` method and define the desired ranges in it if you want values of the dynamic ROI parameters to vary in other ranges during hyperoptimization. A sample for this method can be found in [user_data/hyperopts/sample_hyperopt_advanced.py](https://github.com/freqtrade/freqtrade/blob/develop/freqtrade/templates/sample_hyperopt_advanced.py).
|
||||||
|
|
||||||
## Show details of Hyperopt results
|
## Show details of Hyperopt results
|
||||||
|
|
||||||
|
@ -263,7 +263,6 @@ class IHyperOpt(ABC):
|
|||||||
Real(0, 0.005, name='dynamic_roi_end')
|
Real(0, 0.005, name='dynamic_roi_end')
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
# This is needed for proper unpickling the class attribute ticker_interval
|
# This is needed for proper unpickling the class attribute ticker_interval
|
||||||
# which is set to the actual value by the resolver.
|
# which is set to the actual value by the resolver.
|
||||||
# Why do I still need such shamanic mantras in modern python?
|
# Why do I still need such shamanic mantras in modern python?
|
||||||
|
@ -642,16 +642,16 @@ class IStrategy(ABC):
|
|||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
if 'dynamic_roi_type' in dynamic_roi and dynamic_roi['dynamic_roi_type'] \
|
if 'dynamic_roi_type' in dynamic_roi and dynamic_roi['dynamic_roi_type'] \
|
||||||
in ['linear', 'exponential', 'connect']:
|
in ['linear', 'exponential', 'connect']:
|
||||||
roi_type = dynamic_roi['dynamic_roi_type']
|
roi_type = dynamic_roi['dynamic_roi_type']
|
||||||
# linear decay: f(t) = start - (rate * t)
|
# linear decay: f(t) = start - (rate * t)
|
||||||
if roi_type == 'linear':
|
if roi_type == 'linear':
|
||||||
if 'dynamic_roi_start' in dynamic_roi and 'dynamic_roi_end' in dynamic_roi and \
|
if 'dynamic_roi_start' in dynamic_roi and 'dynamic_roi_end' in dynamic_roi and \
|
||||||
'dynamic_roi_time' in dynamic_roi:
|
'dynamic_roi_time' in dynamic_roi:
|
||||||
start = dynamic_roi['dynamic_roi_start']
|
start = dynamic_roi['dynamic_roi_start']
|
||||||
end = dynamic_roi['dynamic_roi_end']
|
end = dynamic_roi['dynamic_roi_end']
|
||||||
time = dynamic_roi['dynamic_roi_time']
|
time = dynamic_roi['dynamic_roi_time']
|
||||||
rate = (start - end) / time
|
rate = (start - end) / time
|
||||||
min_roi = max(end, start - (rate * trade_dur))
|
min_roi = max(end, start - (rate * trade_dur))
|
||||||
return trade_dur, min_roi
|
return trade_dur, min_roi
|
||||||
else:
|
else:
|
||||||
@ -661,8 +661,8 @@ class IStrategy(ABC):
|
|||||||
if 'dynamic_roi_start' in dynamic_roi and 'dynamic_roi_end' in dynamic_roi and \
|
if 'dynamic_roi_start' in dynamic_roi and 'dynamic_roi_end' in dynamic_roi and \
|
||||||
'dynamic_roi_rate' in dynamic_roi:
|
'dynamic_roi_rate' in dynamic_roi:
|
||||||
start = dynamic_roi['dynamic_roi_start']
|
start = dynamic_roi['dynamic_roi_start']
|
||||||
end = dynamic_roi['dynamic_roi_end']
|
end = dynamic_roi['dynamic_roi_end']
|
||||||
rate = dynamic_roi['dynamic_roi_rate']
|
rate = dynamic_roi['dynamic_roi_rate']
|
||||||
min_roi = max(end, start * np.exp(-rate*trade_dur))
|
min_roi = max(end, start * np.exp(-rate*trade_dur))
|
||||||
return trade_dur, min_roi
|
return trade_dur, min_roi
|
||||||
else:
|
else:
|
||||||
@ -673,7 +673,7 @@ class IStrategy(ABC):
|
|||||||
return None, None
|
return None, None
|
||||||
# figure out where we are in the defined roi table
|
# figure out where we are in the defined roi table
|
||||||
past_roi = list(filter(lambda x: x <= trade_dur, minimal_roi.keys()))
|
past_roi = list(filter(lambda x: x <= trade_dur, minimal_roi.keys()))
|
||||||
next_roi = list(filter(lambda x: x > trade_dur, minimal_roi.keys()))
|
next_roi = list(filter(lambda x: x > trade_dur, minimal_roi.keys()))
|
||||||
# if we are past the final point in the table, use that key/vaule pair
|
# if we are past the final point in the table, use that key/vaule pair
|
||||||
if not past_roi:
|
if not past_roi:
|
||||||
return None, None
|
return None, None
|
||||||
@ -716,7 +716,7 @@ class IStrategy(ABC):
|
|||||||
trade_dur = int((current_time.timestamp() - trade.open_date_utc.timestamp()) // 60)
|
trade_dur = int((current_time.timestamp() - trade.open_date_utc.timestamp()) // 60)
|
||||||
|
|
||||||
if self.dynamic_roi and 'dynamic_roi_enabled' in self.dynamic_roi \
|
if self.dynamic_roi and 'dynamic_roi_enabled' in self.dynamic_roi \
|
||||||
and self.dynamic_roi['dynamic_roi_enabled']:
|
and self.dynamic_roi['dynamic_roi_enabled']:
|
||||||
_, roi = self.min_roi_reached_dynamic(trade_dur)
|
_, roi = self.min_roi_reached_dynamic(trade_dur)
|
||||||
else:
|
else:
|
||||||
_, roi = self.min_roi_reached_entry(trade_dur)
|
_, roi = self.min_roi_reached_entry(trade_dur)
|
||||||
|
@ -275,9 +275,9 @@ class AdvancedSampleHyperOpt(IHyperOpt):
|
|||||||
|
|
||||||
You may override it in your custom Hyperopt class.
|
You may override it in your custom Hyperopt class.
|
||||||
|
|
||||||
If you are reducing the types, you may also remove the parameters that will not be used on the
|
If you are reducing the types, you may also remove the parameters that will not be used on
|
||||||
reduced scope. For example, if you reduce the types to only 'connect' you do not need to specify
|
the reduced scope. For example, if you reduce the types to only 'connect' you do not
|
||||||
the ranges for decay-rate, decay-time, start, or end.
|
need to specify the ranges for decay-rate, decay-time, start, or end.
|
||||||
"""
|
"""
|
||||||
return [
|
return [
|
||||||
Categorical([True, False], name='dynamic_roi_enabled'),
|
Categorical([True, False], name='dynamic_roi_enabled'),
|
||||||
|
Loading…
Reference in New Issue
Block a user