From d2aca6fab24921fb2e2f0bea5a27539c386d7de4 Mon Sep 17 00:00:00 2001 From: Gert Wohlgemuth Date: Sun, 6 May 2018 16:36:04 -0700 Subject: [PATCH] added support to plot any given dataframe column --- freqtrade/arguments.py | 17 +++++++++++++---- scripts/plot_dataframe.py | 18 ++++++++++++++++++ 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/freqtrade/arguments.py b/freqtrade/arguments.py index b402adddc..a4f32411d 100644 --- a/freqtrade/arguments.py +++ b/freqtrade/arguments.py @@ -260,8 +260,7 @@ class Arguments(object): '--stop-loss', help='Renders stop/loss informations in the main chart', dest='stoplossdisplay', - default=False, - type=bool + action='store_true' ) self.parser.add_argument( @@ -285,13 +284,23 @@ class Arguments(object): default=None ) + self.parser.add_argument( + '--plot-dataframe', + help='Renders the specified dataframes', + dest='plotdataframe', + default=None, + nargs='+', + type=str + + ) + self.parser.add_argument( '--plot-volume', help='plots the volume as a subchart', dest='plotvolume', - default=False, - type=bool + action='store_true' ) + diff --git a/scripts/plot_dataframe.py b/scripts/plot_dataframe.py index 7f2d9fb3a..d187aa037 100755 --- a/scripts/plot_dataframe.py +++ b/scripts/plot_dataframe.py @@ -30,6 +30,20 @@ from freqtrade.configuration import Configuration logger = logging.getLogger(__name__) +def plot_dataframes(data, fig, args): + """ + plots additional dataframes in the main plot + :param data: + :param fig: + :param args: + :return: + """ + + for x in args.plotdataframe: + chart = go.Scattergl(x=data['date'], y=data[x], name=x) + fig.append_trace(chart, 1, 1) + + def plot_volume_dataframe(data, fig, args, plotnumber): """ adds the plotting of the volume @@ -42,6 +56,7 @@ def plot_volume_dataframe(data, fig, args, plotnumber): volume = go.Bar(x=data['date'], y=data['volume'], name='Volume') fig.append_trace(volume, plotnumber, 1) + def plot_macd_dataframe(data, fig, args, plotnumber): """ adds the plotting of the MACD if specified @@ -316,6 +331,9 @@ def plot_analyzed_dataframe(args: Namespace) -> None: # append stop loss/profit plot_stop_loss_trade(df_sell, fig, analyze, args) + # plot other dataframes + plot_dataframes(data, fig, args) + fig['layout'].update(title=args.pair) fig['layout']['yaxis1'].update(title='Price')