vectorbt 0.28.1__tar.gz → 0.28.4__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 (120) hide show
  1. {vectorbt-0.28.1 → vectorbt-0.28.4}/LICENSE.md +1 -1
  2. vectorbt-0.28.4/PKG-INFO +312 -0
  3. vectorbt-0.28.4/README.md +246 -0
  4. vectorbt-0.28.4/pyproject.toml +90 -0
  5. vectorbt-0.28.4/setup.py +3 -0
  6. {vectorbt-0.28.1 → vectorbt-0.28.4}/tests/test_generic.py +9 -16
  7. {vectorbt-0.28.1 → vectorbt-0.28.4}/tests/test_indicators.py +20 -3
  8. {vectorbt-0.28.1 → vectorbt-0.28.4}/tests/test_records.py +0 -14
  9. {vectorbt-0.28.1 → vectorbt-0.28.4}/tests/test_utils.py +20 -1
  10. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/_version.py +1 -1
  11. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/base/array_wrapper.py +2 -2
  12. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/base/indexing.py +19 -5
  13. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/generic/accessors.py +5 -10
  14. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/indicators/factory.py +9 -3
  15. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/records/base.py +1 -1
  16. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/records/mapped_array.py +5 -10
  17. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/utils/checks.py +71 -0
  18. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/utils/datetime_.py +1 -2
  19. vectorbt-0.28.4/vectorbt.egg-info/PKG-INFO +312 -0
  20. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt.egg-info/SOURCES.txt +1 -4
  21. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt.egg-info/requires.txt +7 -16
  22. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt.egg-info/top_level.txt +0 -1
  23. vectorbt-0.28.1/MANIFEST.in +0 -1
  24. vectorbt-0.28.1/PKG-INFO +0 -316
  25. vectorbt-0.28.1/README.md +0 -232
  26. vectorbt-0.28.1/setup.py +0 -94
  27. vectorbt-0.28.1/tests/__init__.py +0 -0
  28. vectorbt-0.28.1/tests/utils.py +0 -21
  29. vectorbt-0.28.1/vectorbt/templates/.ipynb_checkpoints/dark-checkpoint.json +0 -813
  30. vectorbt-0.28.1/vectorbt.egg-info/PKG-INFO +0 -316
  31. {vectorbt-0.28.1 → vectorbt-0.28.4}/setup.cfg +0 -0
  32. {vectorbt-0.28.1 → vectorbt-0.28.4}/tests/test_base.py +0 -0
  33. {vectorbt-0.28.1 → vectorbt-0.28.4}/tests/test_data.py +0 -0
  34. {vectorbt-0.28.1 → vectorbt-0.28.4}/tests/test_labels.py +0 -0
  35. {vectorbt-0.28.1 → vectorbt-0.28.4}/tests/test_portfolio.py +0 -0
  36. {vectorbt-0.28.1 → vectorbt-0.28.4}/tests/test_returns.py +0 -0
  37. {vectorbt-0.28.1 → vectorbt-0.28.4}/tests/test_settings.py +0 -0
  38. {vectorbt-0.28.1 → vectorbt-0.28.4}/tests/test_signals.py +0 -0
  39. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/__init__.py +0 -0
  40. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/_settings.py +0 -0
  41. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/_typing.py +0 -0
  42. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/base/__init__.py +0 -0
  43. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/base/accessors.py +0 -0
  44. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/base/column_grouper.py +0 -0
  45. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/base/combine_fns.py +0 -0
  46. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/base/index_fns.py +0 -0
  47. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/base/reshape_fns.py +0 -0
  48. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/data/__init__.py +0 -0
  49. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/data/base.py +0 -0
  50. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/data/custom.py +0 -0
  51. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/data/updater.py +0 -0
  52. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/generic/__init__.py +0 -0
  53. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/generic/decorators.py +0 -0
  54. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/generic/drawdowns.py +0 -0
  55. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/generic/enums.py +0 -0
  56. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/generic/nb.py +0 -0
  57. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/generic/plots_builder.py +0 -0
  58. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/generic/plotting.py +0 -0
  59. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/generic/ranges.py +0 -0
  60. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/generic/splitters.py +0 -0
  61. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/generic/stats_builder.py +0 -0
  62. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/indicators/__init__.py +0 -0
  63. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/indicators/basic.py +0 -0
  64. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/indicators/configs.py +0 -0
  65. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/indicators/nb.py +0 -0
  66. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/labels/__init__.py +0 -0
  67. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/labels/enums.py +0 -0
  68. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/labels/generators.py +0 -0
  69. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/labels/nb.py +0 -0
  70. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/messaging/__init__.py +0 -0
  71. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/messaging/telegram.py +0 -0
  72. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/ohlcv_accessors.py +0 -0
  73. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/portfolio/__init__.py +0 -0
  74. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/portfolio/base.py +0 -0
  75. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/portfolio/decorators.py +0 -0
  76. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/portfolio/enums.py +0 -0
  77. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/portfolio/logs.py +0 -0
  78. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/portfolio/nb.py +0 -0
  79. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/portfolio/orders.py +0 -0
  80. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/portfolio/trades.py +0 -0
  81. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/px_accessors.py +0 -0
  82. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/records/__init__.py +0 -0
  83. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/records/col_mapper.py +0 -0
  84. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/records/decorators.py +0 -0
  85. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/records/nb.py +0 -0
  86. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/returns/__init__.py +0 -0
  87. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/returns/accessors.py +0 -0
  88. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/returns/metrics.py +0 -0
  89. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/returns/nb.py +0 -0
  90. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/returns/qs_adapter.py +0 -0
  91. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/root_accessors.py +0 -0
  92. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/signals/__init__.py +0 -0
  93. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/signals/accessors.py +0 -0
  94. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/signals/enums.py +0 -0
  95. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/signals/factory.py +0 -0
  96. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/signals/generators.py +0 -0
  97. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/signals/nb.py +0 -0
  98. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/templates/dark.json +0 -0
  99. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/templates/light.json +0 -0
  100. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/templates/seaborn.json +0 -0
  101. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/utils/__init__.py +0 -0
  102. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/utils/array_.py +0 -0
  103. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/utils/attr_.py +0 -0
  104. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/utils/colors.py +0 -0
  105. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/utils/config.py +0 -0
  106. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/utils/decorators.py +0 -0
  107. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/utils/docs.py +0 -0
  108. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/utils/enum_.py +0 -0
  109. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/utils/figure.py +0 -0
  110. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/utils/image_.py +0 -0
  111. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/utils/mapping.py +0 -0
  112. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/utils/math_.py +0 -0
  113. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/utils/module_.py +0 -0
  114. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/utils/params.py +0 -0
  115. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/utils/random_.py +0 -0
  116. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/utils/requests_.py +0 -0
  117. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/utils/schedule_.py +0 -0
  118. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/utils/tags.py +0 -0
  119. {vectorbt-0.28.1 → vectorbt-0.28.4}/vectorbt/utils/template.py +0 -0
  120. {vectorbt-0.28.1 → vectorbt-0.28.4}/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,312 @@
