Move plot-options to arguments.py

This commit is contained in:
Matthias 2019-06-16 19:35:15 +02:00
parent bf2c0390e7
commit 0300128cb8
3 changed files with 48 additions and 28 deletions

View File

@ -55,7 +55,7 @@ class Arguments(object):
# Workaround issue in argparse with action='append' and default value
# (see https://bugs.python.org/issue16399)
if parsed_arg.config is None and not no_default_config:
if not no_default_config and parsed_arg.config is None:
parsed_arg.config = [constants.DEFAULT_CONFIG]
return parsed_arg
@ -514,3 +514,33 @@ class Arguments(object):
dest='erase',
action='store_true'
)
def plot_dataframe_options(self) -> None:
"""
Parses given arguments for plot_dataframe
"""
self.parser.add_argument(
'--indicators1',
help='Set indicators from your strategy you want in the first row of the graph. Separate '
'them with a comma. E.g: ema3,ema5 (default: %(default)s)',
type=str,
default='sma,ema3,ema5',
dest='indicators1',
)
self.parser.add_argument(
'--indicators2',
help='Set indicators from your strategy you want in the third row of the graph. Separate '
'them with a comma. E.g: macd,fastd,fastk (default: %(default)s)',
type=str,
default='macd,macdsignal',
dest='indicators2',
)
self.parser.add_argument(
'--plot-limit',
help='Specify tick limit for plotting - too high values cause huge files - '
'Default: %(default)s',
dest='plot_limit',
default=750,
type=int,
)

View File

@ -186,6 +186,20 @@ def test_download_data_options() -> None:
assert args.exchange == 'binance'
def test_plot_dataframe_options() -> None:
args = [
'--indicators1', 'sma10,sma100',
'--indicators2', 'macd,fastd,fastk',
'--plot-limit', '30',
]
arguments = Arguments(args, '')
arguments.plot_dataframe_options()
args = arguments.parse_args(True)
assert args.indicators1 == "sma10,sma100"
assert args.indicators2 == "macd,fastd,fastk"
assert args.plot_limit == 30
def test_check_int_positive() -> None:
assert Arguments.check_int_positive("3") == 3

View File

@ -34,10 +34,10 @@ import pandas as pd
from freqtrade.arguments import Arguments, TimeRange
from freqtrade.data import history
from freqtrade.data.btanalysis import load_trades
from freqtrade.data.btanalysis import load_trades, extract_trades_of_period
from freqtrade.exchange import Exchange
from freqtrade.optimize import setup_configuration
from freqtrade.plot.plotting import (extract_trades_of_period, generate_graph,
from freqtrade.plot.plotting import (generate_graph,
generate_plot_file)
from freqtrade.resolvers import StrategyResolver
from freqtrade.state import RunMode
@ -171,31 +171,7 @@ def plot_parse_args(args: List[str]) -> Namespace:
"""
arguments = Arguments(args, 'Graph dataframe')
arguments.scripts_options()
arguments.parser.add_argument(
'--indicators1',
help='Set indicators from your strategy you want in the first row of the graph. Separate '
'them with a coma. E.g: ema3,ema5 (default: %(default)s)',
type=str,
default='sma,ema3,ema5',
dest='indicators1',
)
arguments.parser.add_argument(
'--indicators2',
help='Set indicators from your strategy you want in the third row of the graph. Separate '
'them with a coma. E.g: fastd,fastk (default: %(default)s)',
type=str,
default='macd,macdsignal',
dest='indicators2',
)
arguments.parser.add_argument(
'--plot-limit',
help='Specify tick limit for plotting - too high values cause huge files - '
'Default: %(default)s',
dest='plot_limit',
default=750,
type=int,
)
arguments.plot_dataframe_options()
arguments.common_args_parser()
arguments.optimizer_shared_options(arguments.parser)
arguments.backtesting_options(arguments.parser)