-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathpyproject.toml
More file actions
253 lines (231 loc) · 9.35 KB
/
pyproject.toml
File metadata and controls
253 lines (231 loc) · 9.35 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
[build-system]
requires = ["setuptools>=68", "wheel"]
build-backend = "setuptools.build_meta"
[project]
name = "quant-platform"
version = "0.1.0"
description = "Professional IBKR cash-account quant platform with six bounded service packages (five trading services plus governance)"
readme = "README.md"
requires-python = ">=3.11"
license = { text = "Proprietary" }
dependencies = [
# Data
"pandas>=2.2,<3",
"pyarrow>=15.0,<20",
"numpy>=1.26,<3",
# Database
"psycopg[binary]>=3.1,<4",
"sqlalchemy>=2.0,<3",
"alembic>=1.13,<2",
# Redis
"redis>=5.0,<6",
# Config / validation (IO boundary only)
"pydantic>=2.6,<3",
"pydantic-settings>=2.2,<3",
# Async / scheduling
"anyio>=4.3,<4.13",
# Observability
"structlog>=24.1,<26",
"prometheus-client>=0.20,<1",
# Utilities
"tenacity>=8.2,<10",
"psutil>=5.9,<8",
"python-dateutil>=2.9,<3",
"exchange-calendars>=4.5,<5",
"httpx>=0.27,<0.28",
# LLM text feature extraction (Phase 5)
"anthropic>=0.40,<1",
]
[project.optional-dependencies]
# ibapi must be installed manually from the IBKR TWS API download (not on PyPI).
# Download from https://interactivebrokers.github.io/ and run:
# pip install <path-to-TWS-API>/source/pythonclient
broker = []
api = [
"fastapi>=0.111,<0.136",
"starlette>=0.37.2,<0.47",
"uvicorn[standard]>=0.29,<1",
]
# Vectorized backtesting engine (heavy; not required for live/paper trading)
backtest = ["vectorbt>=0.25"]
# scikit-learn powers the ``learned-representations-v1`` feature family
# (PCA + StandardScaler in ``research/features/learned/trainer.py``). The
# trainer lazy-imports it and raises a helpful ImportError when missing,
# so a deployment that doesn't use Arms C/D/E (latest-stack) or any
# downstream learned-feature path can skip this extra.
ml = ["xgboost>=3,<4", "scikit-learn>=1.4,<3"]
# PyTorch powers the GRU sequence ranker (``campaigns/models/sequence.py``,
# Arm N of the latest-stack backtest). The model lazy-imports torch and raises
# a helpful ImportError when missing, so any deployment not running Arm N can
# skip this extra. NOTE: PyPI provides only the CPU wheel; GPU on Windows needs
# the dedicated PyTorch CUDA index, e.g. for Blackwell (RTX 50xx):
# pip install torch --index-url https://download.pytorch.org/whl/cu128
# This is a documented manual step (same spirit as the broker/ibapi extra); the
# pin here only guarantees the CPU build resolves from PyPI.
dl = ["torch>=2.2,<3"]
observability = ["sentry-sdk>=2,<3"]
dev = [
"pytest>=8.1,<10",
"pytest-asyncio>=0.23,<1",
"pytest-cov>=5.0,<7",
"mypy>=1.9,<2",
"ruff>=0.4,<1",
"pre-commit>=3.7,<5",
"factory-boy>=3.3,<4",
"freezegun>=1.4,<2",
]
[project.scripts]
quant-platform = "quant_platform.__main__:main"
[tool.setuptools.packages.find]
where = ["src"]
[tool.setuptools.package-data]
"quant_platform.infrastructure.postgres" = ["schema_history.sql"]
[tool.mypy]
python_version = "3.11"
strict = true
ignore_missing_imports = true
warn_return_any = true
warn_unused_ignores = false
exclude = ["tests/"]
disable_error_code = [
# Existing source type debt; CI still runs mypy, but these categories need
# dedicated type-hardening passes before strict mode can be fully enforced.
"import-not-found",
"import-untyped",
]
# ---- Type hardening per package -----------------------------------------------
# These packages are the highest-leverage boundaries (domain models, contracts,
# governance gates). We re-enable the disabled error codes here so regressions
# at these layers are caught in CI without flipping repo-wide strictness. Other
# packages remain on the broader debt list above and will be paid down in
# follow-up sprints.
[[tool.mypy.overrides]]
module = [
"quant_platform.application.*",
"quant_platform.core.*",
"quant_platform.services.governance_service.*",
]
disable_error_code = [
"import-not-found",
"import-untyped",
]
# ---- Type hardening: execution_service + portfolio_service --------------------
# These two packages handle live money movement. Re-enable the highest-value
# error codes (missing annotations, wrong return types, argument mismatches)
# while keeping third-party stub gaps suppressed. Fix any errors revealed
# before expanding this list further.
[[tool.mypy.overrides]]
module = [
"quant_platform.services.execution_service.*",
"quant_platform.services.portfolio_service.*",
]
disable_error_code = [
"import-not-found",
"import-untyped",
]
[tool.ruff]
line-length = 100
target-version = "py311"
src = ["src"]
[tool.ruff.lint.isort]
known-first-party = ["quant_platform"]
[tool.ruff.lint]
select = ["E", "F", "I", "N", "UP", "ANN", "B", "SIM", "TCH", "S"]
ignore = [
]
[tool.ruff.lint.per-file-ignores]
# Stage 1 of the lint debt burn-down: enforce unused locals in production code
# while leaving existing test fixtures to be cleaned up incrementally.
"tests/**/*.py" = [
"B007",
"B905",
"E402",
"E501",
"F841",
"S101",
"S104",
"S105",
"S106",
"S108",
"S110",
"S311",
"S607",
"N802",
"N803",
"N806",
"N815",
"ANN001",
"ANN003",
"ANN201",
"ANN202",
"ANN401",
]
# Dynamic framework/adapter boundaries that still need package-local annotation hardening.
"src/quant_platform/bootstrap/**/*.py" = ["ANN401"]
"src/quant_platform/cli/**/*.py" = ["ANN401"]
# Research composition package: relocated 1:1 from the bootstrap/** umbrella
# when bootstrap/research moved out to its own composition layer (F5).
"src/quant_platform/research/**/*.py" = ["ANN401"]
# Session runtime container: __getattr__/__init__(**kwargs) are inherently dynamic.
# Relocated 1:1 from the bootstrap/** umbrella when state.py moved to application/runtime.
"src/quant_platform/application/runtime/state.py" = ["ANN401"]
# Pydantic v2 resolves postponed model annotations at runtime for settings models.
"src/quant_platform/config_risk_execution/risk.py" = ["TC003"]
# Event serialization and FastAPI route registration resolve postponed annotations at runtime.
"src/quant_platform/core/events/*.py" = ["TC001", "TC003"]
"src/quant_platform/views/operator_api/routers/cash_orders_audit.py" = ["TC001", "TC003"]
"src/quant_platform/views/operator_api/routers/strategy_state.py" = ["TC003"]
# IBKR callback names are externally dictated by ibapi's EWrapper/EClient API.
"src/quant_platform/services/execution_service/ib_wrapper/*.py" = ["N802", "N803"]
# Trading outcome enum value, not a password or credential.
"src/quant_platform/services/portfolio_service/pretrade_gate.py" = ["S105"]
# The lint-debt ratchet shells out to git/Ruff with fixed argv and no shell.
"scripts/check_lint_debt.py" = ["S603"]
# Tooling and diagnostics use fixed argv with resolved executables and no shell.
"scripts/check_secrets.py" = ["S603"]
"scripts/check_type_debt.py" = ["S603"]
"src/quant_platform/services/research_service/boosting/device.py" = ["S603"]
"src/quant_platform/services/research_service/campaigns/evaluation/artifacts.py" = ["S603"]
# Deterministic research resampling/permutation RNGs, not security tokens.
"src/quant_platform/services/research_service/feature_quality/audit/calculations.py" = ["S311"]
"src/quant_platform/services/research_service/reports/statistics.py" = ["S311"]
[tool.pytest.ini_options]
testpaths = ["tests"]
asyncio_mode = "auto"
markers = [
"ibapi: tests that require a live IB Gateway connection (opt-in via live_broker CI job)",
"integration_durable: tests that require real Postgres + Redis services (CI job integration_durable)",
"industrial_backtest: vectorbt-backed intraday/golden production backtest hardening tests",
"ibapi_orders: IBGateway tests that place real paper orders (QP_LIVE_IBKR_ALLOW_PAPER_ORDERS=1 required)",
"e2e: end-to-end tests requiring IBGateway + Postgres + Redis together",
"gpu: tests that require a CUDA-capable GPU (skipped automatically when none is detected)",
]
[tool.coverage.run]
branch = true
source = ["src/quant_platform"]
omit = [
"src/quant_platform/alembic/*",
# Offline coverage ratchet excludes operator/CLI wrappers and durable-only
# adapters that are exercised by separate integration/live gates.
"src/quant_platform/__main__.py",
"src/quant_platform/infrastructure/multi_engine_governance.py",
"src/quant_platform/infrastructure/postgres_feature_repository.py",
"src/quant_platform/infrastructure/postgres_model_registry.py",
"src/quant_platform/infrastructure/postgres_repositories.py",
"src/quant_platform/infrastructure/signal_contributions.py",
"src/quant_platform/services/data_service/maintenance_supervisor.py",
"src/quant_platform/services/data_service/tiingo_bar_fetcher.py",
"src/quant_platform/services/data_service/universe_manager.py",
"src/quant_platform/services/execution_service/client_portal_gateway.py",
"src/quant_platform/services/execution_service/pending_settlement_store.py",
"src/quant_platform/services/governance_service/text_gate.py",
"src/quant_platform/services/research_service/modeling/registry/cli.py",
# Requires the [backtest] optional extra (vectorbt); skipped in standard CI
"src/quant_platform/services/research_service/backtesting/vectorbt/vectorbt_engine.py",
]
[tool.coverage.report]
show_missing = true
skip_covered = false
fail_under = 75
# Higher bar for the core domain / risk / execution paths.
# Enforced via pytest --cov-fail-under in CI; this section documents intent.