Fix typo and add tests for create_plotconfig

This commit is contained in:
Matthias 2020-01-04 11:30:21 +01:00
parent 4628024de6
commit b5a806dec7
2 changed files with 25 additions and 1 deletions

View File

@ -165,7 +165,7 @@ def create_plotconfig(indicators1: List[str], indicators2: List[str], plot_confi
if not indicators1:
indicators1 = ['sma', 'ema3', 'ema5']
if not indicators2:
indicators1 = ['macd', 'macdsignal']
indicators2 = ['macd', 'macdsignal']
# Create subplot configuration if plot_config is not available.
plot_config = {

View File

@ -13,6 +13,7 @@ from freqtrade.data.btanalysis import create_cum_profit, load_backtest_data
from freqtrade.exceptions import OperationalException
from freqtrade.plot.plot_utils import start_plot_dataframe, start_plot_profit
from freqtrade.plot.plotting import (add_indicators, add_profit,
create_plotconfig,
generate_candlestick_graph,
generate_plot_filename,
generate_profit_graph, init_plotscript,
@ -372,3 +373,26 @@ def test_plot_profit(default_conf, mocker, testdatadir, caplog):
assert profit_mock.call_args_list[0][0][0] == default_conf['pairs']
assert store_mock.call_args_list[0][1]['auto_open'] is True
@pytest.mark.parametrize("ind1,ind2,plot_conf,exp", [
([], [], {},
{'main_plot': {'sma': {}, 'ema3': {}, 'ema5': {}},
'subplots': {'Other': {'macd': {}, 'macdsignal': {}}}}),
(['sma', 'ema3'], ['macd'], {},
{'main_plot': {'sma': {}, 'ema3': {}}, 'subplots': {'Other': {'macd': {}}}}
),
([], [], {'main_plot': {'sma': {}}},
{'main_plot': {'sma': {}}, 'subplots': {}}),
([], [], {'subplots': {'RSI': {'rsi': {'color': 'red'}}}},
{'main_plot': {}, 'subplots': {'RSI': {'rsi': {'color': 'red'}}}}),
])
def test_create_plotconfig(ind1, ind2, plot_conf, exp):
res = create_plotconfig(ind1, ind2, plot_conf)
assert 'main_plot' in res
assert 'subplots' in res
assert isinstance(res['main_plot'], dict)
assert isinstance(res['subplots'], dict)
assert res == exp