1
+ Metadata-Version: 2.4
2
+ Name: vectorbt
3
+ Version: 0.28.4
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
+ Dynamic: license-file
66
+
67
+ <div align="center">
68
+ <a href="https://vectorbt.pro/" title="VectorBT PRO">
69
+ <img src="https://raw.githubusercontent.com/polakowo/vectorbt/master/docs/docs/assets/logo/header-pro.svg" />
70
+ </a>
71
+ </div>
72
+ <div align="center">
73
+ <a href="https://vectorbt.dev/" title="vectorbt">
74
+ <img src="https://raw.githubusercontent.com/polakowo/vectorbt/master/docs/docs/assets/logo/header.svg" />
75
+ </a>
76
+ </div>
77
+
78
+ <br>
79
+
80
+ <p align="center">
81
+ <a href="https://pepy.tech/project/vectorbt" title="Downloads">
82
+ <img src="https://pepy.tech/badge/vectorbt" />
83
+ </a>
84
+ <a href="https://pypi.org/project/vectorbt" title="PyPI">
85
+ <img src="https://img.shields.io/pypi/v/vectorbt?color=blueviolet" />
86
+ </a>
87
+ <a href="https://github.com/polakowo/vectorbt/blob/master/LICENSE.md" title="License">
88
+ <img src="https://img.shields.io/badge/license-Fair%20Code-yellow" />
89
+ </a>
90
+ <a href="https://codecov.io/gh/polakowo/vectorbt" title="codecov">
91
+ <img src="https://codecov.io/gh/polakowo/vectorbt/branch/master/graph/badge.svg?token=YTLNAI7PS3" />
92
+ </a>
93
+ <a href="https://vectorbt.dev/" title="Website">
94
+ <img src="https://img.shields.io/website?url=https://vectorbt.dev/" />
95
+ </a>
96
+ <a href="https://mybinder.org/v2/gh/polakowo/vectorbt/HEAD?urlpath=lab" title="Launch Binder">
97
+ <img src="https://img.shields.io/badge/launch-binder-d6604a" />
98
+ </a>
99
+ <a href="https://gitter.im/vectorbt/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge" title="Join the chat">
100
+ <img src="https://badges.gitter.im/vectorbt.svg" />
101
+ </a>
102
+ </p>
103
+
104
+ <p align="center">
105
+ <a href="https://pypi.org/project/vectorbt" title="Supported Python versions">
106
+ <img src="https://img.shields.io/pypi/pyversions/vectorbt.svg?logo=python&logoColor=white" />
107
+ </a>
108
+ </p>
109
+
110
+ > [!TIP]
111
+ > *New in 0.28*:
112
+ >
113
+ > * Plotly 6 support
114
+ > * `ticker_kwargs` in `YFData`
115
+ > * Fixed Pandas TA dependency (→ [pandas-ta-classic](https://github.com/xgboosted/pandas-ta-classic)).
116
+
117
+ ## :package: Installation
118
+
119
+ ```sh
120
+ pip install -U vectorbt
121
+ ```
122
+
123
+ To install optional dependencies as well:
124
+
125
+ ```sh
126
+ pip install -U "vectorbt[full]"
127
+ ```
128
+
129
+ ## :sparkles: Usage
130
+
131
+ VectorBT lets you backtest strategies in just a few lines of Python.
132
+
133
+ * Profit from investing $100 in Bitcoin since 2014:
134
+
135
+ ```python
136
+ import vectorbt as vbt
137
+
138
+ data = vbt.YFData.download("BTC-USD")
139
+ price = data.get("Close")
140
+
141
+ pf = vbt.Portfolio.from_holding(price, init_cash=100)
142
+ print(pf.total_profit())
143
+ ```
144
+
145
+ ```plaintext
146
+ 19501.10906763755
147
+ ```
148
+
149
+ * Buy when the 10-day SMA crosses above the 50-day SMA, and sell on the opposite crossover:
150
+
151
+ ```python
152
+ fast_ma = vbt.MA.run(price, 10)
153
+ slow_ma = vbt.MA.run(price, 50)
154
+ entries = fast_ma.ma_crossed_above(slow_ma)
155
+ exits = fast_ma.ma_crossed_below(slow_ma)
156
+
157
+ pf = vbt.Portfolio.from_signals(price, entries, exits, init_cash=100)
158
+ print(pf.total_profit())
159
+ ```
160
+
161
+ ```plaintext
162
+ 34417.80960086067
163
+ ```
164
+
165
+ * Generate 1,000 strategies with random signals and test them on BTC and ETH:
166
+
167
+ ```python
168
+ import numpy as np
169
+
170
+ symbols = ["BTC-USD", "ETH-USD"]
171
+ data = vbt.YFData.download(symbols, missing_index="drop")
172
+ price = data.get("Close")
173
+
174
+ n = np.random.randint(10, 101, size=1000).tolist()
175
+ pf = vbt.Portfolio.from_random_signals(price, n=n, init_cash=100, seed=42)
176
+
177
+ mean_expectancy = pf.trades.expectancy().groupby(["randnx_n", "symbol"]).mean()
178
+ fig = mean_expectancy.unstack().vbt.scatterplot(xaxis_title="randnx_n", yaxis_title="mean_expectancy")
179
+ fig.show()
180
+ ```
181
+
182
+ ![](https://raw.githubusercontent.com/polakowo/vectorbt/master/docs/docs/assets/images/usage_rand_scatter.svg)
183
+
184
+ * For hyperparameter optimization fans: test 10,000 window combinations of a dual-SMA crossover strategy on BTC, ETH, and XRP:
185
+
186
+ ```python
187
+ symbols = ["BTC-USD", "ETH-USD", "XRP-USD"]
188
+ data = vbt.YFData.download(symbols, missing_index="drop")
189
+ price = data.get("Close")
190
+
191
+ windows = np.arange(2, 101)
192
+ fast_ma, slow_ma = vbt.MA.run_combs(price, window=windows, r=2, short_names=["fast", "slow"])
193
+ entries = fast_ma.ma_crossed_above(slow_ma)
194
+ exits = fast_ma.ma_crossed_below(slow_ma)
195
+
196
+ pf = vbt.Portfolio.from_signals(price, entries, exits, size=np.inf, fees=0.001, freq="1D")
197
+
198
+ fig = pf.total_return().vbt.heatmap(
199
+ x_level="fast_window", y_level="slow_window", slider_level="symbol", symmetric=True,
200
+ trace_kwargs=dict(colorbar=dict(title="Total return", tickformat="%")))
201
+ fig.show()
202
+ ```
203
+
204
+ <img width="750" src="https://raw.githubusercontent.com/polakowo/vectorbt/master/docs/docs/assets/images/usage_dmac_heatmap.gif">
205
+
206
+ Inspect any strategy configuration by indexing with pandas:
207
+
208
+ ```python
209
+ print(pf[(10, 20, "ETH-USD")].stats())
210
+ ```
211
+
212
+ ```plaintext
213
+ Start 2017-11-09 00:00:00+00:00
214
+ End 2026-01-03 00:00:00+00:00
215
+ Period 2978 days 00:00:00
216
+ Start Value 100.0
217
+ End Value 1604.093789
218
+ Total Return [%] 1504.093789
219
+ Benchmark Return [%] 866.094127
220
+ Max Gross Exposure [%] 100.0
221
+ Total Fees Paid 204.226289
222
+ Max Drawdown [%] 70.734951
223
+ Max Drawdown Duration 1095 days 00:00:00
224
+ Total Trades 81
225
+ Total Closed Trades 80
226
+ Total Open Trades 1
227
+ Open Trade PnL -14.232533
228
+ Win Rate [%] 41.25
229
+ Best Trade [%] 120.511071
230
+ Worst Trade [%] -27.772271
231
+ Avg Winning Trade [%] 27.265519
232
+ Avg Losing Trade [%] -9.022864
233
+ Avg Winning Trade Duration 32 days 20:21:49.090909091
234
+ Avg Losing Trade Duration 8 days 16:51:03.829787234
235
+ Profit Factor 1.275515
236
+ Expectancy 18.979079
237
+ Sharpe Ratio 0.861945
238
+ Calmar Ratio 0.572758
239
+ Omega Ratio 1.20277
240
+ Sortino Ratio 1.301377
241
+ Name: (10, 20, ETH-USD), dtype: object
242
+ ```
243
+
244
+ Same goes for plotting:
245
+
246
+ ```python
247
+ pf[(10, 20, "ETH-USD")].plot().show()
248
+ ```
249
+
250
+ ![](https://raw.githubusercontent.com/polakowo/vectorbt/master/docs/docs/assets/images/usage_dmac_portfolio.svg)
251
+
252
+ It's not all about backtesting! VectorBT can also help with financial data analysis and visualization.
253
+
254
+ * Create a GIF that animates Bollinger Bands %B and bandwidth across multiple symbols:
255
+
256
+ ```python
257
+ symbols = ["BTC-USD", "ETH-USD", "XRP-USD"]
258
+ data = vbt.YFData.download(symbols, period="6mo", missing_index="drop")
259
+ price = data.get("Close")
260
+ bbands = vbt.BBANDS.run(price)
261
+
262
+ def plot(index, bbands):
263
+ bbands = bbands.loc[index]
264
+ fig = vbt.make_subplots(
265
+ rows=2, cols=1, shared_xaxes=True, vertical_spacing=0.15,
266
+ subplot_titles=("%B", "Bandwidth"))
267
+ fig.update_layout(showlegend=False, width=750, height=400)
268
+ bbands.percent_b.vbt.ts_heatmap(
269
+ trace_kwargs=dict(zmin=0, zmid=0.5, zmax=1, colorscale="Spectral", colorbar=dict(
270
+ y=(fig.layout.yaxis.domain[0] + fig.layout.yaxis.domain[1]) / 2, len=0.5
271
+ )), add_trace_kwargs=dict(row=1, col=1), fig=fig)
272
+ bbands.bandwidth.vbt.ts_heatmap(
273
+ trace_kwargs=dict(colorbar=dict(
274
+ y=(fig.layout.yaxis2.domain[0] + fig.layout.yaxis2.domain[1]) / 2, len=0.5
275
+ )), add_trace_kwargs=dict(row=2, col=1), fig=fig)
276
+ return fig
277
+
278
+ vbt.save_animation("bbands.gif", bbands.wrapper.index, plot, bbands, delta=90, step=3, fps=3)
279
+ ```
280
+
281
+ ```plaintext
282
+ 100%|██████████| 31/31 [00:21<00:00, 1.21it/s]
283
+ ```
284
+
285
+ <img width="750" src="https://raw.githubusercontent.com/polakowo/vectorbt/master/docs/docs/assets/images/usage_bbands.gif">
286
+
287
+ This is just the tip of the iceberg. Visit the [website](https://vectorbt.dev/) to learn more.
288
+
289
+ ## :link: Links
290
+
291
+ * [Website](https://vectorbt.dev/)
292
+ * [Colab Notebook](https://colab.research.google.com/drive/1ibqyrf6LPFlzRb6mkPpl3hxqL6ryNBXI?usp=sharing)
293
+
294
+ ## :balance_scale: License
295
+
296
+ 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.
297
+
298
+ 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.
299
+
300
+ If you have questions or want to request a license exception, please [contact the author](mailto:olegpolakow@vectorbt.pro).
301
+
302
+ Installing optional dependencies may be subject to a more restrictive license.
303
+
304
+ ## :star: Star History
305
+
306
+ [![Star History Chart](https://api.star-history.com/svg?repos=polakowo/vectorbt&type=Timeline)](https://star-history.com/#polakowo/vectorbt&Timeline)
307
+
308
+ ## :warning: Disclaimer
309
+
310
+ This software is for educational purposes only. Do not risk money you cannot afford to lose.
311
+
312
+ USE THE SOFTWARE AT YOUR OWN RISK. THE AUTHORS AND ALL AFFILIATES ASSUME NO RESPONSIBILITY FOR YOUR TRADING RESULTS.
@@ -0,0 +1,246 @@
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://pypi.org/project/vectorbt" title="PyPI">
19
+ <img src="https://img.shields.io/pypi/v/vectorbt?color=blueviolet" />
20
+ </a>
21
+ <a href="https://github.com/polakowo/vectorbt/blob/master/LICENSE.md" title="License">
22
+ <img src="https://img.shields.io/badge/license-Fair%20Code-yellow" />
23
+ </a>
24
+ <a href="https://codecov.io/gh/polakowo/vectorbt" title="codecov">
25
+ <img src="https://codecov.io/gh/polakowo/vectorbt/branch/master/graph/badge.svg?token=YTLNAI7PS3" />
26
+ </a>
27
+ <a href="https://vectorbt.dev/" title="Website">
28
+ <img src="https://img.shields.io/website?url=https://vectorbt.dev/" />
29
+ </a>
30
+ <a href="https://mybinder.org/v2/gh/polakowo/vectorbt/HEAD?urlpath=lab" title="Launch Binder">
31
+ <img src="https://img.shields.io/badge/launch-binder-d6604a" />
32
+ </a>
33
+ <a href="https://gitter.im/vectorbt/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge" title="Join the chat">
34
+ <img src="https://badges.gitter.im/vectorbt.svg" />
35
+ </a>
36
+ </p>
37
+
38
+ <p align="center">
39
+ <a href="https://pypi.org/project/vectorbt" title="Supported Python versions">
40
+ <img src="https://img.shields.io/pypi/pyversions/vectorbt.svg?logo=python&logoColor=white" />
41
+ </a>
42
+ </p>
43
+
44
+ > [!TIP]
45
+ > *New in 0.28*:
46
+ >
47
+ > * Plotly 6 support
48
+ > * `ticker_kwargs` in `YFData`
49
+ > * Fixed Pandas TA dependency (→ [pandas-ta-classic](https://github.com/xgboosted/pandas-ta-classic)).
50
+
51
+ ## :package: Installation
52
+
53
+ ```sh
54
+ pip install -U vectorbt
55
+ ```
56
+
57
+ To install optional dependencies as well:
58
+
59
+ ```sh
60
+ pip install -U "vectorbt[full]"
61
+ ```
62
+
63
+ ## :sparkles: Usage
64
+
65
+ VectorBT lets you backtest strategies in just a few lines of Python.
66
+
67
+ * Profit from investing $100 in Bitcoin since 2014:
68
+
69
+ ```python
70
+ import vectorbt as vbt
71
+
72
+ data = vbt.YFData.download("BTC-USD")
73
+ price = data.get("Close")
74
+
75
+ pf = vbt.Portfolio.from_holding(price, init_cash=100)
76
+ print(pf.total_profit())
77
+ ```
78
+
79
+ ```plaintext
80
+ 19501.10906763755
81
+ ```
82
+
83
+ * Buy when the 10-day SMA crosses above the 50-day SMA, and sell on the opposite crossover:
84
+
85
+ ```python
86
+ fast_ma = vbt.MA.run(price, 10)
87
+ slow_ma = vbt.MA.run(price, 50)
88
+ entries = fast_ma.ma_crossed_above(slow_ma)
89
+ exits = fast_ma.ma_crossed_below(slow_ma)
90
+
91
+ pf = vbt.Portfolio.from_signals(price, entries, exits, init_cash=100)
92
+ print(pf.total_profit())
93
+ ```
94
+
95
+ ```plaintext
96
+ 34417.80960086067
97
+ ```
98
+
99
+ * Generate 1,000 strategies with random signals and test them on BTC and ETH:
100
+
101
+ ```python
102
+ import numpy as np
103
+
104
+ symbols = ["BTC-USD", "ETH-USD"]
105
+ data = vbt.YFData.download(symbols, missing_index="drop")
106
+ price = data.get("Close")
107
+
108
+ n = np.random.randint(10, 101, size=1000).tolist()
109
+ pf = vbt.Portfolio.from_random_signals(price, n=n, init_cash=100, seed=42)
110
+
111
+ mean_expectancy = pf.trades.expectancy().groupby(["randnx_n", "symbol"]).mean()
112
+ fig = mean_expectancy.unstack().vbt.scatterplot(xaxis_title="randnx_n", yaxis_title="mean_expectancy")
113
+ fig.show()
114
+ ```
115
+
116
+ ![](https://raw.githubusercontent.com/polakowo/vectorbt/master/docs/docs/assets/images/usage_rand_scatter.svg)
117
+
118
+ * For hyperparameter optimization fans: test 10,000 window combinations of a dual-SMA crossover strategy on BTC, ETH, and XRP:
119
+
120
+ ```python
121
+ symbols = ["BTC-USD", "ETH-USD", "XRP-USD"]
122
+ data = vbt.YFData.download(symbols, missing_index="drop")
123
+ price = data.get("Close")
124
+
125
+ windows = np.arange(2, 101)
126
+ fast_ma, slow_ma = vbt.MA.run_combs(price, window=windows, r=2, short_names=["fast", "slow"])
127
+ entries = fast_ma.ma_crossed_above(slow_ma)
128
+ exits = fast_ma.ma_crossed_below(slow_ma)
129
+
130
+ pf = vbt.Portfolio.from_signals(price, entries, exits, size=np.inf, fees=0.001, freq="1D")
131
+
132
+ fig = pf.total_return().vbt.heatmap(
133
+ x_level="fast_window", y_level="slow_window", slider_level="symbol", symmetric=True,
134
+ trace_kwargs=dict(colorbar=dict(title="Total return", tickformat="%")))
135
+ fig.show()
136
+ ```
137
+
138
+ <img width="750" src="https://raw.githubusercontent.com/polakowo/vectorbt/master/docs/docs/assets/images/usage_dmac_heatmap.gif">
139
+
140
+ Inspect any strategy configuration by indexing with pandas:
141
+
142
+ ```python
143
+ print(pf[(10, 20, "ETH-USD")].stats())
144
+ ```
145
+
146
+ ```plaintext
147
+ Start 2017-11-09 00:00:00+00:00
148
+ End 2026-01-03 00:00:00+00:00
149
+ Period 2978 days 00:00:00
150
+ Start Value 100.0
151
+ End Value 1604.093789
152
+ Total Return [%] 1504.093789
153
+ Benchmark Return [%] 866.094127
154
+ Max Gross Exposure [%] 100.0
155
+ Total Fees Paid 204.226289
156
+ Max Drawdown [%] 70.734951
157
+ Max Drawdown Duration 1095 days 00:00:00
158
+ Total Trades 81
159
+ Total Closed Trades 80
160
+ Total Open Trades 1
161
+ Open Trade PnL -14.232533
162
+ Win Rate [%] 41.25
163
+ Best Trade [%] 120.511071
164
+ Worst Trade [%] -27.772271
165
+ Avg Winning Trade [%] 27.265519
166
+ Avg Losing Trade [%] -9.022864
167
+ Avg Winning Trade Duration 32 days 20:21:49.090909091
168
+ Avg Losing Trade Duration 8 days 16:51:03.829787234
169
+ Profit Factor 1.275515
170
+ Expectancy 18.979079
171
+ Sharpe Ratio 0.861945
172
+ Calmar Ratio 0.572758
173
+ Omega Ratio 1.20277
174
+ Sortino Ratio 1.301377
175
+ Name: (10, 20, ETH-USD), dtype: object
176
+ ```
177
+
178
+ Same goes for plotting:
179
+
180
+ ```python
181
+ pf[(10, 20, "ETH-USD")].plot().show()
182
+ ```
183
+
184
+ ![](https://raw.githubusercontent.com/polakowo/vectorbt/master/docs/docs/assets/images/usage_dmac_portfolio.svg)
185
+
186
+ It's not all about backtesting! VectorBT can also help with financial data analysis and visualization.
187
+
188
+ * Create a GIF that animates Bollinger Bands %B and bandwidth across multiple symbols:
189
+
190
+ ```python
191
+ symbols = ["BTC-USD", "ETH-USD", "XRP-USD"]
192
+ data = vbt.YFData.download(symbols, period="6mo", missing_index="drop")
193
+ price = data.get("Close")
194
+ bbands = vbt.BBANDS.run(price)
195
+
196
+ def plot(index, bbands):
197
+ bbands = bbands.loc[index]
198
+ fig = vbt.make_subplots(
199
+ rows=2, cols=1, shared_xaxes=True, vertical_spacing=0.15,
200
+ subplot_titles=("%B", "Bandwidth"))
201
+ fig.update_layout(showlegend=False, width=750, height=400)
202
+ bbands.percent_b.vbt.ts_heatmap(
203
+ trace_kwargs=dict(zmin=0, zmid=0.5, zmax=1, colorscale="Spectral", colorbar=dict(
204
+ y=(fig.layout.yaxis.domain[0] + fig.layout.yaxis.domain[1]) / 2, len=0.5
205
+ )), add_trace_kwargs=dict(row=1, col=1), fig=fig)
206
+ bbands.bandwidth.vbt.ts_heatmap(
207
+ trace_kwargs=dict(colorbar=dict(
208
+ y=(fig.layout.yaxis2.domain[0] + fig.layout.yaxis2.domain[1]) / 2, len=0.5
209
+ )), add_trace_kwargs=dict(row=2, col=1), fig=fig)
210
+ return fig
211
+
212
+ vbt.save_animation("bbands.gif", bbands.wrapper.index, plot, bbands, delta=90, step=3, fps=3)
213
+ ```
214
+
215
+ ```plaintext
216
+ 100%|██████████| 31/31 [00:21<00:00, 1.21it/s]
217
+ ```
218
+
219
+ <img width="750" src="https://raw.githubusercontent.com/polakowo/vectorbt/master/docs/docs/assets/images/usage_bbands.gif">
220
+
221
+ This is just the tip of the iceberg. Visit the [website](https://vectorbt.dev/) to learn more.
222
+
223
+ ## :link: Links
224
+
225
+ * [Website](https://vectorbt.dev/)
226
+ * [Colab Notebook](https://colab.research.google.com/drive/1ibqyrf6LPFlzRb6mkPpl3hxqL6ryNBXI?usp=sharing)
227
+
228
+ ## :balance_scale: License
229
+
230
+ 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.
231
+
232
+ 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.
233
+
234
+ If you have questions or want to request a license exception, please [contact the author](mailto:olegpolakow@vectorbt.pro).
235
+
236
+ Installing optional dependencies may be subject to a more restrictive license.
237
+
238
+ ## :star: Star History
239
+
240
+ [![Star History Chart](https://api.star-history.com/svg?repos=polakowo/vectorbt&type=Timeline)](https://star-history.com/#polakowo/vectorbt&Timeline)
241
+
242
+ ## :warning: Disclaimer
243
+
244
+ This software is for educational purposes only. Do not risk money you cannot afford to lose.
245
+
246
+ USE THE SOFTWARE AT YOUR OWN RISK. THE AUTHORS AND ALL AFFILIATES ASSUME NO RESPONSIBILITY FOR YOUR TRADING RESULTS.
@@ -0,0 +1,90 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "vectorbt"
7
+ dynamic = ["version"]
8
+ description = "Python library for backtesting and analyzing trading strategies at scale"
9
+ readme = "README.md"
10
+ license-files = ["LICENSE.md"]
11
+ authors = [
12
+ {name = "Oleg Polakow", email = "olegpolakow@vectorbt.pro"}
13
+ ]
14
+ requires-python = ">=3.10"
15
+ classifiers = [
16
+ "Development Status :: 5 - Production/Stable",
17
+ "Intended Audience :: Developers",
18
+ "Intended Audience :: Financial and Insurance Industry",
19
+ "Programming Language :: Python :: 3.10",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Programming Language :: Python :: 3.13",
23
+ "Operating System :: OS Independent",
24
+ "Intended Audience :: Science/Research",
25
+ "Topic :: Software Development",
26
+ "Topic :: Office/Business :: Financial",
27
+ "Topic :: Scientific/Engineering :: Information Analysis",
28
+ ]
29
+ dependencies = [
30
+ "numpy>=1.23",
31
+ "pandas>=2.0,<3.0",
32
+ "scipy",
33
+ "matplotlib",
34
+ "plotly>=4.12.0",
35
+ "ipywidgets>=7.0.0",
36
+ "anywidget",
37
+ "numba>=0.60",
38
+ "dill",
39
+ "tqdm",
40
+ "dateparser",
41
+ "imageio",
42
+ "scikit-learn",
43
+ "schedule",
44
+ "requests",
45
+ "pytz",
46
+ "mypy_extensions",
47
+ ]
48
+
49
+ [project.optional-dependencies]
50
+ full = [
51
+ "yfinance>=0.2.22",
52
+ "python-binance",
53
+ "ccxt>=4.0.14",
54
+ "alpaca-py",
55
+ "ray>=1.4.1",
56
+ "ta",
57
+ "pandas-ta-classic",
58
+ "TA-Lib",
59
+ "python-telegram-bot>=13.4,<20.0",
60
+ "quantstats>=0.0.37",
61
+ ]
62
+ full-no-talib = [
63
+ "yfinance>=0.2.22",
64
+ "python-binance",
65
+ "ccxt>=4.0.14",
66
+ "alpaca-py",
67
+ "ray>=1.4.1",
68
+ "ta",
69
+ "pandas-ta-classic",
70
+ "python-telegram-bot>=13.4,<20.0",
71
+ "quantstats>=0.0.37",
72
+ ]
73
+ cov = [
74
+ "pytest",
75
+ "pytest-cov",
76
+ "pytest-xdist",
77
+ "codecov",
78
+ ]
79
+
80
+ [project.urls]
81
+ Homepage = "https://github.com/polakowo/vectorbt"
82
+
83
+ [tool.setuptools.dynamic]
84
+ version = {attr = "vectorbt._version.__version__"}
85
+
86
+ [tool.setuptools.packages.find]
87
+ include = ["vectorbt*"]
88
+
89
+ [tool.setuptools.package-data]
90
+ vectorbt = ["templates/*.json"]
@@ -0,0 +1,3 @@
1
+ from setuptools import setup
2
+
3
+ setup()