mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-14 04:03:55 +00:00
remove use of hyperopt_conf.py
This commit is contained in:
parent
af16830a38
commit
c1f8f641e6
|
@ -160,9 +160,8 @@ the parameter `-l` or `--live`.
|
||||||
|
|
||||||
## Hyperopt commands
|
## Hyperopt commands
|
||||||
|
|
||||||
It is possible to use hyperopt for trading strategy optimization.
|
To optimize your strategy, you can use hyperopt parameter hyperoptimization
|
||||||
Hyperopt uses an internal json config return by `hyperopt_optimize_conf()`
|
to find optimal parameter values for your stategy.
|
||||||
located in `freqtrade/optimize/hyperopt_conf.py`.
|
|
||||||
|
|
||||||
```
|
```
|
||||||
usage: main.py hyperopt [-h] [-i TICKER_INTERVAL] [--realistic-simulation]
|
usage: main.py hyperopt [-h] [-i TICKER_INTERVAL] [--realistic-simulation]
|
||||||
|
|
|
@ -11,8 +11,6 @@ from freqtrade import misc, constants
|
||||||
from freqtrade.exchange import get_ticker_history
|
from freqtrade.exchange import get_ticker_history
|
||||||
from freqtrade.arguments import TimeRange
|
from freqtrade.arguments import TimeRange
|
||||||
|
|
||||||
from user_data.hyperopt_conf import hyperopt_optimize_conf
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@ -83,7 +81,7 @@ def load_tickerdata_file(
|
||||||
|
|
||||||
def load_data(datadir: str,
|
def load_data(datadir: str,
|
||||||
ticker_interval: str,
|
ticker_interval: str,
|
||||||
pairs: Optional[List[str]] = None,
|
pairs: List[str],
|
||||||
refresh_pairs: Optional[bool] = False,
|
refresh_pairs: Optional[bool] = False,
|
||||||
timerange: TimeRange = TimeRange(None, None, 0, 0)) -> Dict[str, List]:
|
timerange: TimeRange = TimeRange(None, None, 0, 0)) -> Dict[str, List]:
|
||||||
"""
|
"""
|
||||||
|
@ -92,14 +90,12 @@ def load_data(datadir: str,
|
||||||
"""
|
"""
|
||||||
result = {}
|
result = {}
|
||||||
|
|
||||||
_pairs = pairs or hyperopt_optimize_conf()['exchange']['pair_whitelist']
|
|
||||||
|
|
||||||
# If the user force the refresh of pairs
|
# If the user force the refresh of pairs
|
||||||
if refresh_pairs:
|
if refresh_pairs:
|
||||||
logger.info('Download data for all pairs and store them in %s', datadir)
|
logger.info('Download data for all pairs and store them in %s', datadir)
|
||||||
download_pairs(datadir, _pairs, ticker_interval, timerange=timerange)
|
download_pairs(datadir, pairs, ticker_interval, timerange=timerange)
|
||||||
|
|
||||||
for pair in _pairs:
|
for pair in pairs:
|
||||||
pairdata = load_tickerdata_file(datadir, pair, ticker_interval, timerange=timerange)
|
pairdata = load_tickerdata_file(datadir, pair, ticker_interval, timerange=timerange)
|
||||||
if pairdata:
|
if pairdata:
|
||||||
result[pair] = pairdata
|
result[pair] = pairdata
|
||||||
|
|
|
@ -27,7 +27,6 @@ from freqtrade.arguments import Arguments
|
||||||
from freqtrade.configuration import Configuration
|
from freqtrade.configuration import Configuration
|
||||||
from freqtrade.optimize import load_data
|
from freqtrade.optimize import load_data
|
||||||
from freqtrade.optimize.backtesting import Backtesting
|
from freqtrade.optimize.backtesting import Backtesting
|
||||||
from user_data.hyperopt_conf import hyperopt_optimize_conf
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -596,11 +595,8 @@ def start(args: Namespace) -> None:
|
||||||
# Monkey patch the configuration with hyperopt_conf.py
|
# Monkey patch the configuration with hyperopt_conf.py
|
||||||
configuration = Configuration(args)
|
configuration = Configuration(args)
|
||||||
logger.info('Starting freqtrade in Hyperopt mode')
|
logger.info('Starting freqtrade in Hyperopt mode')
|
||||||
|
config = configuration.load_config()
|
||||||
|
|
||||||
optimize_config = hyperopt_optimize_conf()
|
|
||||||
config = configuration._load_common_config(optimize_config)
|
|
||||||
config = configuration._load_backtesting_config(config)
|
|
||||||
config = configuration._load_hyperopt_config(config)
|
|
||||||
config['exchange']['key'] = ''
|
config['exchange']['key'] = ''
|
||||||
config['exchange']['secret'] = ''
|
config['exchange']['secret'] = ''
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,6 @@ def init_hyperopt(default_conf, mocker):
|
||||||
global _HYPEROPT_INITIALIZED, _HYPEROPT
|
global _HYPEROPT_INITIALIZED, _HYPEROPT
|
||||||
if not _HYPEROPT_INITIALIZED:
|
if not _HYPEROPT_INITIALIZED:
|
||||||
mocker.patch('freqtrade.exchange.validate_pairs', MagicMock(return_value=True))
|
mocker.patch('freqtrade.exchange.validate_pairs', MagicMock(return_value=True))
|
||||||
mocker.patch('freqtrade.optimize.hyperopt.hyperopt_optimize_conf',
|
|
||||||
MagicMock(return_value=default_conf))
|
|
||||||
mocker.patch('freqtrade.exchange.validate_pairs', MagicMock())
|
mocker.patch('freqtrade.exchange.validate_pairs', MagicMock())
|
||||||
_HYPEROPT = Hyperopt(default_conf)
|
_HYPEROPT = Hyperopt(default_conf)
|
||||||
_HYPEROPT_INITIALIZED = True
|
_HYPEROPT_INITIALIZED = True
|
||||||
|
@ -64,8 +62,6 @@ def test_start(mocker, default_conf, caplog) -> None:
|
||||||
"""
|
"""
|
||||||
start_mock = MagicMock()
|
start_mock = MagicMock()
|
||||||
mocker.patch('freqtrade.optimize.hyperopt.Hyperopt.start', start_mock)
|
mocker.patch('freqtrade.optimize.hyperopt.Hyperopt.start', start_mock)
|
||||||
mocker.patch('freqtrade.optimize.hyperopt.hyperopt_optimize_conf',
|
|
||||||
MagicMock(return_value=default_conf))
|
|
||||||
mocker.patch('freqtrade.freqtradebot.exchange.validate_pairs', MagicMock())
|
mocker.patch('freqtrade.freqtradebot.exchange.validate_pairs', MagicMock())
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
|
@ -182,7 +178,6 @@ def test_fmin_best_results(mocker, init_hyperopt, default_conf, caplog) -> None:
|
||||||
|
|
||||||
mocker.patch('freqtrade.optimize.hyperopt.load_data', MagicMock())
|
mocker.patch('freqtrade.optimize.hyperopt.load_data', MagicMock())
|
||||||
mocker.patch('freqtrade.optimize.hyperopt.fmin', return_value=fmin_result)
|
mocker.patch('freqtrade.optimize.hyperopt.fmin', return_value=fmin_result)
|
||||||
mocker.patch('freqtrade.optimize.hyperopt.hyperopt_optimize_conf', return_value=conf)
|
|
||||||
mocker.patch('freqtrade.freqtradebot.exchange.validate_pairs', MagicMock())
|
mocker.patch('freqtrade.freqtradebot.exchange.validate_pairs', MagicMock())
|
||||||
|
|
||||||
StrategyResolver({'strategy': 'DefaultStrategy'})
|
StrategyResolver({'strategy': 'DefaultStrategy'})
|
||||||
|
@ -227,7 +222,6 @@ def test_fmin_throw_value_error(mocker, init_hyperopt, default_conf, caplog) ->
|
||||||
conf.update({'epochs': 1})
|
conf.update({'epochs': 1})
|
||||||
conf.update({'timerange': None})
|
conf.update({'timerange': None})
|
||||||
conf.update({'spaces': 'all'})
|
conf.update({'spaces': 'all'})
|
||||||
mocker.patch('freqtrade.optimize.hyperopt.hyperopt_optimize_conf', return_value=conf)
|
|
||||||
mocker.patch('freqtrade.freqtradebot.exchange.validate_pairs', MagicMock())
|
mocker.patch('freqtrade.freqtradebot.exchange.validate_pairs', MagicMock())
|
||||||
|
|
||||||
StrategyResolver({'strategy': 'DefaultStrategy'})
|
StrategyResolver({'strategy': 'DefaultStrategy'})
|
||||||
|
@ -270,7 +264,6 @@ def test_resuming_previous_hyperopt_results_succeeds(mocker, init_hyperopt, defa
|
||||||
mocker.patch('freqtrade.optimize.hyperopt.sorted', return_value=trials.results)
|
mocker.patch('freqtrade.optimize.hyperopt.sorted', return_value=trials.results)
|
||||||
mocker.patch('freqtrade.optimize.hyperopt.load_data', MagicMock())
|
mocker.patch('freqtrade.optimize.hyperopt.load_data', MagicMock())
|
||||||
mocker.patch('freqtrade.optimize.hyperopt.fmin', return_value={})
|
mocker.patch('freqtrade.optimize.hyperopt.fmin', return_value={})
|
||||||
mocker.patch('freqtrade.optimize.hyperopt.hyperopt_optimize_conf', return_value=conf)
|
|
||||||
mocker.patch('freqtrade.exchange.validate_pairs', MagicMock())
|
mocker.patch('freqtrade.exchange.validate_pairs', MagicMock())
|
||||||
|
|
||||||
StrategyResolver({'strategy': 'DefaultStrategy'})
|
StrategyResolver({'strategy': 'DefaultStrategy'})
|
||||||
|
|
|
@ -326,8 +326,6 @@ def test_load_tickerdata_file() -> None:
|
||||||
|
|
||||||
|
|
||||||
def test_init(default_conf, mocker) -> None:
|
def test_init(default_conf, mocker) -> None:
|
||||||
conf = {'exchange': {'pair_whitelist': []}}
|
|
||||||
mocker.patch('freqtrade.optimize.hyperopt_optimize_conf', return_value=conf)
|
|
||||||
assert {} == optimize.load_data(
|
assert {} == optimize.load_data(
|
||||||
'',
|
'',
|
||||||
pairs=[],
|
pairs=[],
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
"""
|
|
||||||
File that contains the configuration for Hyperopt
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
def hyperopt_optimize_conf() -> dict:
|
|
||||||
"""
|
|
||||||
This function is used to define which parameters Hyperopt must used.
|
|
||||||
The "pair_whitelist" is only used is your are using Hyperopt with MongoDB,
|
|
||||||
without MongoDB, Hyperopt will use the pair your have set in your config file.
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
return {
|
|
||||||
'max_open_trades': 3,
|
|
||||||
'stake_currency': 'BTC',
|
|
||||||
'stake_amount': 0.01,
|
|
||||||
"minimal_roi": {
|
|
||||||
'40': 0.0,
|
|
||||||
'30': 0.01,
|
|
||||||
'20': 0.02,
|
|
||||||
'0': 0.04,
|
|
||||||
},
|
|
||||||
'stoploss': -0.10,
|
|
||||||
"bid_strategy": {
|
|
||||||
"ask_last_balance": 0.0
|
|
||||||
},
|
|
||||||
"exchange": {
|
|
||||||
"name": "bittrex",
|
|
||||||
"pair_whitelist": [
|
|
||||||
"ETH/BTC",
|
|
||||||
"LTC/BTC",
|
|
||||||
"ETC/BTC",
|
|
||||||
"DASH/BTC",
|
|
||||||
"ZEC/BTC",
|
|
||||||
"XLM/BTC",
|
|
||||||
"NXT/BTC",
|
|
||||||
"POWR/BTC",
|
|
||||||
"ADA/BTC",
|
|
||||||
"XMR/BTC"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user