vectorbt 0.28.2__tar.gz → 0.28.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. {vectorbt-0.28.2 → vectorbt-0.28.5}/LICENSE.md +1 -1
  2. vectorbt-0.28.5/MANIFEST.in +1 -0
  3. vectorbt-0.28.5/PKG-INFO +343 -0
  4. vectorbt-0.28.5/README.md +272 -0
  5. vectorbt-0.28.5/pyproject.toml +96 -0
  6. vectorbt-0.28.5/setup.py +9 -0
  7. {vectorbt-0.28.2 → vectorbt-0.28.5}/tests/test_generic.py +9 -16
  8. {vectorbt-0.28.2 → vectorbt-0.28.5}/tests/test_indicators.py +16 -2
  9. vectorbt-0.28.5/tests/test_plotting.py +1275 -0
  10. {vectorbt-0.28.2 → vectorbt-0.28.5}/tests/test_portfolio.py +17 -17
  11. {vectorbt-0.28.2 → vectorbt-0.28.5}/tests/test_records.py +0 -14
  12. {vectorbt-0.28.2 → vectorbt-0.28.5}/tests/test_utils.py +20 -1
  13. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/_version.py +1 -1
  14. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/base/array_wrapper.py +2 -2
  15. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/base/indexing.py +19 -5
  16. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/generic/accessors.py +5 -10
  17. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/portfolio/base.py +14 -3
  18. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/records/base.py +1 -1
  19. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/records/mapped_array.py +5 -10
  20. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/utils/checks.py +71 -0
  21. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/utils/datetime_.py +1 -2
  22. vectorbt-0.28.5/vectorbt.egg-info/PKG-INFO +343 -0
  23. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt.egg-info/SOURCES.txt +2 -3
  24. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt.egg-info/requires.txt +11 -14
  25. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt.egg-info/top_level.txt +0 -1
  26. vectorbt-0.28.2/MANIFEST.in +0 -1
  27. vectorbt-0.28.2/PKG-INFO +0 -316
  28. vectorbt-0.28.2/README.md +0 -232
  29. vectorbt-0.28.2/setup.py +0 -94
  30. vectorbt-0.28.2/tests/__init__.py +0 -0
  31. vectorbt-0.28.2/tests/utils.py +0 -21
  32. vectorbt-0.28.2/vectorbt/templates/.ipynb_checkpoints/dark-checkpoint.json +0 -813
  33. vectorbt-0.28.2/vectorbt.egg-info/PKG-INFO +0 -316
  34. {vectorbt-0.28.2 → vectorbt-0.28.5}/setup.cfg +0 -0
  35. {vectorbt-0.28.2 → vectorbt-0.28.5}/tests/test_base.py +0 -0
  36. {vectorbt-0.28.2 → vectorbt-0.28.5}/tests/test_data.py +0 -0
  37. {vectorbt-0.28.2 → vectorbt-0.28.5}/tests/test_labels.py +0 -0
  38. {vectorbt-0.28.2 → vectorbt-0.28.5}/tests/test_returns.py +0 -0
  39. {vectorbt-0.28.2 → vectorbt-0.28.5}/tests/test_settings.py +0 -0
  40. {vectorbt-0.28.2 → vectorbt-0.28.5}/tests/test_signals.py +0 -0
  41. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/__init__.py +0 -0
  42. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/_settings.py +0 -0
  43. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/_typing.py +0 -0
  44. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/base/__init__.py +0 -0
  45. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/base/accessors.py +0 -0
  46. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/base/column_grouper.py +0 -0
  47. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/base/combine_fns.py +0 -0
  48. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/base/index_fns.py +0 -0
  49. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/base/reshape_fns.py +0 -0
  50. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/data/__init__.py +0 -0
  51. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/data/base.py +0 -0
  52. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/data/custom.py +0 -0
  53. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/data/updater.py +0 -0
  54. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/generic/__init__.py +0 -0
  55. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/generic/decorators.py +0 -0
  56. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/generic/drawdowns.py +0 -0
  57. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/generic/enums.py +0 -0
  58. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/generic/nb.py +0 -0
  59. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/generic/plots_builder.py +0 -0
  60. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/generic/plotting.py +0 -0
  61. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/generic/ranges.py +0 -0
  62. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/generic/splitters.py +0 -0
  63. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/generic/stats_builder.py +0 -0
  64. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/indicators/__init__.py +0 -0
  65. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/indicators/basic.py +0 -0
  66. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/indicators/configs.py +0 -0
  67. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/indicators/factory.py +0 -0
  68. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/indicators/nb.py +0 -0
  69. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/labels/__init__.py +0 -0
  70. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/labels/enums.py +0 -0
  71. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/labels/generators.py +0 -0
  72. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/labels/nb.py +0 -0
  73. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/messaging/__init__.py +0 -0
  74. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/messaging/telegram.py +0 -0
  75. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/ohlcv_accessors.py +0 -0
  76. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/portfolio/__init__.py +0 -0
  77. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/portfolio/decorators.py +0 -0
  78. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/portfolio/enums.py +0 -0
  79. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/portfolio/logs.py +0 -0
  80. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/portfolio/nb.py +0 -0
  81. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/portfolio/orders.py +0 -0
  82. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/portfolio/trades.py +0 -0
  83. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/px_accessors.py +0 -0
  84. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/records/__init__.py +0 -0
  85. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/records/col_mapper.py +0 -0
  86. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/records/decorators.py +0 -0
  87. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/records/nb.py +0 -0
  88. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/returns/__init__.py +0 -0
  89. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/returns/accessors.py +0 -0
  90. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/returns/metrics.py +0 -0
  91. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/returns/nb.py +0 -0
  92. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/returns/qs_adapter.py +0 -0
  93. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/root_accessors.py +0 -0
  94. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/signals/__init__.py +0 -0
  95. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/signals/accessors.py +0 -0
  96. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/signals/enums.py +0 -0
  97. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/signals/factory.py +0 -0
  98. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/signals/generators.py +0 -0
  99. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/signals/nb.py +0 -0
  100. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/templates/dark.json +0 -0
  101. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/templates/light.json +0 -0
  102. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/templates/seaborn.json +0 -0
  103. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/utils/__init__.py +0 -0
  104. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/utils/array_.py +0 -0
  105. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/utils/attr_.py +0 -0
  106. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/utils/colors.py +0 -0
  107. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/utils/config.py +0 -0
  108. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/utils/decorators.py +0 -0
  109. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/utils/docs.py +0 -0
  110. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/utils/enum_.py +0 -0
  111. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/utils/figure.py +0 -0
  112. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/utils/image_.py +0 -0
  113. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/utils/mapping.py +0 -0
  114. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/utils/math_.py +0 -0
  115. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/utils/module_.py +0 -0
  116. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/utils/params.py +0 -0
  117. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/utils/random_.py +0 -0
  118. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/utils/requests_.py +0 -0
  119. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/utils/schedule_.py +0 -0
  120. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/utils/tags.py +0 -0
  121. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt/utils/template.py +0 -0
  122. {vectorbt-0.28.2 → vectorbt-0.28.5}/vectorbt.egg-info/dependency_links.txt +0 -0
