Use timeframe_to_prev_date to move trade-date to candle
This commit is contained in:
parent
45fb4d25ab
commit
4e907e2304
@ -10,6 +10,7 @@ from freqtrade.data.btanalysis import (calculate_max_drawdown,
|
|||||||
create_cum_profit,
|
create_cum_profit,
|
||||||
extract_trades_of_period, load_trades)
|
extract_trades_of_period, load_trades)
|
||||||
from freqtrade.data.converter import trim_dataframe
|
from freqtrade.data.converter import trim_dataframe
|
||||||
|
from freqtrade.exchange import timeframe_to_prev_date
|
||||||
from freqtrade.data.history import load_data
|
from freqtrade.data.history import load_data
|
||||||
from freqtrade.misc import pair_to_filename
|
from freqtrade.misc import pair_to_filename
|
||||||
from freqtrade.resolvers import StrategyResolver
|
from freqtrade.resolvers import StrategyResolver
|
||||||
@ -122,7 +123,8 @@ def add_profit(fig, row, data: pd.DataFrame, column: str, name: str) -> make_sub
|
|||||||
return fig
|
return fig
|
||||||
|
|
||||||
|
|
||||||
def add_max_drawdown(fig, row, trades: pd.DataFrame, df_comb: pd.DataFrame) -> make_subplots:
|
def add_max_drawdown(fig, row, trades: pd.DataFrame, df_comb: pd.DataFrame,
|
||||||
|
timeframe: str) -> make_subplots:
|
||||||
"""
|
"""
|
||||||
Add scatter points indicating max drawdown
|
Add scatter points indicating max drawdown
|
||||||
"""
|
"""
|
||||||
@ -132,8 +134,8 @@ def add_max_drawdown(fig, row, trades: pd.DataFrame, df_comb: pd.DataFrame) -> m
|
|||||||
drawdown = go.Scatter(
|
drawdown = go.Scatter(
|
||||||
x=[highdate, lowdate],
|
x=[highdate, lowdate],
|
||||||
y=[
|
y=[
|
||||||
df_comb.loc[df_comb.index == highdate, 'cum_profit'],
|
df_comb.loc[timeframe_to_prev_date(timeframe, highdate), 'cum_profit'],
|
||||||
df_comb.loc[df_comb.index == lowdate, 'cum_profit'],
|
df_comb.loc[timeframe_to_prev_date(timeframe, lowdate), 'cum_profit'],
|
||||||
],
|
],
|
||||||
mode='markers',
|
mode='markers',
|
||||||
name=f"Max drawdown {max_drawdown:.2f}%",
|
name=f"Max drawdown {max_drawdown:.2f}%",
|
||||||
@ -405,7 +407,7 @@ def generate_profit_graph(pairs: str, data: Dict[str, pd.DataFrame],
|
|||||||
|
|
||||||
fig.add_trace(avgclose, 1, 1)
|
fig.add_trace(avgclose, 1, 1)
|
||||||
fig = add_profit(fig, 2, df_comb, 'cum_profit', 'Profit')
|
fig = add_profit(fig, 2, df_comb, 'cum_profit', 'Profit')
|
||||||
fig = add_max_drawdown(fig, 2, trades, df_comb)
|
fig = add_max_drawdown(fig, 2, trades, df_comb, timeframe)
|
||||||
|
|
||||||
for pair in pairs:
|
for pair in pairs:
|
||||||
profit_col = f'cum_profit_{pair}'
|
profit_col = f'cum_profit_{pair}'
|
||||||
|
Loading…
Reference in New Issue
Block a user