Skip to content

Commit

Permalink
Merge pull request freqtrade#9160 from mohsenjfar/develop
Browse files Browse the repository at this point in the history
Update strategy_analysis_example.md
  • Loading branch information
xmatthias authored Sep 8, 2023
2 parents cb5cd5c + f13e134 commit 376b5fc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 31 deletions.
18 changes: 3 additions & 15 deletions docs/strategy_analysis_example.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ trades.groupby("pair")["exit_reason"].value_counts()
# Plotting equity line (starting with 0 on day 1 and adding daily profit for each backtested day)

from freqtrade.configuration import Configuration
from freqtrade.data.btanalysis import load_backtest_data, load_backtest_stats
from freqtrade.data.btanalysis import load_backtest_stats
import plotly.express as px
import pandas as pd

Expand All @@ -178,20 +178,8 @@ import pandas as pd
stats = load_backtest_stats(backtest_dir)
strategy_stats = stats['strategy'][strategy]

dates = []
profits = []
for date_profit in strategy_stats['daily_profit']:
dates.append(date_profit[0])
profits.append(date_profit[1])

equity = 0
equity_daily = []
for daily_profit in profits:
equity_daily.append(equity)
equity += float(daily_profit)


df = pd.DataFrame({'dates': dates,'equity_daily': equity_daily})
df = pd.DataFrame(columns=['dates','equity'], data=strategy_stats['daily_profit'])
df['equity_daily'] = df['equity'].cumsum()

fig = px.line(df, x="dates", y="equity_daily")
fig.show()
Expand Down
20 changes: 4 additions & 16 deletions freqtrade/templates/strategy_analysis_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@
"# Plotting equity line (starting with 0 on day 1 and adding daily profit for each backtested day)\n",
"\n",
"from freqtrade.configuration import Configuration\n",
"from freqtrade.data.btanalysis import load_backtest_data, load_backtest_stats\n",
"from freqtrade.data.btanalysis import load_backtest_stats\n",
"import plotly.express as px\n",
"import pandas as pd\n",
"\n",
Expand All @@ -254,20 +254,8 @@
"stats = load_backtest_stats(backtest_dir)\n",
"strategy_stats = stats['strategy'][strategy]\n",
"\n",
"dates = []\n",
"profits = []\n",
"for date_profit in strategy_stats['daily_profit']:\n",
" dates.append(date_profit[0])\n",
" profits.append(date_profit[1])\n",
"\n",
"equity = 0\n",
"equity_daily = []\n",
"for daily_profit in profits:\n",
" equity_daily.append(equity)\n",
" equity += float(daily_profit)\n",
"\n",
"\n",
"df = pd.DataFrame({'dates': dates,'equity_daily': equity_daily})\n",
"df = pd.DataFrame(columns=['dates','equity'], data=strategy_stats['daily_profit'])\n",
"df['equity_daily'] = df['equity'].cumsum()\n",
"\n",
"fig = px.line(df, x=\"dates\", y=\"equity_daily\")\n",
"fig.show()\n"
Expand Down Expand Up @@ -414,7 +402,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.11.4"
},
"mimetype": "text/x-python",
"name": "python",
Expand Down

0 comments on commit 376b5fc

Please sign in to comment.