vectorbt-rust 1.0.0__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.
@@ -0,0 +1,363 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 4
4
+
5
+ [[package]]
6
+ name = "autocfg"
7
+ version = "1.5.0"
8
+ source = "registry+https://github.com/rust-lang/crates.io-index"
9
+ checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
10
+
11
+ [[package]]
12
+ name = "cfg-if"
13
+ version = "1.0.4"
14
+ source = "registry+https://github.com/rust-lang/crates.io-index"
15
+ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
16
+
17
+ [[package]]
18
+ name = "getrandom"
19
+ version = "0.3.4"
20
+ source = "registry+https://github.com/rust-lang/crates.io-index"
21
+ checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd"
22
+ dependencies = [
23
+ "cfg-if",
24
+ "libc",
25
+ "r-efi",
26
+ "wasip2",
27
+ ]
28
+
29
+ [[package]]
30
+ name = "heck"
31
+ version = "0.5.0"
32
+ source = "registry+https://github.com/rust-lang/crates.io-index"
33
+ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
34
+
35
+ [[package]]
36
+ name = "indoc"
37
+ version = "2.0.7"
38
+ source = "registry+https://github.com/rust-lang/crates.io-index"
39
+ checksum = "79cf5c93f93228cf8efb3ba362535fb11199ac548a09ce117c9b1adc3030d706"
40
+ dependencies = [
41
+ "rustversion",
42
+ ]
43
+
44
+ [[package]]
45
+ name = "libc"
46
+ version = "0.2.185"
47
+ source = "registry+https://github.com/rust-lang/crates.io-index"
48
+ checksum = "52ff2c0fe9bc6cb6b14a0592c2ff4fa9ceb83eea9db979b0487cd054946a2b8f"
49
+
50
+ [[package]]
51
+ name = "matrixmultiply"
52
+ version = "0.3.10"
53
+ source = "registry+https://github.com/rust-lang/crates.io-index"
54
+ checksum = "a06de3016e9fae57a36fd14dba131fccf49f74b40b7fbdb472f96e361ec71a08"
55
+ dependencies = [
56
+ "autocfg",
57
+ "rawpointer",
58
+ ]
59
+
60
+ [[package]]
61
+ name = "memoffset"
62
+ version = "0.9.1"
63
+ source = "registry+https://github.com/rust-lang/crates.io-index"
64
+ checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
65
+ dependencies = [
66
+ "autocfg",
67
+ ]
68
+
69
+ [[package]]
70
+ name = "ndarray"
71
+ version = "0.16.1"
72
+ source = "registry+https://github.com/rust-lang/crates.io-index"
73
+ checksum = "882ed72dce9365842bf196bdeedf5055305f11fc8c03dee7bb0194a6cad34841"
74
+ dependencies = [
75
+ "matrixmultiply",
76
+ "num-complex",
77
+ "num-integer",
78
+ "num-traits",
79
+ "portable-atomic",
80
+ "portable-atomic-util",
81
+ "rawpointer",
82
+ ]
83
+
84
+ [[package]]
85
+ name = "num-complex"
86
+ version = "0.4.6"
87
+ source = "registry+https://github.com/rust-lang/crates.io-index"
88
+ checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495"
89
+ dependencies = [
90
+ "num-traits",
91
+ ]
92
+
93
+ [[package]]
94
+ name = "num-integer"
95
+ version = "0.1.46"
96
+ source = "registry+https://github.com/rust-lang/crates.io-index"
97
+ checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f"
98
+ dependencies = [
99
+ "num-traits",
100
+ ]
101
+
102
+ [[package]]
103
+ name = "num-traits"
104
+ version = "0.2.19"
105
+ source = "registry+https://github.com/rust-lang/crates.io-index"
106
+ checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
107
+ dependencies = [
108
+ "autocfg",
109
+ ]
110
+
111
+ [[package]]
112
+ name = "numpy"
113
+ version = "0.22.1"
114
+ source = "registry+https://github.com/rust-lang/crates.io-index"
115
+ checksum = "edb929bc0da91a4d85ed6c0a84deaa53d411abfb387fc271124f91bf6b89f14e"
116
+ dependencies = [
117
+ "libc",
118
+ "ndarray",
119
+ "num-complex",
120
+ "num-integer",
121
+ "num-traits",
122
+ "pyo3",
123
+ "rustc-hash",
124
+ ]
125
+
126
+ [[package]]
127
+ name = "once_cell"
128
+ version = "1.21.4"
129
+ source = "registry+https://github.com/rust-lang/crates.io-index"
130
+ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
131
+
132
+ [[package]]
133
+ name = "portable-atomic"
134
+ version = "1.13.1"
135
+ source = "registry+https://github.com/rust-lang/crates.io-index"
136
+ checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49"
137
+
138
+ [[package]]
139
+ name = "portable-atomic-util"
140
+ version = "0.2.7"
141
+ source = "registry+https://github.com/rust-lang/crates.io-index"
142
+ checksum = "c2a106d1259c23fac8e543272398ae0e3c0b8d33c88ed73d0cc71b0f1d902618"
143
+ dependencies = [
144
+ "portable-atomic",
145
+ ]
146
+
147
+ [[package]]
148
+ name = "ppv-lite86"
149
+ version = "0.2.21"
150
+ source = "registry+https://github.com/rust-lang/crates.io-index"
151
+ checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
152
+ dependencies = [
153
+ "zerocopy",
154
+ ]
155
+
156
+ [[package]]
157
+ name = "proc-macro2"
158
+ version = "1.0.106"
159
+ source = "registry+https://github.com/rust-lang/crates.io-index"
160
+ checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
161
+ dependencies = [
162
+ "unicode-ident",
163
+ ]
164
+
165
+ [[package]]
166
+ name = "pyo3"
167
+ version = "0.22.6"
168
+ source = "registry+https://github.com/rust-lang/crates.io-index"
169
+ checksum = "f402062616ab18202ae8319da13fa4279883a2b8a9d9f83f20dbade813ce1884"
170
+ dependencies = [
171
+ "cfg-if",
172
+ "indoc",
173
+ "libc",
174
+ "memoffset",
175
+ "once_cell",
176
+ "portable-atomic",
177
+ "pyo3-build-config",
178
+ "pyo3-ffi",
179
+ "pyo3-macros",
180
+ "unindent",
181
+ ]
182
+
183
+ [[package]]
184
+ name = "pyo3-build-config"
185
+ version = "0.22.6"
186
+ source = "registry+https://github.com/rust-lang/crates.io-index"
187
+ checksum = "b14b5775b5ff446dd1056212d778012cbe8a0fbffd368029fd9e25b514479c38"
188
+ dependencies = [
189
+ "once_cell",
190
+ "target-lexicon",
191
+ ]
192
+
193
+ [[package]]
194
+ name = "pyo3-ffi"
195
+ version = "0.22.6"
196
+ source = "registry+https://github.com/rust-lang/crates.io-index"
197
+ checksum = "9ab5bcf04a2cdcbb50c7d6105de943f543f9ed92af55818fd17b660390fc8636"
198
+ dependencies = [
199
+ "libc",
200
+ "pyo3-build-config",
201
+ ]
202
+
203
+ [[package]]
204
+ name = "pyo3-macros"
205
+ version = "0.22.6"
206
+ source = "registry+https://github.com/rust-lang/crates.io-index"
207
+ checksum = "0fd24d897903a9e6d80b968368a34e1525aeb719d568dba8b3d4bfa5dc67d453"
208
+ dependencies = [
209
+ "proc-macro2",
210
+ "pyo3-macros-backend",
211
+ "quote",
212
+ "syn",
213
+ ]
214
+
215
+ [[package]]
216
+ name = "pyo3-macros-backend"
217
+ version = "0.22.6"
218
+ source = "registry+https://github.com/rust-lang/crates.io-index"
219
+ checksum = "36c011a03ba1e50152b4b394b479826cad97e7a21eb52df179cd91ac411cbfbe"
220
+ dependencies = [
221
+ "heck",
222
+ "proc-macro2",
223
+ "pyo3-build-config",
224
+ "quote",
225
+ "syn",
226
+ ]
227
+
228
+ [[package]]
229
+ name = "quote"
230
+ version = "1.0.45"
231
+ source = "registry+https://github.com/rust-lang/crates.io-index"
232
+ checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924"
233
+ dependencies = [
234
+ "proc-macro2",
235
+ ]
236
+
237
+ [[package]]
238
+ name = "r-efi"
239
+ version = "5.3.0"
240
+ source = "registry+https://github.com/rust-lang/crates.io-index"
241
+ checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
242
+
243
+ [[package]]
244
+ name = "rand"
245
+ version = "0.9.4"
246
+ source = "registry+https://github.com/rust-lang/crates.io-index"
247
+ checksum = "44c5af06bb1b7d3216d91932aed5265164bf384dc89cd6ba05cf59a35f5f76ea"
248
+ dependencies = [
249
+ "rand_chacha",
250
+ "rand_core",
251
+ ]
252
+
253
+ [[package]]
254
+ name = "rand_chacha"
255
+ version = "0.9.0"
256
+ source = "registry+https://github.com/rust-lang/crates.io-index"
257
+ checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
258
+ dependencies = [
259
+ "ppv-lite86",
260
+ "rand_core",
261
+ ]
262
+
263
+ [[package]]
264
+ name = "rand_core"
265
+ version = "0.9.5"
266
+ source = "registry+https://github.com/rust-lang/crates.io-index"
267
+ checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c"
268
+ dependencies = [
269
+ "getrandom",
270
+ ]
271
+
272
+ [[package]]
273
+ name = "rawpointer"
274
+ version = "0.2.1"
275
+ source = "registry+https://github.com/rust-lang/crates.io-index"
276
+ checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3"
277
+
278
+ [[package]]
279
+ name = "rustc-hash"
280
+ version = "1.1.0"
281
+ source = "registry+https://github.com/rust-lang/crates.io-index"
282
+ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
283
+
284
+ [[package]]
285
+ name = "rustversion"
286
+ version = "1.0.22"
287
+ source = "registry+https://github.com/rust-lang/crates.io-index"
288
+ checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
289
+
290
+ [[package]]
291
+ name = "syn"
292
+ version = "2.0.117"
293
+ source = "registry+https://github.com/rust-lang/crates.io-index"
294
+ checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99"
295
+ dependencies = [
296
+ "proc-macro2",
297
+ "quote",
298
+ "unicode-ident",
299
+ ]
300
+
301
+ [[package]]
302
+ name = "target-lexicon"
303
+ version = "0.12.16"
304
+ source = "registry+https://github.com/rust-lang/crates.io-index"
305
+ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
306
+
307
+ [[package]]
308
+ name = "unicode-ident"
309
+ version = "1.0.24"
310
+ source = "registry+https://github.com/rust-lang/crates.io-index"
311
+ checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
312
+
313
+ [[package]]
314
+ name = "unindent"
315
+ version = "0.2.4"
316
+ source = "registry+https://github.com/rust-lang/crates.io-index"
317
+ checksum = "7264e107f553ccae879d21fbea1d6724ac785e8c3bfc762137959b5802826ef3"
318
+
319
+ [[package]]
320
+ name = "vectorbt-rust"
321
+ version = "1.0.0"
322
+ dependencies = [
323
+ "ndarray",
324
+ "numpy",
325
+ "pyo3",
326
+ "rand",
327
+ "rand_chacha",
328
+ ]
329
+
330
+ [[package]]
331
+ name = "wasip2"
332
+ version = "1.0.3+wasi-0.2.9"
333
+ source = "registry+https://github.com/rust-lang/crates.io-index"
334
+ checksum = "20064672db26d7cdc89c7798c48a0fdfac8213434a1186e5ef29fd560ae223d6"
335
+ dependencies = [
336
+ "wit-bindgen",
337
+ ]
338
+
339
+ [[package]]
340
+ name = "wit-bindgen"
341
+ version = "0.57.1"
342
+ source = "registry+https://github.com/rust-lang/crates.io-index"
343
+ checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e"
344
+
345
+ [[package]]
346
+ name = "zerocopy"
347
+ version = "0.8.48"
348
+ source = "registry+https://github.com/rust-lang/crates.io-index"
349
+ checksum = "eed437bf9d6692032087e337407a86f04cd8d6a16a37199ed57949d415bd68e9"
350
+ dependencies = [
351
+ "zerocopy-derive",
352
+ ]
353
+
354
+ [[package]]
355
+ name = "zerocopy-derive"
356
+ version = "0.8.48"
357
+ source = "registry+https://github.com/rust-lang/crates.io-index"
358
+ checksum = "70e3cd084b1788766f53af483dd21f93881ff30d7320490ec3ef7526d203bad4"
359
+ dependencies = [
360
+ "proc-macro2",
361
+ "quote",
362
+ "syn",
363
+ ]
@@ -0,0 +1,24 @@
1
+ [package]
2
+ name = "vectorbt-rust"
3
+ version = "1.0.0"
4
+ edition = "2021"
5
+ description = "Rust-accelerated kernels for vectorbt"
6
+ license = "Apache-2.0 WITH Commons-Clause-1.0"
7
+ readme = "README.md"
8
+
9
+ [lib]
10
+ name = "vectorbt_rust"
11
+ crate-type = ["cdylib"]
12
+
13
+ [dependencies]
14
+ pyo3 = { version = "0.22", features = ["extension-module"] }
15
+ numpy = "0.22"
16
+ ndarray = "0.16"
17
+ rand = "0.9"
18
+ rand_chacha = "0.9"
19
+
20
+ [profile.release]
21
+ lto = true
22
+ codegen-units = 1
23
+ opt-level = 3
24
+ strip = true
@@ -0,0 +1,22 @@
1
+ Metadata-Version: 2.4
2
+ Name: vectorbt-rust
3
+ Version: 1.0.0
4
+ Classifier: Development Status :: 3 - Alpha
5
+ Classifier: Intended Audience :: Developers
6
+ Classifier: Intended Audience :: Financial and Insurance Industry
7
+ Classifier: Programming Language :: Python :: 3.10
8
+ Classifier: Programming Language :: Python :: 3.11
9
+ Classifier: Programming Language :: Python :: 3.12
10
+ Classifier: Programming Language :: Python :: 3.13
11
+ Classifier: Programming Language :: Rust
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Topic :: Software Development
15
+ Classifier: Topic :: Office/Business :: Financial
16
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
17
+ Requires-Dist: numpy>=1.23
18
+ Summary: Rust-accelerated kernels for vectorbt
19
+ Author-email: Oleg Polakow <olegpolakow@vectorbt.pro>
20
+ License: Apache-2.0 WITH Commons-Clause-1.0
21
+ Requires-Python: >=3.10
22
+ Project-URL: Homepage, https://github.com/polakowo/vectorbt
@@ -0,0 +1,133 @@
1
+ # Rust engine
2
+
3
+ This directory contains the optional Rust engine for vectorbt. It builds the
4
+ `vectorbt-rust` Python extension package, exposed to Python as `vectorbt_rust`.
5
+
6
+ Rust is an acceleration engine. The canonical semantics still live in the
7
+ Numba implementations under `vectorbt/<subpackage>/nb.py`; Rust kernels are
8
+ called through engine-neutral dispatch wrappers under
9
+ `vectorbt/<subpackage>/dispatch.py`.
10
+
11
+ > [!NOTE]
12
+ > Most users should not import `vectorbt_rust` directly. Prefer vectorbt's public
13
+ > APIs and pass `engine="rust"` or set the global engine.
14
+
15
+ ## Installation
16
+
17
+ Install the Rust extension together with vectorbt:
18
+
19
+ ```bash
20
+ pip install "vectorbt[rust]"
21
+ ```
22
+
23
+ Or install the Rust extension package directly:
24
+
25
+ ```bash
26
+ pip install vectorbt-rust
27
+ ```
28
+
29
+ `vectorbt-rust` must be version-compatible with `vectorbt`. The engine resolver
30
+ compares the major/minor version prefix and treats mismatches as unavailable.
31
+
32
+ ### Building from source
33
+
34
+ From the repository root:
35
+
36
+ ```bash
37
+ python -m pip install -U pip maturin
38
+ python -m pip install -e ".[test]"
39
+ python -m maturin develop --manifest-path rust/Cargo.toml --release
40
+ ```
41
+
42
+ You can also build from inside this directory:
43
+
44
+ ```bash
45
+ cd rust
46
+ python -m maturin develop --release
47
+ ```
48
+
49
+ The release profile enables LTO, one codegen unit, `opt-level = 3`, and symbol
50
+ stripping. Use release builds for benchmarks; debug builds are not representative.
51
+
52
+ ## Usage
53
+
54
+ The shared resolver lives in `vectorbt/_engine.py`.
55
+
56
+ Per call:
57
+
58
+ ```python
59
+ import vectorbt as vbt
60
+
61
+ out = vbt.MA.run(close, window=20, engine="rust")
62
+ ```
63
+
64
+ Globally:
65
+
66
+ ```python
67
+ import vectorbt as vbt
68
+
69
+ vbt.settings["engine"] = "rust"
70
+ ```
71
+
72
+ Supported engine values:
73
+
74
+ - `auto`: Use Rust when it is installed, version-compatible, and the specific
75
+ call is supported; otherwise fall back to Numba.
76
+ - `numba`: Force the Numba implementation.
77
+ - `rust`: Force Rust and raise an actionable error if Rust is unavailable or the
78
+ call is unsupported.
79
+
80
+ Randomized functions are special: `auto` keeps using Numba to preserve legacy
81
+ NumPy/Numba random streams. Use `engine="rust"` explicitly when you want the
82
+ Rust random implementation.
83
+
84
+ ## Compatibility
85
+
86
+ The current Rust engine targets NumPy arrays and deterministic, array-oriented
87
+ kernels. Some public Python APIs still intentionally resolve to Numba when Rust
88
+ cannot preserve behavior, such as callback-accepting functions or unsupported
89
+ input combinations.
90
+
91
+ ## Testing
92
+
93
+ Run the engine-focused tests from the repository root:
94
+
95
+ ```bash
96
+ pytest tests/test_engine.py
97
+ ```
98
+
99
+ Run the full test suite:
100
+
101
+ ```bash
102
+ pytest
103
+ ```
104
+
105
+ Tests that require Rust are skipped when `vectorbt-rust` is not installed or not
106
+ version-compatible. To force those paths locally, install the extension with
107
+ `maturin develop` first.
108
+
109
+ ## Benchmarks
110
+
111
+ The benchmark scripts live in [benchmarks](../benchmarks).
112
+
113
+ Generate markdown benchmark matrices:
114
+
115
+ ```bash
116
+ python benchmarks/bench_matrix.py
117
+ ```
118
+
119
+ Use release builds for any benchmark numbers you intend to publish.
120
+
121
+ ## New kernels
122
+
123
+ New Rust kernels should follow this process:
124
+
125
+ 1. Treat Numba as the reference.
126
+ 2. Implement the Rust kernel with the same argument order and return shape.
127
+ 3. Register the PyO3 function in the Rust submodule and wire new submodules in `src/lib.rs`.
128
+ 4. Add or update the dispatch wrapper.
129
+ 5. Add parity, fallback, explicit-error, and layout-sensitive tests.
130
+ 6. Add benchmark cases once parity is stable.
131
+
132
+ Keep changes narrow and mechanical. Do not import Rust from `nb.py`, and do not
133
+ make public callers import `vectorbt_rust` directly.
@@ -0,0 +1,36 @@
1
+ [build-system]
2
+ requires = ["maturin>=1.7,<2.0"]
3
+ build-backend = "maturin"
4
+
5
+ [project]
6
+ name = "vectorbt-rust"
7
+ version = "1.0.0"
8
+ description = "Rust-accelerated kernels for vectorbt"
9
+ license = {text = "Apache-2.0 WITH Commons-Clause-1.0"}
10
+ authors = [
11
+ {name = "Oleg Polakow", email = "olegpolakow@vectorbt.pro"}
12
+ ]
13
+ requires-python = ">=3.10"
14
+ classifiers = [
15
+ "Development Status :: 3 - Alpha",
16
+ "Intended Audience :: Developers",
17
+ "Intended Audience :: Financial and Insurance Industry",
18
+ "Programming Language :: Python :: 3.10",
19
+ "Programming Language :: Python :: 3.11",
20
+ "Programming Language :: Python :: 3.12",
21
+ "Programming Language :: Python :: 3.13",
22
+ "Programming Language :: Rust",
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 = ["numpy>=1.23"]
30
+
31
+ [project.urls]
32
+ Homepage = "https://github.com/polakowo/vectorbt"
33
+
34
+ [tool.maturin]
35
+ features = ["pyo3/extension-module"]
36
+ module-name = "vectorbt_rust"
@@ -0,0 +1 @@
1
+ max_width = 120