From 0a184d380e0c0c045f7a4539da100fade9db51a3 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 30 Jun 2019 10:14:33 +0200 Subject: [PATCH] create add_profit function --- freqtrade/plot/plotting.py | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/freqtrade/plot/plotting.py b/freqtrade/plot/plotting.py index 2fe15d320..f8736fe74 100644 --- a/freqtrade/plot/plotting.py +++ b/freqtrade/plot/plotting.py @@ -5,9 +5,9 @@ from typing import Any, Dict, List, Optional import pandas as pd from freqtrade.arguments import Arguments -from frqtrade.exchange import Exchange +from freqtrade.exchange import Exchange from freqtrade.data import history -from freqtrade.data.btanalysis import load_trades +from freqtrade.data.btanalysis import load_trades, create_cum_profit from freqtrade.resolvers import ExchangeResolver, StrategyResolver logger = logging.getLogger(__name__) @@ -82,7 +82,27 @@ def add_indicators(fig, row, indicators: List[str], data: pd.DataFrame) -> tools return fig -def plot_trades(fig, trades: pd.DataFrame): +def add_profit(fig, row, data: pd.DataFrame, column: str, name: str) -> tools.make_subplots: + """ + Add profit-plot + :param fig: Plot figure to append to + :param row: row number for this plot + :param data: candlestick DataFrame + :param column: Column to use for plot + :param name: Name to use + :return: fig with added profit plot + """ + profit = go.Scattergl( + x=data.index, + y=data[column], + name=name, + ) + fig.append_trace(profit, row, 1) + + return fig + + +def plot_trades(fig, trades: pd.DataFrame) -> tools.make_subplots: """ Add trades to "fig" """