Add sample for Nested space

This commit is contained in:
Matthias 2021-04-03 16:13:49 +02:00
parent c2d43a526c
commit 093d6ce8af
2 changed files with 13 additions and 1 deletions

View File

@ -70,6 +70,18 @@ This function needs to return a floating point number (`float`). Smaller numbers
!!! Note
Please keep the arguments `*args` and `**kwargs` in the interface to allow us to extend this interface later.
## Overriding pre-defined spaces
To override a pre-defined space (`roi_space`, `generate_roi_table`, `stoploss_space`, `trailing_space`), define a nested class called Hyperopt and define the required spaces as follows:
```python
class MyAwesomeStrategy(IStrategy):
class HyperOpt:
# Define a custom stoploss space.
def stoploss_space(self):
return [Real(-0.05, -0.01, name='stoploss')]
```
## Legacy Hyperopt
This Section explains the configuration of an explicit Hyperopt file (separate to the strategy).

View File

@ -151,7 +151,7 @@ Depending on the space you want to optimize, only some of the below are required
!!! Note
`populate_indicators` needs to create all indicators any of the spaces may use, otherwise hyperopt will not work.
Rarely you may also need to create a nested class named `HyperOpt` and implement:
Rarely you may also need to create a [nested class](advanced-hyperopt.md#overriding-pre-defined-spaces) named `HyperOpt` and implement
* `roi_space` - for custom ROI optimization (if you need the ranges for the ROI parameters in the optimization hyperspace that differ from default)
* `generate_roi_table` - for custom ROI optimization (if you need the ranges for the values in the ROI table that differ from default or the number of entries (steps) in the ROI table which differs from the default 4 steps)