Elffuss BraidHub

kikocis/freqtrade public

develop · 1.5 KiBRawPermalink
1from copy import deepcopy
2from datetime import datetime
3from pathlib import Path
4
5import pandas as pd
6import pytest
7
8from freqtrade.optimize.hyperopt import Hyperopt
9from freqtrade.strategy.interface import SellType
10from tests.conftest import patch_exchange
11
12
13@pytest.fixture(scope='function')
14def hyperopt_conf(default_conf):
15 hyperconf = deepcopy(default_conf)
16 hyperconf.update({
17 'datadir': Path(default_conf['datadir']),
18 'hyperopt': 'DefaultHyperOpt',
19 'hyperopt_loss': 'ShortTradeDurHyperOptLoss',
20 'hyperopt_path': str(Path(__file__).parent / 'hyperopts'),
21 'epochs': 1,
22 'timerange': None,
23 'spaces': ['default'],
24 'hyperopt_jobs': 1,
25 'hyperopt_min_trades': 1,
26 })
27 return hyperconf
28
29
30@pytest.fixture(scope='function')
31def hyperopt(hyperopt_conf, mocker):
32
33 patch_exchange(mocker)
34 return Hyperopt(hyperopt_conf)
35
36
37@pytest.fixture(scope='function')
38def hyperopt_results():
39 return pd.DataFrame(
40 {
41 'pair': ['ETH/BTC', 'ETH/BTC', 'ETH/BTC'],
42 'profit_ratio': [-0.1, 0.2, 0.3],
43 'profit_abs': [-0.2, 0.4, 0.6],
44 'trade_duration': [10, 30, 10],
45 'sell_reason': [SellType.STOP_LOSS, SellType.ROI, SellType.ROI],
46 'close_date':
47 [
48 datetime(2019, 1, 1, 9, 26, 3, 478039),
49 datetime(2019, 2, 1, 9, 26, 3, 478039),
50 datetime(2019, 3, 1, 9, 26, 3, 478039)
51 ]
52 }
53 )