Repository: freqtrade/freqtrade
Pull request: Hyperopt should mention that a strategy is mandatory.

## Summary
Add small section noting that a strategy file is always necessary for hyperopt

closes  #3047



Problem statement:
Docker-Compose: Hyperopt won't start without --strategy
## Step 1: Have you searched for this issue before posting it?

Yes, I did. 

## Step 2: Describe your environment

  * Operating system: Linux
  * Python Version: 3.8.2 (conda-env)
  * CCXT version: 1.23.69
  * Branch: Master
  
## Step 3: Describe the problem:

According to the documentation hyperopt will reuse some methods from the strategy file **IF** they are not already defined in the hyperopt file itself. So if the are defined, there shouldn't be the need to specify a strategy at all.

"Hyperopt can reuse populate_indicators, populate_buy_trend, populate_sell_trend from your strategy, assuming these methods are **not** in your custom hyperopt file, and a strategy is provided."

### Steps to reproduce:

  1. docker-compose run --rm freqtrade hyperopt --hyperopt CustomHyperopt --spaces all
  
### Observed Results:

  * What happened?
freqtrade threw an error and stopped

  * What did you expect to happen?
Run the hyperopt modul

### Relevant code exceptions or logs:

  ```
Creating network "docker_freqtrade_default" with the default driver
2020-03-09 22:20:49,867 - freqtrade.loggers - INFO - Verbosity set to 0
2020-03-09 22:20:49,867 - freqtrade.configuration.configuration - INFO - Using max_open_trades: 13 ...
2020-03-09 22:20:49,868 - freqtrade.configuration.configuration - INFO - Using user-data directory: /freqtrade/user_data ...
2020-03-09 22:20:49,868 - freqtrade.configuration.configuration - INFO - Using data directory: /freqtrade/user_data/data/binance ...
2020-03-09 22:20:49,868 - freqtrade.configuration.configuration - INFO - Using Hyperopt class name: CustomHyperopt
2020-03-09 22:20:49,868 - freqtrade.configuration.configuration - INFO - Parameter --epochs detected ... Will run Hyperopt with for 500 epochs ...
2020-03-09 22:20:49,868 - freqtrade.configuration.configuration - INFO - Parameter -s/--spaces detected: ['all']
2020-03-09 22:20:49,868 - freqtrade.configuration.configuration - INFO - Parameter -j/--job-workers detected: -1
2020-03-09 22:20:49,868 - freqtrade.configuration.configuration - INFO - Parameter --min-trades detected: 1
2020-03-09 22:20:49,868 - freqtrade.configuration.configuration - INFO - Using Hyperopt loss class name: DefaultHyperOptLoss
2020-03-09 22:20:49,868 - freqtrade.configuration.check_exchange - INFO - Checking exchange...
2020-03-09 22:20:49,868 - freqtrade.configuration.check_exchange - INFO - Exchange "binance" is officially supported by the Freqtrade development team.
2020-03-09 22:20:49,868 - freqtrade.configuration.configuration - INFO - Using pairlist from configuration.
2020-03-09 22:20:49,868 - freqtrade.configuration.config_validation - INFO - Validating configuration ...
2020-03-09 22:20:49,872 - freqtrade.commands.optimize_commands - INFO - Starting freqtrade in Hyperopt mode
2020-03-09 22:20:49,872 - filelock - INFO - Lock 139623767959056 acquired on /freqtrade/user_data/hyperopt.lock
2020-03-09 22:20:49,872 - freqtrade.exchange.exchange - INFO - Instance is running with dry_run enabled
2020-03-09 22:20:49,872 - freqtrade.exchange.exchange - INFO - Applying additional ccxt config: {'enableRateLimit': True}
2020-03-09 22:20:49,877 - freqtrade.exchange.exchange - INFO - Applying additional ccxt config: {'enableRateLimit': True, 'rateLimit': 200}
2020-03-09 22:20:49,883 - freqtrade.exchange.exchange - INFO - Using Exchange "Binance"
2020-03-09 22:20:51,074 - freqtrade.resolvers.exchange_resolver - INFO - Using resolved exchange 'Binance'...
2020-03-09 22:20:51,074 - freqtrade - ERROR - No strategy set. Please use `--strategy` to specify the strategy class to use.
  ```

Hints from issue discussion:
> So if the are defined, there shouldn't be the need to specify a strategy at all.

No, the strategy is not only the methods, but also attributes, that can significantly change the results of backtesting. Hyperopt class does not support currently all those attributes of the strategy. For simplicity (that was a rationale by @xmatthias ).

It was discussed some time ago and I proposed to add all those attributes into the hyperopt class as well (so that they can override the values of corresponding attributes in the strategy). In this case, the abstract Hyperopt base class could be derived from IStrategy -- to treat hyperopt classes as "extended version" of strategies. This would also allow to use hyperopt classes instead of strategies "as is". However, this was rejected, IIRC. Or, probably, we still have an inactive issue for this...

The current approach (which is not an error but "by design"): both --hyperopt and --strategy should be specified, and should correspond each other. Maybe @xmatthias would want to add some words on this.

Well as you say - it's by design - and i'm not sure abut changing this, because hyperopt has some "pretty heavy" dependencies, you would not want on a system that needs to run 24/7 to trade...

It used to default to DefaultStrategy - and since we don't do that anymore it's very well possible that we overlooked the Hyperopt part of the docs regarding this ...
Alright, thank you for the information. Providing a strategy and changing the stake_amount to something different than "unlimited" solved both issues. A small change to the documentation might still help future user :)

Commit message: Add small section noting that a strategy file is always necessary

fix #3047

Patch to review:
diff --git a/docs/hyperopt.md b/docs/hyperopt.md
index 30a22a9697c..55d2d984c9f 100644
--- a/docs/hyperopt.md
+++ b/docs/hyperopt.md
@@ -63,6 +63,9 @@ Optional - can also be loaded from a strategy:
 !!! Note
     Assuming the optional methods are not in your hyperopt file, please use `--strategy AweSomeStrategy` which contains these methods so hyperopt can use these methods instead.
 
+!!! Note
+    You will always have to provide a strategy to Hyperopt even if it contains all methods.
+
 Rarely you may also need to override:
 
 * `roi_space` - for custom ROI optimization (if you need the ranges for the ROI parameters in the optimization hyperspace that differ from default)


Code review comments:
diff_hunk: @@ -63,6 +63,9 @@ Optional - can also be loaded from a strategy:
 !!! Note
     Assuming the optional methods are not in your hyperopt file, please use `--strategy AweSomeStrategy` which contains these methods so hyperopt can use these methods instead.
 
+!!! Note
+    You will always have to provide a strategy to Hyperopt even if it contains all methods.
path: docs/hyperopt.md
text: @user1:
```suggestion
    You always have to provide a strategy to Hyperopt, even if your custom Hyperopt class contains all methods, including those that duplicate methods from the strategy.
```
or
```suggestion
    You always have to provide a strategy to Hyperopt, even if your custom Hyperopt class contains all methods.
```