Skip to content

Commit

Permalink
Add documentation sample for parallel_trade_analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
xmatthias committed Oct 30, 2019
1 parent dd408aa commit 6928c68
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
16 changes: 16 additions & 0 deletions docs/strategy_analysis_example.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,22 @@ trades = load_trades_from_db("sqlite:///tradesv3.sqlite")
trades.groupby("pair")["sell_reason"].value_counts()
```

## Analyze the loaded trades for trade parallelism
This can be useful to find the best `max_open_trades` parameter, when used with backtesting in conjunction with `--disable-max-market-positions`.

`parallel_trade_analysis()` returns a timeseries dataframe with an "open_trades" column, specifying the number of open trades for each candle.


```python
from freqtrade.data.btanalysis import parallel_trade_analysis

# Analyze the above
parallel_trades = parallel_trade_analysis(trades, '5m')


parallel_trades.plot()
```

## Plot results

Freqtrade offers interactive plotting capabilities based on plotly.
Expand Down
29 changes: 26 additions & 3 deletions user_data/notebooks/strategy_analysis_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": true
},
"metadata": {},
"outputs": [],
"source": [
"# Load strategy using values set above\n",
Expand Down Expand Up @@ -169,6 +167,31 @@
"trades.groupby(\"pair\")[\"sell_reason\"].value_counts()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Analyze the loaded trades for trade parallelism\n",
"This can be useful to find the best `max_open_trades` parameter, when used with backtesting in conjunction with `--disable-max-market-positions`.\n",
"\n",
"`parallel_trade_analysis()` returns a timeseries dataframe with an \"open_trades\" column, specifying the number of open trades for each candle."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from freqtrade.data.btanalysis import parallel_trade_analysis\n",
"\n",
"# Analyze the above\n",
"parallel_trades = parallel_trade_analysis(trades, '5m')\n",
"\n",
"\n",
"parallel_trades.plot()"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down

0 comments on commit 6928c68

Please sign in to comment.