Allow importing interface from hyperopt.py
This commit is contained in:
parent
0e500de1a0
commit
639a4d5cf7
@ -161,12 +161,14 @@ This class should be in it's own file within the `user_data/hyperopts/` director
|
|||||||
|
|
||||||
### Using a custom loss function
|
### Using a custom loss function
|
||||||
|
|
||||||
To use a custom loss Class, make sure that the function `hyperopt_loss_function` is defined in your custom hyperopt class.
|
To use a custom loss Class, make sure that the function `hyperopt_loss_function` is defined in your custom hyperopt loss class.
|
||||||
For the sample below, you then need to add the command line parameter `--hyperoptloss SuperDuperHyperOptLoss` to your hyperopt call so this fuction is being used.
|
For the sample below, you then need to add the command line parameter `--hyperoptloss SuperDuperHyperOptLoss` to your hyperopt call so this fuction is being used.
|
||||||
|
|
||||||
A sample of this can be found below, which is identical to the Default Hyperopt loss implementation.
|
A sample of this can be found below, which is identical to the Default Hyperopt loss implementation. A full sample can be found [user_data/hyperopts/](https://github.com/freqtrade/freqtrade/blob/develop/user_data/hyperopts/sample_hyperopt_loss.py)
|
||||||
|
|
||||||
``` python
|
``` python
|
||||||
|
from freqtrade.optimize.hyperopt import IHyperOptLoss
|
||||||
|
|
||||||
TARGET_TRADES = 600
|
TARGET_TRADES = 600
|
||||||
EXPECTED_MAX_PROFIT = 3.0
|
EXPECTED_MAX_PROFIT = 3.0
|
||||||
MAX_ACCEPTED_TRADE_DURATION = 300
|
MAX_ACCEPTED_TRADE_DURATION = 300
|
||||||
|
@ -8,7 +8,7 @@ from math import exp
|
|||||||
|
|
||||||
from pandas import DataFrame
|
from pandas import DataFrame
|
||||||
|
|
||||||
from freqtrade.optimize.hyperopt_loss_interface import IHyperOptLoss
|
from freqtrade.optimize.hyperopt import IHyperOptLoss
|
||||||
|
|
||||||
# Define some constants:
|
# Define some constants:
|
||||||
|
|
||||||
|
@ -21,6 +21,8 @@ from skopt.space import Dimension
|
|||||||
from freqtrade.configuration import Arguments
|
from freqtrade.configuration import Arguments
|
||||||
from freqtrade.data.history import load_data, get_timeframe
|
from freqtrade.data.history import load_data, get_timeframe
|
||||||
from freqtrade.optimize.backtesting import Backtesting
|
from freqtrade.optimize.backtesting import Backtesting
|
||||||
|
# Import IHyperOptLoss to allow users import from this file
|
||||||
|
from freqtrade.optimize.hyperopt_loss_interface import IHyperOptLoss # noqa: F4
|
||||||
from freqtrade.resolvers.hyperopt_resolver import HyperOptResolver, HyperOptLossResolver
|
from freqtrade.resolvers.hyperopt_resolver import HyperOptResolver, HyperOptLossResolver
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ from datetime import datetime
|
|||||||
from pandas import DataFrame
|
from pandas import DataFrame
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from freqtrade.optimize.hyperopt_loss_interface import IHyperOptLoss
|
from freqtrade.optimize.hyperopt import IHyperOptLoss
|
||||||
|
|
||||||
|
|
||||||
class SharpeHyperOptLoss(IHyperOptLoss):
|
class SharpeHyperOptLoss(IHyperOptLoss):
|
||||||
|
@ -13,20 +13,6 @@ from skopt.space import Categorical, Dimension, Integer, Real
|
|||||||
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||||
from freqtrade.optimize.hyperopt_interface import IHyperOpt
|
from freqtrade.optimize.hyperopt_interface import IHyperOpt
|
||||||
|
|
||||||
# set TARGET_TRADES to suit your number concurrent trades so its realistic
|
|
||||||
# to the number of days
|
|
||||||
TARGET_TRADES = 600
|
|
||||||
# This is assumed to be expected avg profit * expected trade count.
|
|
||||||
# For example, for 0.35% avg per trade (or 0.0035 as ratio) and 1100 trades,
|
|
||||||
# self.expected_max_profit = 3.85
|
|
||||||
# Check that the reported Σ% values do not exceed this!
|
|
||||||
# Note, this is ratio. 3.85 stated above means 385Σ%.
|
|
||||||
EXPECTED_MAX_PROFIT = 3.0
|
|
||||||
|
|
||||||
# max average trade duration in minutes
|
|
||||||
# if eval ends with higher value, we consider it a failed eval
|
|
||||||
MAX_ACCEPTED_TRADE_DURATION = 300
|
|
||||||
|
|
||||||
|
|
||||||
# This class is a sample. Feel free to customize it.
|
# This class is a sample. Feel free to customize it.
|
||||||
class SampleHyperOpts(IHyperOpt):
|
class SampleHyperOpts(IHyperOpt):
|
||||||
|
Loading…
Reference in New Issue
Block a user