# vectorbt **Repository Path**: timcn/vectorbt ## Basic Information - **Project Name**: vectorbt - **Description**: Ultimate Python library for time series analysis and backtesting at speed and scale - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2021-08-20 - **Last Updated**: 2024-06-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README
Digging into each strategy configuration is as simple as indexing with pandas:
```python
pf[(10, 20, 'ETH-USD')].stats()
```
```plaintext
Start 2015-08-07 00:00:00+00:00
End 2021-08-01 00:00:00+00:00
Period 2183 days 00:00:00
Start Value 100.0
End Value 620402.791485
Total Return [%] 620302.791485
Benchmark Return [%] 92987.961948
Max Gross Exposure [%] 100.0
Total Fees Paid 10991.676981
Max Drawdown [%] 70.734951
Max Drawdown Duration 760 days 00:00:00
Total Trades 54
Total Closed Trades 53
Total Open Trades 1
Open Trade PnL 67287.940601
Win Rate [%] 52.830189
Best Trade [%] 1075.803607
Worst Trade [%] -29.593414
Avg Winning Trade [%] 95.695343
Avg Losing Trade [%] -11.890246
Avg Winning Trade Duration 35 days 23:08:34.285714286
Avg Losing Trade Duration 8 days 00:00:00
Profit Factor 2.651143
Expectancy 10434.24247
Sharpe Ratio 2.041211
Calmar Ratio 4.6747
Omega Ratio 1.547013
Sortino Ratio 3.519894
Name: (10, 20, ETH-USD), dtype: object
```
The same for plotting:
```python
pf[(10, 20, 'ETH-USD')].plot().show()
```

It's not all about backtesting - vectorbt can be used to facilitate financial data analysis and visualization.
* Let's generate a GIF that animates the %B and bandwidth of Bollinger Bands for different symbols:
```python
symbols = ["BTC-USD", "ETH-USD", "ADA-USD"]
price = vbt.YFData.download(symbols, period='6mo', missing_index='drop').get('Close')
bbands = vbt.BBANDS.run(price)
def plot(index, bbands):
bbands = bbands.loc[index]
fig = vbt.make_subplots(
rows=2, cols=1, shared_xaxes=True, vertical_spacing=0.15,
subplot_titles=('%B', 'Bandwidth'))
fig.update_layout(template='vbt_dark', showlegend=False, width=750, height=400)
bbands.percent_b.vbt.ts_heatmap(
trace_kwargs=dict(zmin=0, zmid=0.5, zmax=1, colorscale='Spectral', colorbar=dict(
y=(fig.layout.yaxis.domain[0] + fig.layout.yaxis.domain[1]) / 2, len=0.5
)), add_trace_kwargs=dict(row=1, col=1), fig=fig)
bbands.bandwidth.vbt.ts_heatmap(
trace_kwargs=dict(colorbar=dict(
y=(fig.layout.yaxis2.domain[0] + fig.layout.yaxis2.domain[1]) / 2, len=0.5
)), add_trace_kwargs=dict(row=2, col=1), fig=fig)
return fig
vbt.save_animation('bbands.gif', bbands.wrapper.index, plot, bbands, delta=90, step=3, fps=3)
```
```plaintext
100%|██████████| 31/31 [00:21<00:00, 1.21it/s]
```
And this is just the tip of the iceberg of what's possible. Check out the [website](https://vectorbt.dev/) to learn more.
## Installation
```sh
pip install -U vectorbt
```
To also install optional dependencies:
```sh
pip install -U "vectorbt[full]"
```
## Important note
All the active development has moved to **[vectorbt PRO](https://vectorbt.pro/)**.
This project is being maintained only. PRs are welcome.
## License
This work is [fair-code](http://faircode.io/) distributed under [Apache 2.0 with Commons Clause](https://github.com/polakowo/vectorbt/blob/master/LICENSE.md) license.
The source code is open and everyone (individuals and organizations) can use it for free.
However, it is not allowed to sell products and services that are mostly just this software.
If you have any questions about this or want to apply for a license exception, please [contact the author](mailto:olegpolakow@gmail.com).
Installing optional dependencies may be subject to a more restrictive license.
## Disclaimer
This software is for educational purposes only. Do not risk money which you are afraid to lose.
USE THE SOFTWARE AT YOUR OWN RISK. THE AUTHORS AND ALL AFFILIATES ASSUME NO RESPONSIBILITY FOR YOUR TRADING RESULTS.