freqtrade / freqtrade-strategies

Free trading strategies for Freqtrade bot
GNU General Public License v3.0
3.27k stars 1.11k forks source link

Default futures strategy does not output all hyperopt indicator values used #256

Closed qkum closed 2 years ago

qkum commented 2 years ago

Describe your environment

Note: All bug reports will be closed without further comment if the above template is deleted or not filled out.

Describe the problem:

Explain the problem you have encountered

This is from the .json file hyperopting this strategy outputs. Same output as in the terminal:

{ "strategy_name": "Hyperopt_f_reinforced_average", "params": { "buy": { "pos_entry_adx": 28.2 }, "sell": { "pos_exit_adx": 34.7 }, "protection": { "lookback_period_candles": 51, "required_profit": 0.031, "stop_duration_candles": 87, "trade_limit": 2 }, "roi": { "0": 0.07999999999999999, "23": 0.057999999999999996, "64": 0.011, "144": 0 }, "stoploss": { "stoploss": -0.287 }, "trailing": { "trailing_stop": true, "trailing_stop_positive": 0.069, "trailing_stop_positive_offset": 0.10400000000000001, "trailing_only_offset_is_reached": false } }, "ft_stratparam_v": 1, "export_time": "2022-07-06 12:53:34.147246+00:00" }

    # Hyperoptable parameters

    # Define the guards spaces
    pos_entry_adx = DecimalParameter(15, 40, decimals=1, default=30.0, space="buy")
    pos_exit_adx = DecimalParameter(15, 40, decimals=1, default=30.0, space="sell")

    # Define the parameter spaces
    adx_period = IntParameter(4, 24, default=14)
    ema_short_period = IntParameter(4, 24, default=8)
    ema_long_period = IntParameter(12, 175, default=21)

Steps to reproduce:

  1. Just run it with the config.json that is supplied with the strategy in this forum.
  2. I added a random protection to the config and strategy to use the --spaces all to make sure it hyperopted all spaces and therefore all 5 variables that also should be outputted.

Observed Results:

Relevant code exceptions or logs

Thanks for all your hard work on this bot, freqtrade peeps 🎖️

qkum commented 2 years ago

If it is me who is too n00b to understand the code.

Then please write something that tells people why the code is calculating values within a range for the strategy to use for an indicator - but with no space="buy/sell".

Edit: The variable names are not as bad as I remembered. It is just me who are getting confused because the code is missing prober commenting and I have to guess it all after staring at code for many hours in a row 🌴

qkum commented 2 years ago

I suspect that the code uses the "default" value if space="buy/sell" is missing.

I tried to add space="buy" space="sell" to the indicators and then their value suddenly was outputted.

Like if someone deleted it before uploading it because they had found some good values for those indicators from hyperopting and then forgetting to add the code back before sharing it.

xmatthias commented 2 years ago
    # Define the parameter spaces
    adx_period = IntParameter(4, 24, default=14)
    ema_short_period = IntParameter(4, 24, default=8)
    ema_long_period = IntParameter(12, 175, default=21)

parameters where the space they belong to is unclear will be ignored.

Parameters must either be assigned to a variable named buy_* or sell_* - or contain space='buy' | space='sell' to be assigned to a space correctly. If no parameter is available for a space, you'll receive the error that no space was found when running hyperopt.

source - the "Parameter space assignment" box.

The error will appear if naming is inconclusive (e.g. sell_ema_long_period = IntParameter(12, 175, default=21, space="buy") - but parameters that have neither prefix nor space assigned will simply be ignored at the moment.

We'll probably update wording in the note-box to be more specific about this.