From 093d6ce8af24bdf37a14b0505f23dd414d40682f Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 3 Apr 2021 16:13:49 +0200 Subject: [PATCH] Add sample for Nested space --- docs/advanced-hyperopt.md | 12 ++++++++++++ docs/hyperopt.md | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/advanced-hyperopt.md b/docs/advanced-hyperopt.md index 6a559ec96..723163b2c 100644 --- a/docs/advanced-hyperopt.md +++ b/docs/advanced-hyperopt.md @@ -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). diff --git a/docs/hyperopt.md b/docs/hyperopt.md index cb8d4ad9d..1ce1f9a86 100644 --- a/docs/hyperopt.md +++ b/docs/hyperopt.md @@ -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)