@@ -200,7 +200,7 @@ Licensor: Oleg Polakow
200
200
  same "printed page" as the copyright notice for easier
201
201
  identification within third-party archives.
202
202
 
203
- Copyright 2025 Oleg Polakow
203
+ Copyright 2026 Oleg Polakow
204
204
 
205
205
  Licensed under the Apache License, Version 2.0 (the "License");
206
206
  you may not use this file except in compliance with the License.
@@ -0,0 +1 @@
1
+ prune docs
@@ -0,0 +1,343 @@
1
+ Metadata-Version: 2.4
2
+ Name: vectorbt
3
+ Version: 0.28.5
4
+ Summary: Python library for backtesting and analyzing trading strategies at scale
5
+ Author-email: Oleg Polakow <olegpolakow@vectorbt.pro>
6
+ Project-URL: Homepage, https://github.com/polakowo/vectorbt
7
+ Classifier: Development Status :: 5 - Production/Stable
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: Intended Audience :: Financial and Insurance Industry
10
+ Classifier: Programming Language :: Python :: 3.10
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: Topic :: Software Development
17
+ Classifier: Topic :: Office/Business :: Financial
18
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE.md
22
+ Requires-Dist: numpy>=1.23
23
+ Requires-Dist: pandas<3.0,>=2.0
24
+ Requires-Dist: scipy
25
+ Requires-Dist: matplotlib
26
+ Requires-Dist: plotly>=4.12.0
27
+ Requires-Dist: ipywidgets>=7.0.0
28
+ Requires-Dist: anywidget
29
+ Requires-Dist: numba>=0.60
30
+ Requires-Dist: dill
31
+ Requires-Dist: tqdm
32
+ Requires-Dist: dateparser
33
+ Requires-Dist: imageio
34
+ Requires-Dist: scikit-learn
35
+ Requires-Dist: schedule
36
+ Requires-Dist: requests
37
+ Requires-Dist: pytz
38
+ Requires-Dist: mypy_extensions
39
+ Provides-Extra: full
40
+ Requires-Dist: yfinance>=0.2.22; extra == "full"
41
+ Requires-Dist: python-binance; extra == "full"
42
+ Requires-Dist: ccxt>=4.0.14; extra == "full"
43
+ Requires-Dist: alpaca-py; extra == "full"
44
+ Requires-Dist: ray>=1.4.1; extra == "full"
45
+ Requires-Dist: ta; extra == "full"
46
+ Requires-Dist: pandas-ta-classic; extra == "full"
47
+ Requires-Dist: TA-Lib; extra == "full"
48
+ Requires-Dist: python-telegram-bot<20.0,>=13.4; extra == "full"
49
+ Requires-Dist: quantstats>=0.0.37; extra == "full"
50
+ Provides-Extra: full-no-talib
51
+ Requires-Dist: yfinance>=0.2.22; extra == "full-no-talib"
52
+ Requires-Dist: python-binance; extra == "full-no-talib"
53
+ Requires-Dist: ccxt>=4.0.14; extra == "full-no-talib"
54
+ Requires-Dist: alpaca-py; extra == "full-no-talib"
55
+ Requires-Dist: ray>=1.4.1; extra == "full-no-talib"
56
+ Requires-Dist: ta; extra == "full-no-talib"
57
+ Requires-Dist: pandas-ta-classic; extra == "full-no-talib"
58
+ Requires-Dist: python-telegram-bot<20.0,>=13.4; extra == "full-no-talib"
59
+ Requires-Dist: quantstats>=0.0.37; extra == "full-no-talib"
60
+ Provides-Extra: cov
61
+ Requires-Dist: pytest; extra == "cov"
62
+ Requires-Dist: pytest-cov; extra == "cov"
63
+ Requires-Dist: pytest-xdist; extra == "cov"
64
+ Requires-Dist: codecov; extra == "cov"
65
+ Provides-Extra: docs
66
+ Requires-Dist: mkdocs-material; extra == "docs"
67
+ Requires-Dist: mkdocs-minify-plugin; extra == "docs"
68
+ Requires-Dist: ruamel.yaml; extra == "docs"
69
+ Requires-Dist: mako; extra == "docs"
70
+ Dynamic: license-file
71
+
72
+ <div align="center">
73
+ <a href="https://vectorbt.pro/" title="VectorBT PRO">
74
+ <img src="https://raw.githubusercontent.com/polakowo/vectorbt/master/docs/docs/assets/logo/header-pro.svg" />
75
+ </a>
76
+ </div>
77
+ <div align="center">
78
+ <a href="https://vectorbt.dev/" title="vectorbt">
79
+ <img src="https://raw.githubusercontent.com/polakowo/vectorbt/master/docs/docs/assets/logo/header.svg" />
80
+ </a>
81
+ </div>
82
+
83
+ <br>
84
+
85
+ <p align="center">
86
+ <a href="https://pepy.tech/project/vectorbt" title="Downloads">
87
+ <img src="https://pepy.tech/badge/vectorbt" />
88
+ </a>
89
+ <a href="https://github.com/polakowo/vectorbt/stargazers" title="Stars">
90
+ <img src="https://img.shields.io/github/stars/polakowo/vectorbt?style=flat" />
91
+ </a>
92
+ <a href="https://github.com/polakowo/vectorbt/network/members" title="Forks">
93
+ <img src="https://img.shields.io/github/forks/polakowo/vectorbt?style=flat" />
94
+ </a>
95
+ <a href="https://github.com/polakowo/vectorbt/graphs/contributors" title="Contributors">
96
+ <img src="https://img.shields.io/github/contributors/polakowo/vectorbt?style=flat" />
97
+ </a>
98
+ <a href="https://pypi.org/project/vectorbt" title="PyPI">
99
+ <img src="https://img.shields.io/pypi/v/vectorbt?color=blueviolet" />
100
+ </a>
101
+ <a href="https://github.com/polakowo/vectorbt/blob/master/LICENSE.md" title="License">
102
+ <img src="https://img.shields.io/badge/license-Fair%20Code-yellow" />
103
+ </a>
104
+ <a href="https://codecov.io/gh/polakowo/vectorbt" title="codecov">
105
+ <img src="https://codecov.io/gh/polakowo/vectorbt/branch/master/graph/badge.svg?token=YTLNAI7PS3" />
106
+ </a>
107
+ <a href="https://vectorbt.dev/" title="Website">
108
+ <img src="https://img.shields.io/website?url=https://vectorbt.dev/" />
109
+ </a>
110
+ <a href="https://mybinder.org/v2/gh/polakowo/vectorbt/HEAD?urlpath=lab" title="Launch Binder">
111
+ <img src="https://img.shields.io/badge/launch-binder-d6604a" />
112
+ </a>
113
+ <a href="https://gitter.im/vectorbt/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge" title="Join the chat">
114
+ <img src="https://badges.gitter.im/vectorbt.svg" />
115
+ </a>
116
+ <a href="https://pypi.org/project/vectorbt" title="Supported Python versions">
117
+ <img src="https://img.shields.io/pypi/pyversions/vectorbt.svg?logo=python&logoColor=white" />
118
+ </a>
119
+ </p>
120
+
121
+ Test thousands of trading ideas in seconds, analyze portfolios across markets and timeframes, and uncover what works with minimal code. Built for both human researchers and AI agents, VectorBT combines rapid experimentation with a mature, battle-tested backtesting stack shaped by years of community use.
122
+
123
+ VectorBT is the open-source, community edition of [VectorBT PRO](https://vectorbt.pro/), a state-of-the-art hybrid backtesting library.
124
+
125
+ ## Features
126
+
127
+ - Fast, vectorized backtesting and strategy research on pandas/NumPy, accelerated with Numba
128
+ - Pandas-native API with custom accessors and high-performance operations
129
+ - Flexible broadcasting for multi-asset analysis and large parameter sweeps
130
+ - Rich indicator ecosystem with support for custom indicators and popular TA libraries (TA-Lib, Pandas TA, etc.)
131
+ - Portfolio backtesting with trades, positions, drawdowns, and performance analysis (incl. QuantStats)
132
+ - Signal-based tooling for generation, ranking, mapping, and distribution analysis
133
+ - Built-in data access (Yahoo Finance, CCXT, Alpaca, etc.), preprocessing, and random data generation
134
+ - Robustness testing, walk-forward optimization, and label generation for ML workflows
135
+ - Interactive visualization with Plotly, Jupyter widgets, and browser-friendly dashboards
136
+ - Automation support for scheduled updates and Telegram notifications
137
+ - Composable Python API suitable for rapid experimentation and AI agent-driven workflows
138
+
139
+ ## Installation
140
+
141
+ ```sh
142
+ pip install -U vectorbt
143
+ ```
144
+
145
+ To install optional dependencies as well:
146
+
147
+ ```sh
148
+ pip install -U "vectorbt[full]"
149
+ ```
150
+
151
+ ## Usage
152
+
153
+ VectorBT lets you backtest strategies in just a few lines of Python.
154
+
155
+ * Profit from investing $100 in Bitcoin since 2014:
156
+
157
+ ```python
158
+ import vectorbt as vbt
159
+
160
+ data = vbt.YFData.download("BTC-USD")
161
+ price = data.get("Close")
162
+
163
+ pf = vbt.Portfolio.from_holding(price, init_cash=100)
164
+ print(pf.total_profit())
165
+ ```
166
+
167
+ ```plaintext
168
+ 19501.10906763755
169
+ ```
170
+
171
+ * Buy when the 10-day SMA crosses above the 50-day SMA, and sell on the opposite crossover:
172
+
173
+ ```python
174
+ fast_ma = vbt.MA.run(price, 10)
175
+ slow_ma = vbt.MA.run(price, 50)
176
+ entries = fast_ma.ma_crossed_above(slow_ma)
177
+ exits = fast_ma.ma_crossed_below(slow_ma)
178
+
179
+ pf = vbt.Portfolio.from_signals(price, entries, exits, init_cash=100)
180
+ print(pf.total_profit())
181
+ ```
182
+
183
+ ```plaintext
184
+ 34417.80960086067
185
+ ```
186
+
187
+ * Generate 1,000 strategies with random signals and test them on BTC and ETH:
188
+
189
+ ```python
190
+ import numpy as np
191
+
192
+ symbols = ["BTC-USD", "ETH-USD"]
193
+ data = vbt.YFData.download(symbols, missing_index="drop")
194
+ price = data.get("Close")
195
+
196
+ n = np.random.randint(10, 101, size=1000).tolist()
197
+ pf = vbt.Portfolio.from_random_signals(price, n=n, init_cash=100, seed=42)
198
+
199
+ mean_expectancy = pf.trades.expectancy().groupby(["randnx_n", "symbol"]).mean()
200
+ fig = mean_expectancy.unstack().vbt.scatterplot(xaxis_title="randnx_n", yaxis_title="mean_expectancy")
201
+ fig.show()
202
+ ```
203
+
204
+ ![](https://raw.githubusercontent.com/polakowo/vectorbt/master/docs/docs/assets/images/usage_rand_scatter.svg)
205
+
206
+ * For hyperparameter optimization fans: test 10,000 window combinations of a dual-SMA crossover strategy on BTC, ETH, and XRP:
207
+
208
+ ```python
209
+ symbols = ["BTC-USD", "ETH-USD", "XRP-USD"]
210
+ data = vbt.YFData.download(symbols, missing_index="drop")
211
+ price = data.get("Close")
212
+
213
+ windows = np.arange(2, 101)
214
+ fast_ma, slow_ma = vbt.MA.run_combs(price, window=windows, r=2, short_names=["fast", "slow"])
215
+ entries = fast_ma.ma_crossed_above(slow_ma)
216
+ exits = fast_ma.ma_crossed_below(slow_ma)
217
+
218
+ pf = vbt.Portfolio.from_signals(price, entries, exits, size=np.inf, fees=0.001, freq="1D")
219
+
220
+ fig = pf.total_return().vbt.heatmap(
221
+ x_level="fast_window", y_level="slow_window", slider_level="symbol", symmetric=True,
222
+ trace_kwargs=dict(colorbar=dict(title="Total return", tickformat="%")))
223
+ fig.show()
224
+ ```
225
+
226
+ <img width="750" src="https://raw.githubusercontent.com/polakowo/vectorbt/master/docs/docs/assets/images/usage_dmac_heatmap.gif">
227
+
228
+ Inspect any strategy configuration by indexing with pandas:
229
+
230
+ ```python
231
+ print(pf[(10, 20, "ETH-USD")].stats())
232
+ ```
233
+
234
+ ```plaintext
235
+ Start 2017-11-09 00:00:00+00:00
236
+ End 2026-01-03 00:00:00+00:00
237
+ Period 2978 days 00:00:00
238
+ Start Value 100.0
239
+ End Value 1604.093789
240
+ Total Return [%] 1504.093789
241
+ Benchmark Return [%] 866.094127
242
+ Max Gross Exposure [%] 100.0
243
+ Total Fees Paid 204.226289
244
+ Max Drawdown [%] 70.734951
245
+ Max Drawdown Duration 1095 days 00:00:00
246
+ Total Trades 81
247
+ Total Closed Trades 80
248
+ Total Open Trades 1
249
+ Open Trade PnL -14.232533
250
+ Win Rate [%] 41.25
251
+ Best Trade [%] 120.511071
252
+ Worst Trade [%] -27.772271
253
+ Avg Winning Trade [%] 27.265519
254
+ Avg Losing Trade [%] -9.022864
255
+ Avg Winning Trade Duration 32 days 20:21:49.090909091
256
+ Avg Losing Trade Duration 8 days 16:51:03.829787234
257
+ Profit Factor 1.275515
258
+ Expectancy 18.979079
259
+ Sharpe Ratio 0.861945
260
+ Calmar Ratio 0.572758
261
+ Omega Ratio 1.20277
262
+ Sortino Ratio 1.301377
263
+ Name: (10, 20, ETH-USD), dtype: object
264
+ ```
265
+
266
+ Same goes for plotting:
267
+
268
+ ```python
269
+ pf[(10, 20, "ETH-USD")].plot().show()
270
+ ```
271
+
272
+ ![](https://raw.githubusercontent.com/polakowo/vectorbt/master/docs/docs/assets/images/usage_dmac_portfolio.svg)
273
+
274
+ It's not all about backtesting! VectorBT can also help with financial data analysis and visualization.
275
+
276
+ * Create a GIF that animates Bollinger Bands %B and bandwidth across multiple symbols:
277
+
278
+ ```python
279
+ symbols = ["BTC-USD", "ETH-USD", "XRP-USD"]
280
+ data = vbt.YFData.download(symbols, period="6mo", missing_index="drop")
281
+ price = data.get("Close")
282
+ bbands = vbt.BBANDS.run(price)
283
+
284
+ def plot(index, bbands):
285
+ bbands = bbands.loc[index]
286
+ fig = vbt.make_subplots(
287
+ rows=2, cols=1, shared_xaxes=True, vertical_spacing=0.15,
288
+ subplot_titles=("%B", "Bandwidth"))
289
+ fig.update_layout(showlegend=False, width=750, height=400)
290
+ bbands.percent_b.vbt.ts_heatmap(
291
+ trace_kwargs=dict(zmin=0, zmid=0.5, zmax=1, colorscale="Spectral", colorbar=dict(
292
+ y=(fig.layout.yaxis.domain[0] + fig.layout.yaxis.domain[1]) / 2, len=0.5
293
+ )), add_trace_kwargs=dict(row=1, col=1), fig=fig)
294
+ bbands.bandwidth.vbt.ts_heatmap(
295
+ trace_kwargs=dict(colorbar=dict(
296
+ y=(fig.layout.yaxis2.domain[0] + fig.layout.yaxis2.domain[1]) / 2, len=0.5
297
+ )), add_trace_kwargs=dict(row=2, col=1), fig=fig)
298
+ return fig
299
+
300
+ vbt.save_animation("bbands.gif", bbands.wrapper.index, plot, bbands, delta=90, step=3, fps=3)
301
+ ```
302
+
303
+ ```plaintext
304
+ 100%|██████████| 31/31 [00:21<00:00, 1.21it/s]
305
+ ```
306
+
307
+ <img width="750" src="https://raw.githubusercontent.com/polakowo/vectorbt/master/docs/docs/assets/images/usage_bbands.gif">
308
+
309
+ This is just the tip of the iceberg. Visit the [website](https://vectorbt.dev/) to learn more.
310
+
311
+ ## Apps
312
+
313
+ ### Candlestick Patterns ([here](https://github.com/polakowo/vectorbt/blob/master/apps/candlestick-patterns/))
314
+
315
+ Explore candlestick-pattern signals interactively and backtest them with VectorBT.
316
+
317
+ [![teaser.png](https://raw.githubusercontent.com/polakowo/vectorbt/master/apps/candlestick-patterns/assets/teaser.png)](https://github.com/polakowo/vectorbt/blob/master/apps/candlestick-patterns/)
318
+
319
+ ## Links
320
+
321
+ * [Website](https://vectorbt.dev/)
322
+ * [Docker images](https://hub.docker.com/r/polakowo/vectorbt)
323
+ * [Colab notebook](https://colab.research.google.com/drive/1ibqyrf6LPFlzRb6mkPpl3hxqL6ryNBXI?usp=sharing)
324
+
325
+ ## License
326
+
327
+ This work is [fair-code](http://faircode.io/) distributed under the [Apache 2.0 with Commons Clause](https://github.com/polakowo/vectorbt/blob/master/LICENSE.md) license.
328
+
329
+ The source code is open, and everyone (individuals and organizations) may use it for free. However, you may not sell products or services that are primarily this software.
330
+
331
+ If you have questions or want to request a license exception, please [contact the author](mailto:olegpolakow@vectorbt.pro).
332
+
333
+ Installing optional dependencies may be subject to a more restrictive license.
334
+
335
+ ## Star history
336
+
337
+ [![Star History Chart](https://api.star-history.com/svg?repos=polakowo/vectorbt&type=Timeline)](https://star-history.com/#polakowo/vectorbt&Timeline)
338
+
339
+ ## Disclaimer
340
+
341
+ This software is for educational purposes only. Do not risk money you cannot afford to lose.
342
+
343
+ USE THE SOFTWARE AT YOUR OWN RISK. THE AUTHORS AND ALL AFFILIATES ASSUME NO RESPONSIBILITY FOR YOUR TRADING RESULTS.
@@ -0,0 +1,272 @@
1
+ <div align="center">
2
+ <a href="https://vectorbt.pro/" title="VectorBT PRO">
3
+ <img src="https://raw.githubusercontent.com/polakowo/vectorbt/master/docs/docs/assets/logo/header-pro.svg" />
4
+ </a>
5
+ </div>
6
+ <div align="center">
7
+ <a href="https://vectorbt.dev/" title="vectorbt">
8
+ <img src="https://raw.githubusercontent.com/polakowo/vectorbt/master/docs/docs/assets/logo/header.svg" />
9
+ </a>
10
+ </div>
11
+
12
+ <br>
13
+
14
+ <p align="center">
15
+ <a href="https://pepy.tech/project/vectorbt" title="Downloads">
16
+ <img src="https://pepy.tech/badge/vectorbt" />
17
+ </a>
18
+ <a href="https://github.com/polakowo/vectorbt/stargazers" title="Stars">
19
+ <img src="https://img.shields.io/github/stars/polakowo/vectorbt?style=flat" />
20
+ </a>
21
+ <a href="https://github.com/polakowo/vectorbt/network/members" title="Forks">
22
+ <img src="https://img.shields.io/github/forks/polakowo/vectorbt?style=flat" />
23
+ </a>
24
+ <a href="https://github.com/polakowo/vectorbt/graphs/contributors" title="Contributors">
25
+ <img src="https://img.shields.io/github/contributors/polakowo/vectorbt?style=flat" />
26
+ </a>
27
+ <a href="https://pypi.org/project/vectorbt" title="PyPI">
28
+ <img src="https://img.shields.io/pypi/v/vectorbt?color=blueviolet" />
29
+ </a>
30
+ <a href="https://github.com/polakowo/vectorbt/blob/master/LICENSE.md" title="License">
31
+ <img src="https://img.shields.io/badge/license-Fair%20Code-yellow" />
32
+ </a>
33
+ <a href="https://codecov.io/gh/polakowo/vectorbt" title="codecov">
34
+ <img src="https://codecov.io/gh/polakowo/vectorbt/branch/master/graph/badge.svg?token=YTLNAI7PS3" />
35
+ </a>
36
+ <a href="https://vectorbt.dev/" title="Website">
37
+ <img src="https://img.shields.io/website?url=https://vectorbt.dev/" />
38
+ </a>
39
+ <a href="https://mybinder.org/v2/gh/polakowo/vectorbt/HEAD?urlpath=lab" title="Launch Binder">
40
+ <img src="https://img.shields.io/badge/launch-binder-d6604a" />
41
+ </a>
42
+ <a href="https://gitter.im/vectorbt/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge" title="Join the chat">
43
+ <img src="https://badges.gitter.im/vectorbt.svg" />
44
+ </a>
45
+ <a href="https://pypi.org/project/vectorbt" title="Supported Python versions">
46
+ <img src="https://img.shields.io/pypi/pyversions/vectorbt.svg?logo=python&logoColor=white" />
47
+ </a>
48
+ </p>
49
+
50
+ Test thousands of trading ideas in seconds, analyze portfolios across markets and timeframes, and uncover what works with minimal code. Built for both human researchers and AI agents, VectorBT combines rapid experimentation with a mature, battle-tested backtesting stack shaped by years of community use.
51
+
52
+ VectorBT is the open-source, community edition of [VectorBT PRO](https://vectorbt.pro/), a state-of-the-art hybrid backtesting library.
53
+
54
+ ## Features
55
+
56
+ - Fast, vectorized backtesting and strategy research on pandas/NumPy, accelerated with Numba
57
+ - Pandas-native API with custom accessors and high-performance operations
58
+ - Flexible broadcasting for multi-asset analysis and large parameter sweeps
59
+ - Rich indicator ecosystem with support for custom indicators and popular TA libraries (TA-Lib, Pandas TA, etc.)
60
+ - Portfolio backtesting with trades, positions, drawdowns, and performance analysis (incl. QuantStats)
61
+ - Signal-based tooling for generation, ranking, mapping, and distribution analysis
62
+ - Built-in data access (Yahoo Finance, CCXT, Alpaca, etc.), preprocessing, and random data generation
63
+ - Robustness testing, walk-forward optimization, and label generation for ML workflows
64
+ - Interactive visualization with Plotly, Jupyter widgets, and browser-friendly dashboards
65
+ - Automation support for scheduled updates and Telegram notifications
66
+ - Composable Python API suitable for rapid experimentation and AI agent-driven workflows
67
+
68
+ ## Installation
69
+
70
+ ```sh
71
+ pip install -U vectorbt
72
+ ```
73
+
74
+ To install optional dependencies as well:
75
+
76
+ ```sh
77
+ pip install -U "vectorbt[full]"
78
+ ```
79
+
80
+ ## Usage
81
+
82
+ VectorBT lets you backtest strategies in just a few lines of Python.
83
+
84
+ * Profit from investing $100 in Bitcoin since 2014:
85
+
86
+ ```python
87
+ import vectorbt as vbt
88
+
89
+ data = vbt.YFData.download("BTC-USD")
90
+ price = data.get("Close")
91
+
92
+ pf = vbt.Portfolio.from_holding(price, init_cash=100)
93
+ print(pf.total_profit())
94
+ ```
95
+
96
+ ```plaintext
97
+ 19501.10906763755
98
+ ```
99
+
100
+ * Buy when the 10-day SMA crosses above the 50-day SMA, and sell on the opposite crossover:
101
+
102
+ ```python
103
+ fast_ma = vbt.MA.run(price, 10)
104
+ slow_ma = vbt.MA.run(price, 50)
105
+ entries = fast_ma.ma_crossed_above(slow_ma)
106
+ exits = fast_ma.ma_crossed_below(slow_ma)
107
+
108
+ pf = vbt.Portfolio.from_signals(price, entries, exits, init_cash=100)
109
+ print(pf.total_profit())
110
+ ```
111
+
112
+ ```plaintext
113
+ 34417.80960086067
114
+ ```
115
+
116
+ * Generate 1,000 strategies with random signals and test them on BTC and ETH:
117
+
118
+ ```python
119
+ import numpy as np
120
+
121
+ symbols = ["BTC-USD", "ETH-USD"]
122
+ data = vbt.YFData.download(symbols, missing_index="drop")
123
+ price = data.get("Close")
124
+
125
+ n = np.random.randint(10, 101, size=1000).tolist()
126
+ pf = vbt.Portfolio.from_random_signals(price, n=n, init_cash=100, seed=42)
127
+
128
+ mean_expectancy = pf.trades.expectancy().groupby(["randnx_n", "symbol"]).mean()
129
+ fig = mean_expectancy.unstack().vbt.scatterplot(xaxis_title="randnx_n", yaxis_title="mean_expectancy")
130
+ fig.show()
131
+ ```
132
+
133
+ ![](https://raw.githubusercontent.com/polakowo/vectorbt/master/docs/docs/assets/images/usage_rand_scatter.svg)
134
+
135
+ * For hyperparameter optimization fans: test 10,000 window combinations of a dual-SMA crossover strategy on BTC, ETH, and XRP:
136
+
137
+ ```python
138
+ symbols = ["BTC-USD", "ETH-USD", "XRP-USD"]
139
+ data = vbt.YFData.download(symbols, missing_index="drop")
140
+ price = data.get("Close")
141
+
142
+ windows = np.arange(2, 101)
143
+ fast_ma, slow_ma = vbt.MA.run_combs(price, window=windows, r=2, short_names=["fast", "slow"])
144
+ entries = fast_ma.ma_crossed_above(slow_ma)
145
+ exits = fast_ma.ma_crossed_below(slow_ma)
146
+
147
+ pf = vbt.Portfolio.from_signals(price, entries, exits, size=np.inf, fees=0.001, freq="1D")
148
+
149
+ fig = pf.total_return().vbt.heatmap(
150
+ x_level="fast_window", y_level="slow_window", slider_level="symbol", symmetric=True,
151
+ trace_kwargs=dict(colorbar=dict(title="Total return", tickformat="%")))
152
+ fig.show()
153
+ ```
154
+
155
+ <img width="750" src="https://raw.githubusercontent.com/polakowo/vectorbt/master/docs/docs/assets/images/usage_dmac_heatmap.gif">
156
+
157
+ Inspect any strategy configuration by indexing with pandas:
158
+
159
+ ```python
160
+ print(pf[(10, 20, "ETH-USD")].stats())
161
+ ```
162
+
163
+ ```plaintext
164
+ Start 2017-11-09 00:00:00+00:00
165
+ End 2026-01-03 00:00:00+00:00
166
+ Period 2978 days 00:00:00
167
+ Start Value 100.0
168
+ End Value 1604.093789
169
+ Total Return [%] 1504.093789
170
+ Benchmark Return [%] 866.094127
171
+ Max Gross Exposure [%] 100.0
172
+ Total Fees Paid 204.226289
173
+ Max Drawdown [%] 70.734951
174
+ Max Drawdown Duration 1095 days 00:00:00
175
+ Total Trades 81
176
+ Total Closed Trades 80
177
+ Total Open Trades 1
178
+ Open Trade PnL -14.232533
179
+ Win Rate [%] 41.25
180
+ Best Trade [%] 120.511071
181
+ Worst Trade [%] -27.772271
182
+ Avg Winning Trade [%] 27.265519
183
+ Avg Losing Trade [%] -9.022864
184
+ Avg Winning Trade Duration 32 days 20:21:49.090909091
185
+ Avg Losing Trade Duration 8 days 16:51:03.829787234
186
+ Profit Factor 1.275515
187
+ Expectancy 18.979079
188
+ Sharpe Ratio 0.861945
189
+ Calmar Ratio 0.572758
190
+ Omega Ratio 1.20277
191
+ Sortino Ratio 1.301377
192
+ Name: (10, 20, ETH-USD), dtype: object
193
+ ```
194
+
195
+ Same goes for plotting:
196
+
197
+ ```python
198
+ pf[(10, 20, "ETH-USD")].plot().show()
199
+ ```
200
+
201
+ ![](https://raw.githubusercontent.com/polakowo/vectorbt/master/docs/docs/assets/images/usage_dmac_portfolio.svg)
202
+
203
+ It's not all about backtesting! VectorBT can also help with financial data analysis and visualization.
204
+
205
+ * Create a GIF that animates Bollinger Bands %B and bandwidth across multiple symbols:
206
+
207
+ ```python
208
+ symbols = ["BTC-USD", "ETH-USD", "XRP-USD"]
209
+ data = vbt.YFData.download(symbols, period="6mo", missing_index="drop")
210
+ price = data.get("Close")
211
+ bbands = vbt.BBANDS.run(price)
212
+
213
+ def plot(index, bbands):
214
+ bbands = bbands.loc[index]
215
+ fig = vbt.make_subplots(
216
+ rows=2, cols=1, shared_xaxes=True, vertical_spacing=0.15,
217
+ subplot_titles=("%B", "Bandwidth"))
218
+ fig.update_layout(showlegend=False, width=750, height=400)
219
+ bbands.percent_b.vbt.ts_heatmap(
220
+ trace_kwargs=dict(zmin=0, zmid=0.5, zmax=1, colorscale="Spectral", colorbar=dict(
221
+ y=(fig.layout.yaxis.domain[0] + fig.layout.yaxis.domain[1]) / 2, len=0.5
222
+ )), add_trace_kwargs=dict(row=1, col=1), fig=fig)
223
+ bbands.bandwidth.vbt.ts_heatmap(
224
+ trace_kwargs=dict(colorbar=dict(
225
+ y=(fig.layout.yaxis2.domain[0] + fig.layout.yaxis2.domain[1]) / 2, len=0.5
226
+ )), add_trace_kwargs=dict(row=2, col=1), fig=fig)
227
+ return fig
228
+
229
+ vbt.save_animation("bbands.gif", bbands.wrapper.index, plot, bbands, delta=90, step=3, fps=3)
230
+ ```
231
+
232
+ ```plaintext
233
+ 100%|██████████| 31/31 [00:21<00:00, 1.21it/s]
234
+ ```
235
+
236
+ <img width="750" src="https://raw.githubusercontent.com/polakowo/vectorbt/master/docs/docs/assets/images/usage_bbands.gif">
237
+
238
+ This is just the tip of the iceberg. Visit the [website](https://vectorbt.dev/) to learn more.
239
+
240
+ ## Apps
241
+
242
+ ### Candlestick Patterns ([here](https://github.com/polakowo/vectorbt/blob/master/apps/candlestick-patterns/))
243
+
244
+ Explore candlestick-pattern signals interactively and backtest them with VectorBT.
245
+
246
+ [![teaser.png](https://raw.githubusercontent.com/polakowo/vectorbt/master/apps/candlestick-patterns/assets/teaser.png)](https://github.com/polakowo/vectorbt/blob/master/apps/candlestick-patterns/)
247
+
248
+ ## Links
249
+
250
+ * [Website](https://vectorbt.dev/)
251
+ * [Docker images](https://hub.docker.com/r/polakowo/vectorbt)
252
+ * [Colab notebook](https://colab.research.google.com/drive/1ibqyrf6LPFlzRb6mkPpl3hxqL6ryNBXI?usp=sharing)
253
+
254
+ ## License
255
+
256
+ This work is [fair-code](http://faircode.io/) distributed under the [Apache 2.0 with Commons Clause](https://github.com/polakowo/vectorbt/blob/master/LICENSE.md) license.
257
+
258
+ The source code is open, and everyone (individuals and organizations) may use it for free. However, you may not sell products or services that are primarily this software.
259
+
260
+ If you have questions or want to request a license exception, please [contact the author](mailto:olegpolakow@vectorbt.pro).
261
+
262
+ Installing optional dependencies may be subject to a more restrictive license.
263
+
264
+ ## Star history
265
+
266
+ [![Star History Chart](https://api.star-history.com/svg?repos=polakowo/vectorbt&type=Timeline)](https://star-history.com/#polakowo/vectorbt&Timeline)
267
+
268
+ ## Disclaimer
269
+
270
+ This software is for educational purposes only. Do not risk money you cannot afford to lose.
271
+
272
+ USE THE SOFTWARE AT YOUR OWN RISK. THE AUTHORS AND ALL AFFILIATES ASSUME NO RESPONSIBILITY FOR YOUR TRADING RESULTS.