forked from nautechsystems/nautilus_trader
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpyproject.toml
More file actions
334 lines (311 loc) · 11.8 KB
/
pyproject.toml
File metadata and controls
334 lines (311 loc) · 11.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
[project]
name = "nautilus_trader"
version = "1.225.0"
description = "A high-performance algorithmic trading platform and event-driven backtester"
authors = [{ name = "Nautech Systems", email = "info@nautechsystems.io" }]
classifiers = [
"License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)",
"Operating System :: OS Independent",
"Development Status :: 4 - Beta",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Scientific/Engineering",
"Topic :: Office/Business :: Financial",
"Topic :: Office/Business :: Financial :: Investment",
"Intended Audience :: Developers",
"Intended Audience :: Financial and Insurance Industry",
"Intended Audience :: Science/Research",
]
license = { text = "LGPL-3.0-or-later" }
readme = "README.md"
requires-python = ">=3.12,<3.15"
dependencies = [
"click>=8.0.0,<9.0.0",
"fsspec>=2025.2.0,<=2026.1.0",
"msgspec>=0.20.0,<1.0.0",
"numpy>=1.26.4",
"pandas>=2.3.3,<3.0.0",
"portion>=2.6.1",
"pyarrow>=23.0.1",
"pytz>=2025.2.0",
"tqdm>=4.67.3,<5.0.0",
"uvloop==0.22.1,<1.0.0; sys_platform != \"win32\"", # Pinned to 0.22.1 for stability
]
[project.urls]
homepage = "https://nautilustrader.io"
repository = "https://github.com/nautechsystems/nautilus_trader"
docs = "https://nautilustrader.io/docs"
# For now we use the poetry build backend until uv supports custom build scripts
[build-system]
requires = [
"setuptools>=82",
"poetry-core==2.3.1", # Pinned to 2.3.1 for stability
"numpy>=1.26.4",
"cython==3.2.4", # Pinned to 3.2.4 for stability
]
build-backend = "poetry.core.masonry.api"
[tool.poetry]
include = [
# Rust source must be included in the source distributions
{ path = "crates/*", format = "sdist" },
{ path = "Cargo.lock", format = "sdist" },
{ path = "Cargo.toml", format = "sdist" },
{ path = ".cargo/*", format = "sdist" },
# Compiled extensions must be included in the wheel distributions
{ path = "nautilus_trader/**/*.so", format = "wheel" },
{ path = "nautilus_trader/**/*.pyd", format = "wheel" },
# Include the py.typed file for type checking support
{ path = "nautilus_trader/py.typed", format = "sdist" },
{ path = "nautilus_trader/py.typed", format = "wheel" },
# Include Python interface files for type checking support
{ path = "nautilus_trader/**/*.pyi", format = "sdist" },
{ path = "nautilus_trader/**/*.pyi", format = "wheel" },
]
[tool.poetry.build]
script = "build.py"
generate-setup-file = false
[project.optional-dependencies]
betfair = ["betfair-parser==0.19.1"] # Pinned to 0.19.1 for stability
ib = [
"defusedxml>=0.7.1,<1.0.0; python_version < '3.14'",
"nautilus-ibapi==10.43.2; python_version < '3.14'",
"protobuf==5.29.5; python_version < '3.14'", # Pinned to 5.29.5 (fixes GHSA-8qvm-5x2c-j2w7)
]
docker = ["docker>=7.1.0,<8.0.0"]
polymarket = ["py-clob-client>=0.34.6,<1.0.0"]
visualization = ["plotly>=6.3.1,<7.0.0"]
[dependency-groups]
dev = [
"cython==3.2.4", # Pinned to 3.2.4 for stability
"setuptools>=80",
"mypy==1.19.1,<2.0.0", # Pinned to 1.19.1 (keep in line with pre-commit)
"pandas-stubs>=2.3.3,<3.0.0",
"pre-commit>=4.5.0,<5.0.0",
"ruff==0.15.5", # Pinned to 0.15.5 (keep in line with pre-commit)
"types-pytz>=2025.2,<2026.0",
"types-toml>=0.10.2,<1.0.0",
]
test = [
"aiohttp>=3.13.3,<4.0.0",
"coverage>=7.13.4,<8.0.0",
"pytest>=7.4.4,<8.0.0", # Intentionally held at 7.x
"pytest-aiohttp>=1.1.0,<2.0.0",
"pytest-asyncio==0.23.8", # Pinned to 0.23.8 for stability
"pytest-benchmark==5.0.1", # Pinned to 5.0.1 due pytest 8.x requirement
"pytest-codspeed==4.3.0", # Pinned to 4.3.0 for stability
"pytest-cov==6.3.0", # Pinned to 6.3.0 due pytest 8.x requirement
"pytest-mock>=3.15.1,<4.0.0",
"pytest-rerunfailures>=16.1,<17.0.0",
"pytest-xdist[psutil]>=3.8.0,<4.0.0",
]
docs = [
"numpydoc>=1.10.0,<2.0.0",
"linkify-it-py>=2.1.0,<3.0.0",
"myst-parser>=5.0.0,<6.0.0",
"sphinx-comments>=0.0.3,<1.0.0",
"furo==2025.12.19", # Pinned to 2025.12.19 for stability
]
[tool.isort]
py_version = "312"
skip_glob = ["**/core/rust/*"]
line_length = 120
ensure_newline_before_comments = true
force_single_line = true
include_trailing_comma = true
lines_after_imports = 2
use_parentheses = true
filter_files = true
[tool.docformatter]
wrap-summaries = 88
wrap-descriptions = 88
make-summary-multi-line = true
pre-summary-new-line = true
blank = true
recursive = true
in-place = true
[tool.ruff]
target-version = "py312"
line-length = 100
exclude = [
".benchmarks",
".eggs",
".git",
".mypy_cache",
".pytest_cache",
".ruff_cache",
".venv",
"build",
"dist",
"venv",
]
[tool.ruff.lint]
select = [
"C4", # flake8-comprehensions
"E", # pycodestyle errors
"F", # pyflakes
"W", # pycodestyle warnings
"C90", # mccabe complexity
"D", # pydocstyle
"DTZ", # flake8-datetimez
"UP", # pyupgrade
"S", # flake8-bandit (security)
"T10", # flake8-debugger
"ICN", # flake8-import-conventions
"PIE", # flake8-pie
"PT", # flake8-pytest-style
"PYI", # flake8-pyi (stubs)
"Q", # flake8-quotes
"I", # isort
"RSE", # flake8-raise
"TID", # flake8-tidy-imports
"SIM", # flake8-simplify
"B", # flake8-bugbear
"PERF", # Perflint
"FURB", # refurb
"ISC", # flake8-implicit-str-concat
"FLY", # flynt
"LOG", # flake8-logging
"ASYNC", # flake8-async
# "ARG", # flake8-unused-arguments - 843 violations
# "ERA", # eradicate (commented code) - 1441 violations
"PD", # pandas-vet
"PGH", # pygrep-hooks
"PLE", # pylint errors
"PLW", # pylint warnings
"NPY", # NumPy-specific rules
"RUF", # Ruff-specific rules
]
ignore = [
"D100", # Missing docstring in public module **fix**
"D101",
"D102", # Missing docstring in public method **fix**
"D103", # Missing docstring in public function **fix**
"D104", # Missing docstring in public package **fix**
"D107",
"D105",
"D200", # One-line docstring should fit on one line with quotes (optional style)
"D203", # 1 blank line required before class docstring (optional style)
"D205", # 1 blank line required between summary line and description (optional style)
"D212", # Multi-line docstring summary should start at the first line (optional style)
"D400", # First line should end with a period (not always a first line)
"D413", # Missing blank line after last section ('Parameters')
"D415", # First line should end with a period, question mark, or exclamation point (not always a first line)
"D416", # Section name should end with a colon ('Warnings:', not 'Warnings') (incorrect?)
"E501", # Line too long (will lint separately)
"E741", # Ambiguous variable name (single char)
"FURB166", # int() on sliced str (explicit base is clearer than auto-detection)
"PERF401", # manual-list-comprehension (16 violations - fix incrementally)
"PERF402", # manual-list-copy (3 violations - fix incrementally)
"PT007", # pytest-parametrize-values-wrong-type (1621 violations - deferred)
"PT011", # Exception type too broad (needs to be fixed case-by-case)
"PT014", # Use list comprehensions (not always readable or appropriate)
"PT017", # pytest-assert-in-except (1 violation - fix later)
"PT028", # pytest-parameter-with-default-argument (4 violations - fix later)
"PYI021", # Docstrings should not be included in stubs (OK as this is the natural place for them)
"PGH003", # Blanket type-ignore (TODO: make these specific incrementally)
"PLE1205", # logging-too-many-args (false positive for custom Logger class)
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
"RUF059", # Unpacked variable is never used (can still be clearer than a discard in some cases)
"S101", # Use of assert detected (OK in test suite, production violations to fix incrementally)
"SIM108", # Use ternary operator instead of if-else-block (opinionated style)
"B017", # pytest.raises(Exception) is too broad (we need broad catches for now)
"B018", # Useless expression (OK in notebooks for displaying figures)
"B008", # Function call in default argument (OK for immutable objects like pd.Timedelta, Money)
"B024", # Abstract class without abstract methods (intentional for base class pattern)
"B904", # raise without from clause (fix later for better exception chaining)
"ASYNC109", # async-function-with-timeout (timeout params are a valid API pattern)
"ASYNC110", # async-busy-wait (refactoring to Event is non-trivial, current patterns work)
"PLW0602", # global-variable-not-assigned (intentional module-level caching pattern)
"PLW0603", # global-statement (intentional module-level caching pattern)
"PLW2901", # redefined-loop-name (intentional loop variable transformation pattern)
"PLW0108", # unnecessary-lambda (lambdas needed for deferred evaluation in tests)
"FURB110", # if-exp-instead-of-or-operator (ternary is often clearer than or)
"FURB171", # single-item-membership-test (intentional for clarity)
"UP042", # Class inherits from both str and Enum (StrEnum pattern used intentionally)
]
# Allow autofix for all enabled rules (when `--fix`) is provided
fixable = ["ALL"]
# E4 = import-related rules (E401: multiple imports on one line, E402: module level import not at top)
# E501 = line too long
# UP006 = Use list instead of List for type annotation (field name 'list' shadows built-in in Bybit schemas)
# UP035 = typing.List is deprecated (field name 'list' shadows built-in in Bybit schemas)
# These are ignored and linted separately
unfixable = ["E4", "E501", "UP006", "UP035"]
# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
[tool.ruff.lint.isort]
force-single-line = true
lines-after-imports = 2
split-on-trailing-comma = true
known-first-party = ["nautilus_trader"]
[tool.ruff.format]
# Inherits target-version, line-length, exclude from [tool.ruff]
docstring-code-format = true
[tool.ruff.lint.mccabe]
max-complexity = 10
[tool.ruff.lint.per-file-ignores]
"**/*.ipynb" = ["S101"] # Notebooks can use asserts for demonstrations
"build.py" = ["S603", "S607"] # Build script needs subprocess calls
"examples/**/*.py" = [
"DTZ",
"S101",
"S105",
"S106",
] # Examples can use naive datetimes, asserts, and mock credentials
"nautilus_trader/common/config.py" = [
"S105",
] # redacted_password variable is intentional
"nautilus_trader/adapters/betfair/**/*.py" = [
"S101",
] # Betfair adapter uses asserts for validation (for now)
"python/nautilus_trader/adapters/hyperliquid/__init__.py" = [
"PLE0604",
] # Dynamic __all__ extension from star import
"test_perf_logger.py" = ["S311"]
"tests/**/*.py" = [
"S101",
"S105",
"S106",
] # Tests can use asserts, mock credentials, and pickle
[tool.mypy]
python_version = "3.12"
disallow_incomplete_defs = true
explicit_package_bases = true
ignore_missing_imports = true
namespace_packages = true
strict_optional = true
warn_no_return = true
warn_unused_configs = true
warn_unused_ignores = true
mypy_path = ["."]
exclude = "(^python/examples/|^examples/)"
[[tool.mypy.overrides]]
strict_optional = false
module = [
"examples/*",
"nautilus_trader/adapters/betfair/*",
"nautilus_trader/adapters/binance/*",
"nautilus_trader/adapters/interactive_brokers/*",
"nautilus_trader/indicators/ta_lib/*",
]
[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = "-ra --new-first --failed-first --doctest-modules --doctest-glob=\"*.pyx\""
asyncio_mode = "strict"
asyncio_default_fixture_loop_scope = "session"
filterwarnings = ["ignore::UserWarning", "ignore::DeprecationWarning"]
[tool.coverage.run]
plugins = ["Cython.Coverage"]
source = ["nautilus_trader"]
omit = [
"nautilus_trader/adapters/*",
"nautilus_trader/examples/*",
"nautilus_trader/test_kit/*",
]
[tool.coverage.report]
fail_under = 0
show_missing = true