Validate plot arguments

This commit is contained in:
Matthias
2019-09-03 07:05:48 +02:00
parent 1b66f01ec0
commit e107290230
2 changed files with 22 additions and 1 deletions

View File

@@ -1,15 +1,24 @@
from argparse import Namespace
from freqtrade import OperationalException
from freqtrade.state import RunMode
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:
"""
Entrypoint for dataframe plotting
"""
# Import here to avoid errors if plot-dependencies are not installed.
from freqtrade.plot.plotting import analyse_and_plot_pairs
validate_plot_args(args)
config = setup_utils_configuration(args, RunMode.PLOT)
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.
from freqtrade.plot.plotting import plot_profit
validate_plot_args(args)
config = setup_utils_configuration(args, RunMode.PLOT)
plot_profit(config)