From 044be3b93e0c51c0826a0205219645ed2e4c32f8 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 29 Jun 2019 16:57:04 +0200 Subject: [PATCH] Add create_cum_profit column --- freqtrade/arguments.py | 2 +- freqtrade/data/btanalysis.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/freqtrade/arguments.py b/freqtrade/arguments.py index f020252f8..cf2c52ed6 100644 --- a/freqtrade/arguments.py +++ b/freqtrade/arguments.py @@ -359,7 +359,7 @@ ARGS_PLOT_DATAFRAME = (ARGS_COMMON + ARGS_STRATEGY + "refresh_pairs", "live"]) ARGS_PLOT_PROFIT = (ARGS_COMMON + ARGS_STRATEGY + - ["pairs", "timerange", "export", "exportfilename"]) + ["pairs", "timerange", "export", "exportfilename", "db_url", "trade_source"]) class TimeRange(NamedTuple): diff --git a/freqtrade/data/btanalysis.py b/freqtrade/data/btanalysis.py index 5a0dee042..30fd5bc93 100644 --- a/freqtrade/data/btanalysis.py +++ b/freqtrade/data/btanalysis.py @@ -109,3 +109,15 @@ def extract_trades_of_period(dataframe: pd.DataFrame, trades: pd.DataFrame) -> p trades = trades.loc[(trades['open_time'] >= dataframe.iloc[0]['date']) & (trades['close_time'] <= dataframe.iloc[-1]['date'])] return trades + + +def create_cum_profit(df: pd.DataFrame, trades: pd.DataFrame, col_name: str): + """ + Adds a column `col_name` with the cumulative profit for the given trades array. + """ + df[col_name] = trades.set_index('close_time')['profitperc'].cumsum() + # Set first value to 0 + df.loc[df.iloc[0].name, col_name] = 0 + # FFill to get continuous + df[col_name] = df[col_name].ffill() + return df