Merge commit '4dca84817eb1b62047a9e4d282254392ea978e44' into feature/objectify
This commit is contained in:
@@ -13,11 +13,11 @@ from freqtrade import optimize
|
||||
from freqtrade.optimize.backtesting import Backtesting, start, setup_configuration
|
||||
from freqtrade.arguments import Arguments
|
||||
from freqtrade.analyze import Analyze
|
||||
import freqtrade.tests.conftest as tt # test tools
|
||||
from freqtrade.tests.conftest import default_conf, log_has
|
||||
|
||||
|
||||
# Avoid to reinit the same object again and again
|
||||
_BACKTESTING = Backtesting(tt.default_conf())
|
||||
_BACKTESTING = Backtesting(default_conf())
|
||||
|
||||
|
||||
def get_args(args) -> List[str]:
|
||||
@@ -184,21 +184,21 @@ def test_setup_configuration_without_arguments(mocker, default_conf, caplog) ->
|
||||
assert 'exchange' in config
|
||||
assert 'pair_whitelist' in config['exchange']
|
||||
assert 'datadir' in config
|
||||
assert tt.log_has(
|
||||
assert log_has(
|
||||
'Parameter --datadir detected: {} ...'.format(config['datadir']),
|
||||
caplog.record_tuples
|
||||
)
|
||||
assert 'ticker_interval' in config
|
||||
assert not tt.log_has('Parameter -i/--ticker-interval detected ...', caplog.record_tuples)
|
||||
assert not log_has('Parameter -i/--ticker-interval detected ...', caplog.record_tuples)
|
||||
|
||||
assert 'live' not in config
|
||||
assert not tt.log_has('Parameter -l/--live detected ...', caplog.record_tuples)
|
||||
assert not log_has('Parameter -l/--live detected ...', caplog.record_tuples)
|
||||
|
||||
assert 'realistic_simulation' not in config
|
||||
assert not tt.log_has('Parameter --realistic-simulation detected ...', caplog.record_tuples)
|
||||
assert not log_has('Parameter --realistic-simulation detected ...', caplog.record_tuples)
|
||||
|
||||
assert 'refresh_pairs' not in config
|
||||
assert not tt.log_has('Parameter -r/--refresh-pairs-cached detected ...', caplog.record_tuples)
|
||||
assert not log_has('Parameter -r/--refresh-pairs-cached detected ...', caplog.record_tuples)
|
||||
|
||||
assert 'timerange' not in config
|
||||
assert 'export' not in config
|
||||
@@ -232,34 +232,34 @@ def test_setup_configuration_with_arguments(mocker, default_conf, caplog) -> Non
|
||||
assert 'exchange' in config
|
||||
assert 'pair_whitelist' in config['exchange']
|
||||
assert 'datadir' in config
|
||||
assert tt.log_has(
|
||||
assert log_has(
|
||||
'Parameter --datadir detected: {} ...'.format(config['datadir']),
|
||||
caplog.record_tuples
|
||||
)
|
||||
assert 'ticker_interval' in config
|
||||
assert tt.log_has('Parameter -i/--ticker-interval detected ...', caplog.record_tuples)
|
||||
assert tt.log_has(
|
||||
assert log_has('Parameter -i/--ticker-interval detected ...', caplog.record_tuples)
|
||||
assert log_has(
|
||||
'Using ticker_interval: 1 ...',
|
||||
caplog.record_tuples
|
||||
)
|
||||
|
||||
assert 'live' in config
|
||||
assert tt.log_has('Parameter -l/--live detected ...', caplog.record_tuples)
|
||||
assert log_has('Parameter -l/--live detected ...', caplog.record_tuples)
|
||||
|
||||
assert 'realistic_simulation'in config
|
||||
assert tt.log_has('Parameter --realistic-simulation detected ...', caplog.record_tuples)
|
||||
assert tt.log_has('Using max_open_trades: 1 ...', caplog.record_tuples)
|
||||
assert log_has('Parameter --realistic-simulation detected ...', caplog.record_tuples)
|
||||
assert log_has('Using max_open_trades: 1 ...', caplog.record_tuples)
|
||||
|
||||
assert 'refresh_pairs'in config
|
||||
assert tt.log_has('Parameter -r/--refresh-pairs-cached detected ...', caplog.record_tuples)
|
||||
assert log_has('Parameter -r/--refresh-pairs-cached detected ...', caplog.record_tuples)
|
||||
assert 'timerange' in config
|
||||
assert tt.log_has(
|
||||
assert log_has(
|
||||
'Parameter --timerange detected: {} ...'.format(config['timerange']),
|
||||
caplog.record_tuples
|
||||
)
|
||||
|
||||
assert 'export' in config
|
||||
assert tt.log_has(
|
||||
assert log_has(
|
||||
'Parameter --export detected: {} ...'.format(config['export']),
|
||||
caplog.record_tuples
|
||||
)
|
||||
@@ -281,7 +281,7 @@ def test_start(mocker, default_conf, caplog) -> None:
|
||||
]
|
||||
args = get_args(args)
|
||||
start(args)
|
||||
assert tt.log_has(
|
||||
assert log_has(
|
||||
'Starting freqtrade in Backtesting mode',
|
||||
caplog.record_tuples
|
||||
)
|
||||
@@ -422,7 +422,7 @@ def test_backtesting_start(default_conf, mocker, caplog) -> None:
|
||||
'up to 2017-11-14T22:59:00+00:00 (0 days)..'
|
||||
]
|
||||
for line in exists:
|
||||
assert tt.log_has(line, caplog.record_tuples)
|
||||
assert log_has(line, caplog.record_tuples)
|
||||
|
||||
|
||||
def test_backtest(default_conf) -> None:
|
||||
@@ -605,4 +605,4 @@ def test_backtest_start_live(default_conf, mocker, caplog):
|
||||
]
|
||||
|
||||
for line in exists:
|
||||
tt.log_has(line, caplog.record_tuples)
|
||||
log_has(line, caplog.record_tuples)
|
||||
|
@@ -4,11 +4,11 @@ from copy import deepcopy
|
||||
from unittest.mock import MagicMock
|
||||
import pandas as pd
|
||||
from freqtrade.optimize.hyperopt import Hyperopt
|
||||
import freqtrade.tests.conftest as tt # test tools
|
||||
from freqtrade.tests.conftest import default_conf, log_has
|
||||
|
||||
|
||||
# Avoid to reinit the same object again and again
|
||||
_HYPEROPT = Hyperopt(tt.default_conf())
|
||||
_HYPEROPT = Hyperopt(default_conf())
|
||||
|
||||
|
||||
# Functions for recurrent object patching
|
||||
@@ -83,7 +83,7 @@ def test_log_results_if_loss_improves(caplog) -> None:
|
||||
'result': 'foo'
|
||||
}
|
||||
)
|
||||
assert tt.log_has(' 1/2: foo. Loss 1.00000', caplog.record_tuples)
|
||||
assert log_has(' 1/2: foo. Loss 1.00000', caplog.record_tuples)
|
||||
|
||||
|
||||
def test_no_log_if_loss_does_not_improve(caplog) -> None:
|
||||
@@ -245,7 +245,7 @@ def test_save_trials_saves_trials(mocker, caplog) -> None:
|
||||
|
||||
hyperopt.save_trials()
|
||||
|
||||
assert tt.log_has(
|
||||
assert log_has(
|
||||
'Saving Trials to \'freqtrade/tests/optimize/ut_trials.pickle\'',
|
||||
caplog.record_tuples
|
||||
)
|
||||
@@ -259,7 +259,7 @@ def test_read_trials_returns_trials_file(mocker, default_conf, caplog) -> None:
|
||||
|
||||
hyperopt = _HYPEROPT
|
||||
hyperopt_trial = hyperopt.read_trials()
|
||||
assert tt.log_has(
|
||||
assert log_has(
|
||||
'Reading Trials from \'freqtrade/tests/optimize/ut_trials.pickle\'',
|
||||
caplog.record_tuples
|
||||
)
|
||||
|
@@ -2,13 +2,13 @@
|
||||
|
||||
import os
|
||||
import json
|
||||
import logging
|
||||
import uuid
|
||||
from shutil import copyfile
|
||||
from freqtrade import optimize
|
||||
from freqtrade.optimize.__init__ import make_testdata_path, download_pairs,\
|
||||
download_backtesting_testdata, load_tickerdata_file, trim_tickerlist
|
||||
from freqtrade.misc import file_dump_json
|
||||
from freqtrade.tests.conftest import log_has
|
||||
|
||||
# Change this if modifying BTC_UNITEST testdatafile
|
||||
_BTC_UNITTEST_LENGTH = 13681
|
||||
@@ -55,9 +55,7 @@ def test_load_data_30min_ticker(ticker_history, mocker, caplog) -> None:
|
||||
_backup_file(file, copy_file=True)
|
||||
optimize.load_data(None, pairs=['BTC_UNITTEST'], ticker_interval=30)
|
||||
assert os.path.isfile(file) is True
|
||||
assert ('freqtrade.optimize',
|
||||
logging.INFO,
|
||||
'Download the pair: "BTC_ETH", Interval: 30 min') not in caplog.record_tuples
|
||||
assert not log_has('Download the pair: "BTC_ETH", Interval: 30 min', caplog.record_tuples)
|
||||
_clean_test_file(file)
|
||||
|
||||
|
||||
@@ -71,9 +69,7 @@ def test_load_data_5min_ticker(ticker_history, mocker, caplog) -> None:
|
||||
_backup_file(file, copy_file=True)
|
||||
optimize.load_data(None, pairs=['BTC_ETH'], ticker_interval=5)
|
||||
assert os.path.isfile(file) is True
|
||||
assert ('freqtrade.optimize',
|
||||
logging.INFO,
|
||||
'Download the pair: "BTC_ETH", Interval: 5 min') not in caplog.record_tuples
|
||||
assert not log_has('Download the pair: "BTC_ETH", Interval: 5 min', caplog.record_tuples)
|
||||
_clean_test_file(file)
|
||||
|
||||
|
||||
@@ -87,9 +83,7 @@ def test_load_data_1min_ticker(ticker_history, mocker, caplog) -> None:
|
||||
_backup_file(file, copy_file=True)
|
||||
optimize.load_data(None, ticker_interval=1, pairs=['BTC_ETH'])
|
||||
assert os.path.isfile(file) is True
|
||||
assert ('freqtrade.optimize',
|
||||
logging.INFO,
|
||||
'Download the pair: "BTC_ETH", Interval: 1 min') not in caplog.record_tuples
|
||||
assert not log_has('Download the pair: "BTC_ETH", Interval: 1 min', caplog.record_tuples)
|
||||
_clean_test_file(file)
|
||||
|
||||
|
||||
@@ -103,9 +97,7 @@ def test_load_data_with_new_pair_1min(ticker_history, mocker, caplog) -> None:
|
||||
_backup_file(file)
|
||||
optimize.load_data(None, ticker_interval=1, pairs=['BTC_MEME'])
|
||||
assert os.path.isfile(file) is True
|
||||
assert ('freqtrade.optimize',
|
||||
logging.INFO,
|
||||
'Download the pair: "BTC_MEME", Interval: 1 min') in caplog.record_tuples
|
||||
assert log_has('Download the pair: "BTC_MEME", Interval: 1 min', caplog.record_tuples)
|
||||
_clean_test_file(file)
|
||||
|
||||
|
||||
@@ -165,9 +157,7 @@ def test_download_pairs_exception(ticker_history, mocker, caplog) -> None:
|
||||
# clean files freshly downloaded
|
||||
_clean_test_file(file1_1)
|
||||
_clean_test_file(file1_5)
|
||||
assert ('freqtrade.optimize.__init__',
|
||||
logging.INFO,
|
||||
'Failed to download the pair: "BTC-MEME", Interval: 1 min') in caplog.record_tuples
|
||||
assert log_has('Failed to download the pair: "BTC-MEME", Interval: 1 min', caplog.record_tuples)
|
||||
|
||||
|
||||
def test_download_backtesting_testdata(ticker_history, mocker) -> None:
|
||||
|
Reference in New Issue
Block a user