Validate plot arguments
This commit is contained in:
parent
1b66f01ec0
commit
e107290230
@ -1,15 +1,24 @@
|
|||||||
from argparse import Namespace
|
from argparse import Namespace
|
||||||
|
from freqtrade import OperationalException
|
||||||
from freqtrade.state import RunMode
|
from freqtrade.state import RunMode
|
||||||
from freqtrade.utils import setup_utils_configuration
|
from freqtrade.utils import setup_utils_configuration
|
||||||
|
|
||||||
|
|
||||||
|
def validate_plot_args(args: Namespace):
|
||||||
|
args_tmp = vars(args)
|
||||||
|
if not args_tmp.get('datadir') and not args_tmp.get('config'):
|
||||||
|
raise OperationalException(
|
||||||
|
"You need to specify either `--datadir` or `--config` "
|
||||||
|
"for plot-profit and plot-dataframe.")
|
||||||
|
|
||||||
|
|
||||||
def start_plot_dataframe(args: Namespace) -> None:
|
def start_plot_dataframe(args: Namespace) -> None:
|
||||||
"""
|
"""
|
||||||
Entrypoint for dataframe plotting
|
Entrypoint for dataframe plotting
|
||||||
"""
|
"""
|
||||||
# Import here to avoid errors if plot-dependencies are not installed.
|
# Import here to avoid errors if plot-dependencies are not installed.
|
||||||
from freqtrade.plot.plotting import analyse_and_plot_pairs
|
from freqtrade.plot.plotting import analyse_and_plot_pairs
|
||||||
|
validate_plot_args(args)
|
||||||
config = setup_utils_configuration(args, RunMode.PLOT)
|
config = setup_utils_configuration(args, RunMode.PLOT)
|
||||||
|
|
||||||
analyse_and_plot_pairs(config)
|
analyse_and_plot_pairs(config)
|
||||||
@ -21,6 +30,7 @@ def start_plot_profit(args: Namespace) -> None:
|
|||||||
"""
|
"""
|
||||||
# Import here to avoid errors if plot-dependencies are not installed.
|
# Import here to avoid errors if plot-dependencies are not installed.
|
||||||
from freqtrade.plot.plotting import plot_profit
|
from freqtrade.plot.plotting import plot_profit
|
||||||
|
validate_plot_args(args)
|
||||||
config = setup_utils_configuration(args, RunMode.PLOT)
|
config = setup_utils_configuration(args, RunMode.PLOT)
|
||||||
|
|
||||||
plot_profit(config)
|
plot_profit(config)
|
||||||
|
@ -4,8 +4,10 @@ from pathlib import Path
|
|||||||
from unittest.mock import MagicMock
|
from unittest.mock import MagicMock
|
||||||
|
|
||||||
import plotly.graph_objects as go
|
import plotly.graph_objects as go
|
||||||
|
import pytest
|
||||||
from plotly.subplots import make_subplots
|
from plotly.subplots import make_subplots
|
||||||
|
|
||||||
|
from freqtrade import OperationalException
|
||||||
from freqtrade.configuration import TimeRange
|
from freqtrade.configuration import TimeRange
|
||||||
from freqtrade.data import history
|
from freqtrade.data import history
|
||||||
from freqtrade.data.btanalysis import create_cum_profit, load_backtest_data
|
from freqtrade.data.btanalysis import create_cum_profit, load_backtest_data
|
||||||
@ -335,6 +337,15 @@ def test_start_plot_profit(mocker):
|
|||||||
assert called_config['pairs'] == ["ETH/BTC"]
|
assert called_config['pairs'] == ["ETH/BTC"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_start_plot_profit_error(mocker):
|
||||||
|
args = [
|
||||||
|
"plot-profit",
|
||||||
|
"--pairs", "ETH/BTC"
|
||||||
|
]
|
||||||
|
with pytest.raises(OperationalException):
|
||||||
|
start_plot_profit(get_args(args))
|
||||||
|
|
||||||
|
|
||||||
def test_plot_profit(default_conf, mocker, caplog):
|
def test_plot_profit(default_conf, mocker, caplog):
|
||||||
default_conf['trade_source'] = 'file'
|
default_conf['trade_source'] = 'file'
|
||||||
default_conf["datadir"] = history.make_testdata_path(None)
|
default_conf["datadir"] = history.make_testdata_path(None)
|
||||||
|
Loading…
Reference in New Issue
Block a user