fa-quant 1.2.1__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 (107) hide show
  1. fa_quant-1.2.1/.gitignore +225 -0
  2. fa_quant-1.2.1/CHANGELOG.md +149 -0
  3. fa_quant-1.2.1/LICENSE +21 -0
  4. fa_quant-1.2.1/PKG-INFO +236 -0
  5. fa_quant-1.2.1/README.md +177 -0
  6. fa_quant-1.2.1/agents/equity/daily_investment_system/factor_scoring.py +175 -0
  7. fa_quant-1.2.1/agents/equity/daily_investment_system/settlement_ledger.py +1222 -0
  8. fa_quant-1.2.1/pyproject.toml +138 -0
  9. fa_quant-1.2.1/src/financial_agent/__init__.py +1 -0
  10. fa_quant-1.2.1/src/financial_agent/agents/__init__.py +0 -0
  11. fa_quant-1.2.1/src/financial_agent/agents/claude/__init__.py +0 -0
  12. fa_quant-1.2.1/src/financial_agent/agents/gpt/__init__.py +0 -0
  13. fa_quant-1.2.1/src/financial_agent/agents/grok/__init__.py +0 -0
  14. fa_quant-1.2.1/src/financial_agent/dl/__init__.py +0 -0
  15. fa_quant-1.2.1/src/financial_agent/dl/models/__init__.py +0 -0
  16. fa_quant-1.2.1/src/financial_agent/dl/models/baseline_model.py +23 -0
  17. fa_quant-1.2.1/src/financial_agent/dl/preprocessing/__init__.py +0 -0
  18. fa_quant-1.2.1/src/financial_agent/dl/preprocessing/data_windowing.py +135 -0
  19. fa_quant-1.2.1/src/financial_agent/harness/__init__.py +73 -0
  20. fa_quant-1.2.1/src/financial_agent/harness/__main__.py +430 -0
  21. fa_quant-1.2.1/src/financial_agent/harness/audit.py +393 -0
  22. fa_quant-1.2.1/src/financial_agent/harness/equity_policy.toml +179 -0
  23. fa_quant-1.2.1/src/financial_agent/harness/fingerprint.py +55 -0
  24. fa_quant-1.2.1/src/financial_agent/harness/gates.py +522 -0
  25. fa_quant-1.2.1/src/financial_agent/harness/handlers.py +77 -0
  26. fa_quant-1.2.1/src/financial_agent/harness/helpers.py +47 -0
  27. fa_quant-1.2.1/src/financial_agent/harness/kernels.py +696 -0
  28. fa_quant-1.2.1/src/financial_agent/harness/ledger.py +325 -0
  29. fa_quant-1.2.1/src/financial_agent/harness/lifecycle.py +127 -0
  30. fa_quant-1.2.1/src/financial_agent/harness/manifest.py +113 -0
  31. fa_quant-1.2.1/src/financial_agent/harness/market_calendar.py +50 -0
  32. fa_quant-1.2.1/src/financial_agent/harness/mcp.py +505 -0
  33. fa_quant-1.2.1/src/financial_agent/harness/policy.py +248 -0
  34. fa_quant-1.2.1/src/financial_agent/harness/runner.py +275 -0
  35. fa_quant-1.2.1/src/financial_agent/harness/schema.py +451 -0
  36. fa_quant-1.2.1/src/financial_agent/harness/scoring.py +363 -0
  37. fa_quant-1.2.1/src/financial_agent/harness/skills.py +458 -0
  38. fa_quant-1.2.1/src/financial_agent/quant/__init__.py +1 -0
  39. fa_quant-1.2.1/src/financial_agent/quant/__main__.py +506 -0
  40. fa_quant-1.2.1/src/financial_agent/quant/backtest/__init__.py +16 -0
  41. fa_quant-1.2.1/src/financial_agent/quant/backtest/config.py +74 -0
  42. fa_quant-1.2.1/src/financial_agent/quant/backtest/costs.py +62 -0
  43. fa_quant-1.2.1/src/financial_agent/quant/backtest/engine.py +248 -0
  44. fa_quant-1.2.1/src/financial_agent/quant/backtest/metrics.py +102 -0
  45. fa_quant-1.2.1/src/financial_agent/quant/backtest/result.py +51 -0
  46. fa_quant-1.2.1/src/financial_agent/quant/data/__init__.py +21 -0
  47. fa_quant-1.2.1/src/financial_agent/quant/data/bars.py +103 -0
  48. fa_quant-1.2.1/src/financial_agent/quant/data/cache.py +168 -0
  49. fa_quant-1.2.1/src/financial_agent/quant/data/providers.py +138 -0
  50. fa_quant-1.2.1/src/financial_agent/quant/data/quality.py +104 -0
  51. fa_quant-1.2.1/src/financial_agent/quant/data/synthetic.py +67 -0
  52. fa_quant-1.2.1/src/financial_agent/quant/execution/__init__.py +24 -0
  53. fa_quant-1.2.1/src/financial_agent/quant/execution/alpaca.py +293 -0
  54. fa_quant-1.2.1/src/financial_agent/quant/execution/broker.py +98 -0
  55. fa_quant-1.2.1/src/financial_agent/quant/execution/ibkr.py +634 -0
  56. fa_quant-1.2.1/src/financial_agent/quant/execution/journal.py +139 -0
  57. fa_quant-1.2.1/src/financial_agent/quant/execution/paper.py +254 -0
  58. fa_quant-1.2.1/src/financial_agent/quant/execution/reconcile.py +35 -0
  59. fa_quant-1.2.1/src/financial_agent/quant/mcp.py +210 -0
  60. fa_quant-1.2.1/src/financial_agent/quant/portfolio.py +56 -0
  61. fa_quant-1.2.1/src/financial_agent/quant/quant_policy.toml +40 -0
  62. fa_quant-1.2.1/src/financial_agent/quant/risk/__init__.py +21 -0
  63. fa_quant-1.2.1/src/financial_agent/quant/risk/killswitch.py +61 -0
  64. fa_quant-1.2.1/src/financial_agent/quant/risk/limits.py +109 -0
  65. fa_quant-1.2.1/src/financial_agent/quant/risk/orders.py +91 -0
  66. fa_quant-1.2.1/src/financial_agent/quant/risk/pretrade.py +157 -0
  67. fa_quant-1.2.1/src/financial_agent/quant/risk/state.py +86 -0
  68. fa_quant-1.2.1/src/financial_agent/quant/runner/__init__.py +20 -0
  69. fa_quant-1.2.1/src/financial_agent/quant/runner/config.py +254 -0
  70. fa_quant-1.2.1/src/financial_agent/quant/runner/promotion.py +277 -0
  71. fa_quant-1.2.1/src/financial_agent/quant/runner/report.py +231 -0
  72. fa_quant-1.2.1/src/financial_agent/quant/runner/session.py +705 -0
  73. fa_quant-1.2.1/src/financial_agent/quant/strategies/__init__.py +19 -0
  74. fa_quant-1.2.1/src/financial_agent/quant/strategies/base.py +44 -0
  75. fa_quant-1.2.1/src/financial_agent/quant/strategies/benchmarks.py +54 -0
  76. fa_quant-1.2.1/src/financial_agent/quant/strategies/momentum.py +80 -0
  77. fa_quant-1.2.1/src/financial_agent/quant/strategies/registry.py +65 -0
  78. fa_quant-1.2.1/src/financial_agent/quant/strategies/research.py +226 -0
  79. fa_quant-1.2.1/src/financial_agent/quant/strategies/trend.py +91 -0
  80. fa_quant-1.2.1/src/financial_agent/quant/validation/__init__.py +41 -0
  81. fa_quant-1.2.1/src/financial_agent/quant/validation/bootstrap.py +39 -0
  82. fa_quant-1.2.1/src/financial_agent/quant/validation/certificate.py +189 -0
  83. fa_quant-1.2.1/src/financial_agent/quant/validation/gate.py +304 -0
  84. fa_quant-1.2.1/src/financial_agent/quant/validation/overfitting.py +148 -0
  85. fa_quant-1.2.1/src/financial_agent/quant/validation/stress.py +33 -0
  86. fa_quant-1.2.1/src/financial_agent/quant/validation/walkforward.py +157 -0
  87. fa_quant-1.2.1/src/financial_agent/rl/__init__.py +13 -0
  88. fa_quant-1.2.1/src/financial_agent/rl/agent.py +112 -0
  89. fa_quant-1.2.1/src/financial_agent/rl/environment.py +177 -0
  90. fa_quant-1.2.1/src/financial_agent/rl/trainer.py +142 -0
  91. fa_quant-1.2.1/src/financial_agent/trading/__init__.py +0 -0
  92. fa_quant-1.2.1/src/financial_agent/trading/autotrain/__init__.py +0 -0
  93. fa_quant-1.2.1/src/financial_agent/trading/autotrain/training.py +92 -0
  94. fa_quant-1.2.1/src/financial_agent/trading/backtest.py +118 -0
  95. fa_quant-1.2.1/src/financial_agent/trading/config/__init__.py +0 -0
  96. fa_quant-1.2.1/src/financial_agent/trading/config/config.py +1587 -0
  97. fa_quant-1.2.1/src/financial_agent/trading/marketdata/__init__.py +0 -0
  98. fa_quant-1.2.1/src/financial_agent/trading/marketdata/yahoodownloader.py +99 -0
  99. fa_quant-1.2.1/src/financial_agent/trading/model/__init__.py +0 -0
  100. fa_quant-1.2.1/src/financial_agent/trading/model/models.py +466 -0
  101. fa_quant-1.2.1/src/financial_agent/trading/preprocessing/__init__.py +0 -0
  102. fa_quant-1.2.1/src/financial_agent/trading/preprocessing/data.py +32 -0
  103. fa_quant-1.2.1/src/financial_agent/trading/preprocessing/preprocessors.py +162 -0
  104. fa_quant-1.2.1/src/financial_agent/trading/utils/__init__.py +0 -0
  105. fa_quant-1.2.1/src/financial_agent/trading/utils/gpu_config.py +213 -0
  106. fa_quant-1.2.1/src/financial_agent/trading/utils/main.py +52 -0
  107. fa_quant-1.2.1/src/financial_agent/trading/utils/setup_gpu_for_notebooks.py +130 -0
@@ -0,0 +1,225 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+ #poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ #pdm.lock
116
+ #pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ #pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # SageMath parsed files
135
+ *.sage.py
136
+
137
+ # Environments
138
+ .env
139
+ .envrc
140
+ .venv
141
+ env/
142
+ venv/
143
+ ENV/
144
+ env.bak/
145
+ venv.bak/
146
+
147
+ # Spyder project settings
148
+ .spyderproject
149
+ .spyproject
150
+
151
+ # Rope project settings
152
+ .ropeproject
153
+
154
+ # mkdocs documentation
155
+ /site
156
+
157
+ # mypy
158
+ .mypy_cache/
159
+ .dmypy.json
160
+ dmypy.json
161
+
162
+ # Pyre type checker
163
+ .pyre/
164
+
165
+ # pytype static type analyzer
166
+ .pytype/
167
+
168
+ # Cython debug symbols
169
+ cython_debug/
170
+
171
+ # PyCharm
172
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
173
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
174
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
175
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
176
+ .idea/
177
+
178
+ # Abstra
179
+ # Abstra is an AI-powered process automation framework.
180
+ # Ignore directories containing user credentials, local state, and settings.
181
+ # Learn more at https://abstra.io/docs
182
+ .abstra/
183
+
184
+ # Visual Studio Code
185
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
186
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
187
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
188
+ # you could uncomment the following to ignore the entire vscode folder
189
+ # .vscode/
190
+
191
+ # Ruff stuff:
192
+ .ruff_cache/
193
+
194
+ # PyPI configuration file
195
+ .pypirc
196
+
197
+ # Cursor
198
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
199
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
200
+ # refer to https://docs.cursor.com/context/ignore-files
201
+ .cursorignore
202
+ .cursorindexingignore
203
+
204
+ # Marimo
205
+ marimo/_static/
206
+ marimo/_lsp/
207
+ __marimo__/
208
+
209
+ # macOS
210
+ .DS_Store
211
+
212
+ # Project-local artifacts
213
+ tensorboard_log/
214
+
215
+ # Equity-agent reproducible working data; keep durable reports in output/.
216
+ agents/equity/.work/
217
+
218
+ # Harness run locks (removed on exit; a leftover one marks a crashed run).
219
+ agents/equity/output/.locks/
220
+
221
+ # Harness run journals (one JSON per (model, date) run attempt).
222
+ agents/equity/output/.runs/
223
+
224
+ # Quant research downloads (never commit market data).
225
+ .quant-cache/
@@ -0,0 +1,149 @@
1
+ # Changelog
2
+
3
+ All notable changes are documented here, following [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
4
+ and [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
5
+
6
+ ## [Unreleased]
7
+
8
+ ## [1.2.1] - 2026-10-20
9
+
10
+ ### Added
11
+
12
+ - The Release workflow can publish to PyPI through trusted publishing once the
13
+ `PYPI_PUBLISH` repository variable is `true`. Manual dispatch rehearses the
14
+ upload on TestPyPI. Pull requests and releases run `twine check --strict`. See
15
+ `docs/releasing.md`.
16
+
17
+ ### Changed
18
+
19
+ - The distribution is renamed `fa-quant`, because `financial-agent` on PyPI is an
20
+ unrelated project. The `financial_agent` import package (declared as PEP 794
21
+ `import-names`) and the `fa-quant` command are unchanged. Certificates and MCP
22
+ report the `fa-quant` version. Run `uv sync` after pulling.
23
+ - Packaging uses the SPDX license expression `MIT`. The sdist holds only what
24
+ building the wheel needs (31.7 MB to 0.2 MB). The PyPI description links to the
25
+ tagged repository files.
26
+
27
+ ## [1.2.0] - 2026-10-19
28
+
29
+ ### Added
30
+
31
+ - `fa-quant status` shows live readiness for Alpaca and IBKR paper configs:
32
+ clean sessions, halts and breaks in the evidence window, mean and per-fill
33
+ slippage against the allowance, certificate verdict, identity match, age and
34
+ expiry, and every unmet reason. It reads only the journal and certificate,
35
+ makes no broker call and grants nothing.
36
+ - `deploy/quant/run-session.py`, a stdlib-only scheduler wrapper. It loads
37
+ credentials from a chmod 600 env file (refused when a symlink,
38
+ group/other-accessible or not user-owned), runs `fa-quant run --json`, passes
39
+ output and the exit code through (128 + N after signal N), and on a non-zero
40
+ exit posts one sanitized JSON alert (status, session, reasons) to
41
+ `FA_QUANT_ALERT_WEBHOOK` when set. The launchd, cron and systemd templates call
42
+ it; the launchd template gives a Pacific-host example (`Hour=5`, `Minute=45`)
43
+ and the `pmset` wake command.
44
+
45
+ ### Changed
46
+
47
+ - `live_readiness(config, *, now)` holds the certificate and paper-evidence
48
+ evaluation; `authorize_live` adds the `FA_QUANT_ALLOW_LIVE` opt-in and the
49
+ grant. Thresholds and reasons are unchanged.
50
+
51
+ ## [1.1.1] - 2026-10-19
52
+
53
+ ### Fixed
54
+
55
+ - Broker-backed (Alpaca, IBKR) sessions submit opening-auction orders only when
56
+ the New York date equals the session date and the time is before the packaged
57
+ 09:25 ET `[execution] opening_auction_cutoff`. The check runs before journaling
58
+ submission intents and before every submission, including interrupted-submission
59
+ recovery; otherwise the session halts with the observed time. Late or replayed
60
+ runs can no longer queue orders for a later auction. Local paper and the demo
61
+ are unchanged.
62
+ - `fa-quant run --today` defaults to the current New York date instead of the
63
+ host-local date.
64
+ - CHANGELOG link references cover every release.
65
+
66
+ ### Changed
67
+
68
+ - `run_session` accepts `now`, an injectable clock returning timezone-aware
69
+ datetimes. Adding the policy section changes `quant_policy.toml` bytes, so new
70
+ certificates record a different `policy_sha256`; thresholds are unchanged and
71
+ existing certificates still verify.
72
+
73
+ ## [1.1.0] - 2026-10-13
74
+
75
+ ### Added
76
+
77
+ - IBKR Client Portal Gateway execution with guarded paper/live accounts, USD
78
+ portfolio observation, whole-share opening-auction orders, contract resolution,
79
+ precaution allow-lists, order recovery and gateway operations guidance.
80
+
81
+ ### Changed
82
+
83
+ - Public broker `lookup(client_order_id)` supports runner recovery across adapters.
84
+ - Live evidence must come from the same broker as the live configuration;
85
+ local simulation never authorizes live execution.
86
+
87
+ ### Fixed
88
+
89
+ - Finalize broker-backed opening-auction intents after observing their auction
90
+ session, preventing vanished zero-fill or partial orders from halting later runs.
91
+ Reconciliation still halts on unreported fills.
92
+ - Validate IBKR account metadata once per adapter and cache authentication status
93
+ for 60 seconds, refreshing immediately after HTTP 401, to reduce gateway pacing
94
+ delays without bypassing live guards.
95
+
96
+ ## [1.0.1] - 2026-10-13
97
+
98
+ ### Fixed
99
+
100
+ - Wheel installations can run trading sessions and the offline demo outside a
101
+ source checkout without failing with `FileNotFoundError` for missing helper scripts.
102
+
103
+ ## [1.0.0] - 2026-10-13
104
+
105
+ ### Added
106
+
107
+ - Risk-managed systematic ETF platform with binding strategy/data/broker contracts
108
+ and research → certify → paper → live delivery plan (#91).
109
+ - Adjusted Yahoo/CSV data, incremental revision-aware cache, quality checks and
110
+ deterministic synthetic fixtures (#92).
111
+ - Cost-aware, next-bar portfolio backtesting, shared weight-to-share sizing,
112
+ trend/volatility targeting, dual momentum and fixed-weight benchmarks (#93).
113
+ - Tighten-only pre-trade limits, account loss/drawdown state and persistent
114
+ operator-released kill switch (#94).
115
+ - Embargoed walk-forward validation, DSR, CSCV/PBO diagnostics, bootstrap,
116
+ execution stress, policy gates and hashed certificates (#95).
117
+ - Dated research-forecast adapter and honest failing short-history evidence (#97).
118
+ - Persisted paper broker, guarded Alpaca REST execution, idempotent orders,
119
+ reconciliation and hash-chained audit journal (#98).
120
+ - Operator CLI, session runner, live authorization from certificate and clean
121
+ Alpaca-paper evidence, offline demo, paper-only MCP previews and deployment
122
+ templates (#99).
123
+ - Release documentation, real-data comparison with unchanged gate verdicts,
124
+ wheel installation smoke and tag-triggered release workflow.
125
+
126
+ ### Changed
127
+
128
+ - Core installation is separated from optional RL, deep-learning, notebook and
129
+ development stacks; NumPy/pandas pins remain unchanged (#96).
130
+ - Package metadata now describes the platform and uses the existing maintainer
131
+ identity. Version 1.0.0 is classified beta: live performance is unproven.
132
+ - CLI help describes every command/option; session reports retain every attempt
133
+ and show last planned targets on off-cadence days.
134
+ - MCP initialization reports the installed package version.
135
+
136
+ ### Fixed
137
+
138
+ - A single pre-registered parameter set can clear the promotion gate: CSCV now
139
+ computes its absolute OOS loss frequency instead of rejecting one-column input.
140
+ PBO and degradation slope remain not applicable; multi-variant calculations
141
+ and every promotion threshold are unchanged.
142
+
143
+ [Unreleased]: https://github.com/BichengWang/financial-agent/compare/v1.2.1...HEAD
144
+ [1.2.1]: https://github.com/BichengWang/financial-agent/compare/v1.2.0...v1.2.1
145
+ [1.2.0]: https://github.com/BichengWang/financial-agent/compare/v1.1.1...v1.2.0
146
+ [1.1.1]: https://github.com/BichengWang/financial-agent/compare/v1.1.0...v1.1.1
147
+ [1.1.0]: https://github.com/BichengWang/financial-agent/compare/v1.0.1...v1.1.0
148
+ [1.0.1]: https://github.com/BichengWang/financial-agent/compare/v1.0.0...v1.0.1
149
+ [1.0.0]: https://github.com/BichengWang/financial-agent/releases/tag/v1.0.0
fa_quant-1.2.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Kenneth
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,236 @@
1
+ Metadata-Version: 2.5
2
+ Name: fa-quant
3
+ Version: 1.2.1
4
+ Import-Name: financial_agent
5
+ Summary: Risk-managed systematic ETF trading, statistical validation, and financial research
6
+ Project-URL: Homepage, https://github.com/BichengWang/financial-agent
7
+ Project-URL: Repository, https://github.com/BichengWang/financial-agent
8
+ Project-URL: Documentation, https://github.com/BichengWang/financial-agent/tree/main/docs/quant
9
+ Project-URL: Issues, https://github.com/BichengWang/financial-agent/issues
10
+ Project-URL: Changelog, https://github.com/BichengWang/financial-agent/blob/main/CHANGELOG.md
11
+ Author-email: "Bicheng (Kenneth)" <31808103+BichengWang@users.noreply.github.com>
12
+ License-Expression: MIT
13
+ License-File: LICENSE
14
+ Keywords: backtesting,portfolio,reinforcement-learning,risk-management,systematic-trading
15
+ Classifier: Development Status :: 4 - Beta
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: Operating System :: POSIX
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Office/Business :: Financial :: Investment
21
+ Requires-Python: >=3.12
22
+ Requires-Dist: gymnasium
23
+ Requires-Dist: numpy<2.0,>=1.24.0
24
+ Requires-Dist: pandas<3,>=2.0
25
+ Requires-Dist: requests<3,>=2.32
26
+ Requires-Dist: yfinance
27
+ Provides-Extra: all
28
+ Requires-Dist: beautifulsoup4; extra == 'all'
29
+ Requires-Dist: ipython; extra == 'all'
30
+ Requires-Dist: keras-nightly; extra == 'all'
31
+ Requires-Dist: matplotlib; extra == 'all'
32
+ Requires-Dist: notebook; extra == 'all'
33
+ Requires-Dist: pyfolio-reloaded; extra == 'all'
34
+ Requires-Dist: scikit-learn; extra == 'all'
35
+ Requires-Dist: seaborn; extra == 'all'
36
+ Requires-Dist: stable-baselines3; extra == 'all'
37
+ Requires-Dist: stockstats; extra == 'all'
38
+ Requires-Dist: tensorflow; extra == 'all'
39
+ Provides-Extra: dev
40
+ Requires-Dist: black>=22.0.0; extra == 'dev'
41
+ Requires-Dist: flake8>=6.0.0; extra == 'dev'
42
+ Requires-Dist: mypy>=1.0.0; extra == 'dev'
43
+ Requires-Dist: pytest-cov; extra == 'dev'
44
+ Requires-Dist: pytest-custom-exit-code; extra == 'dev'
45
+ Requires-Dist: pytest>=7.0.0; extra == 'dev'
46
+ Provides-Extra: dl
47
+ Requires-Dist: ipython; extra == 'dl'
48
+ Requires-Dist: keras-nightly; extra == 'dl'
49
+ Requires-Dist: matplotlib; extra == 'dl'
50
+ Requires-Dist: scikit-learn; extra == 'dl'
51
+ Requires-Dist: seaborn; extra == 'dl'
52
+ Requires-Dist: tensorflow; extra == 'dl'
53
+ Provides-Extra: notebooks
54
+ Requires-Dist: ipython; extra == 'notebooks'
55
+ Requires-Dist: matplotlib; extra == 'notebooks'
56
+ Requires-Dist: notebook; extra == 'notebooks'
57
+ Requires-Dist: seaborn; extra == 'notebooks'
58
+ Provides-Extra: research
59
+ Requires-Dist: openpyxl<4,>=3.1; extra == 'research'
60
+ Provides-Extra: rl
61
+ Requires-Dist: beautifulsoup4; extra == 'rl'
62
+ Requires-Dist: matplotlib; extra == 'rl'
63
+ Requires-Dist: pyfolio-reloaded; extra == 'rl'
64
+ Requires-Dist: scikit-learn; extra == 'rl'
65
+ Requires-Dist: stable-baselines3; extra == 'rl'
66
+ Requires-Dist: stockstats; extra == 'rl'
67
+ Requires-Dist: tensorflow; extra == 'rl'
68
+ Description-Content-Type: text/markdown
69
+
70
+ # financial-agent
71
+
72
+ A Python platform for systematic ETF research, cost-aware portfolio backtesting,
73
+ statistical certification, paper trading and explicitly gated Alpaca and IBKR execution.
74
+ It also retains an equity-research harness and separate RL/deep-learning research
75
+ stacks. The platform is **beta**: live performance is unproven, and neither a
76
+ historical gate pass nor paper results guarantee profit.
77
+
78
+ ## Five-minute offline quickstart
79
+
80
+ Install [uv](https://docs.astral.sh/uv/getting-started/installation/); Python 3.12
81
+ is selected by `.python-version`. From the repository root:
82
+
83
+ ```sh
84
+ uv sync --locked
85
+ uv run fa-quant demo
86
+ uv run fa-quant --help
87
+ ```
88
+
89
+ The demo uses seeded synthetic data with a planted trend. It runs backtest,
90
+ validation/certificate creation, 25 local paper sessions and status without
91
+ network access after dependencies are installed. Its printed numbers demonstrate
92
+ software behavior, not market performance. To keep the artifacts, use a fresh
93
+ state directory:
94
+
95
+ ```sh
96
+ uv run fa-quant demo --sessions 25 --state-dir /tmp/fa-quant-demo-release
97
+ ```
98
+
99
+ Core dependencies include NumPy `<2`, pandas `>=2,<3`, yfinance, Gymnasium and
100
+ requests. Default development tools are installed by `uv sync`; optional `rl`,
101
+ `dl`, `notebooks` and `research` extras add the heavier research stacks. Full
102
+ release verification uses `uv sync --locked --all-extras`.
103
+
104
+ Once a release is published to PyPI, `pip install fa-quant` installs the
105
+ `fa-quant` command and the `financial_agent` import package. The PyPI project
106
+ `financial-agent` is unrelated. Python 3.12 is the tested version; on 3.13+ the
107
+ NumPy `<2` pin builds NumPy from source. Examples, docs and evidence stay in this
108
+ repository; see [releasing](https://github.com/BichengWang/financial-agent/blob/v1.2.1/docs/releasing.md).
109
+
110
+ ## Real-data research
111
+
112
+ The example uses SPY, QQQ, IWM, EFA, EEM, TLT, IEF, LQD, GLD, DBC and VNQ,
113
+ weekly next-open fills, whole shares and a 2% cash buffer. Downloads are cached
114
+ under gitignored `var/`. Use the latest completed session as the inclusive end:
115
+
116
+ ```sh
117
+ uv run fa-quant backtest --config examples/quant/paper.toml --end 2026-10-12 --json
118
+ uv run fa-quant validate --config examples/quant/paper.toml --end 2026-10-12 --json
119
+ uv run fa-quant certify --config examples/quant/paper.toml --end 2026-10-12 \
120
+ --output var/quant-paper/certificate.json
121
+ ```
122
+
123
+ `validate`/`certify` return 2 when any gate fails; failed certificates can be saved
124
+ but cannot authorize live trading. With `--config`, settings come from the TOML;
125
+ standalone strategy/provider/start flags do not override it. See
126
+ [strategy research](https://github.com/BichengWang/financial-agent/blob/v1.2.1/docs/quant/strategy-research.md) for grids and interpretation.
127
+
128
+ The [committed real-data evidence](https://github.com/BichengWang/financial-agent/blob/v1.2.1/reports/quant/2026-10-default-strategy-evidence.md)
129
+ uses the earliest common ETF date, **2006-02-06 through 2026-10-12**, unchanged
130
+ default costs and the disclosed four-variant trend grid. All four full-period
131
+ default comparisons are shown here:
132
+
133
+ | Strategy | CAGR | Net Sharpe | Max drawdown | Turnover/year |
134
+ |---|---:|---:|---:|---:|
135
+ | Trend vol target | 5.625% | 0.740 | 16.533% | 14.375× |
136
+ | Dual momentum | 11.100% | 0.754 | 26.397% | 10.550× |
137
+ | SPY buy-and-hold | 11.122% | 0.652 | 54.299% | 0.048× |
138
+ | 60/40 SPY/IEF | 8.212% | 0.785 | 31.979% | 0.206× |
139
+
140
+ Trend passes all eight historical checks: OOS Sharpe 0.729, DSR 0.996, OOS
141
+ maximum drawdown 17.114%. PBO 0.650 warns that in-sample parameter selection adds
142
+ no reliable value. Single-default dual momentum and 60/40 also pass all eight
143
+ statistical checks; SPY fails the OOS drawdown limit. For a single pre-registered
144
+ variant, CSCV computes absolute OOS loss frequency; PBO and degradation slope
145
+ are not applicable. Warmup/OOS windows differ; read the report for dates, exact
146
+ checks, costs, bootstrap intervals, stress results and data caveats. No parameters
147
+ or thresholds were tuned to pass. Statistical passes do not override execution
148
+ limits: default dual momentum's three slots allocate 33.3% each versus the 30%
149
+ per-name cap, and concentrated SPY/60-40 benchmarks also exceed runtime caps.
150
+
151
+ The dated equity `research_forecast` strategy also [fails its real-ledger gate](https://github.com/BichengWang/financial-agent/blob/v1.2.1/reports/quant/research-forecast-validation.md):
152
+ there is too little history to support promotion. This is the retained result
153
+ for the LLM research signal, not an implied trading edge.
154
+
155
+ ## Paper trading and live gate
156
+
157
+ Load Alpaca **paper** keys into the process environment as `APCA_API_KEY_ID` and
158
+ `APCA_API_SECRET_KEY`; keep them out of TOML, git and command history. With keys
159
+ loaded, preview and run before the opening auction (around 08:45 New York time):
160
+
161
+ ```sh
162
+ uv run fa-quant run --config examples/quant/paper.toml --dry-run
163
+ uv run fa-quant run --config examples/quant/paper.toml
164
+ uv run fa-quant status --config examples/quant/paper.toml
165
+ ```
166
+
167
+ IBKR uses the locally running **Client Portal Gateway**, with daily browser login.
168
+ Copy [ibkr-paper.toml](https://github.com/BichengWang/financial-agent/blob/v1.2.1/examples/quant/ibkr-paper.toml), set your USD paper account
169
+ ID (`DU…`/`DF…`) and gateway port, then use the same `fa-quant run` command.
170
+ TLS verification can be disabled only on loopback; remote gateways require a
171
+ trusted certificate or CA path. Order questions halt unless every message ID is
172
+ explicitly allowed. Follow the [gateway setup](https://github.com/BichengWang/financial-agent/blob/v1.2.1/docs/quant/operations.md#ibkr-client-portal-gateway).
173
+
174
+ The release verifies execution through local paper and fake Alpaca/IBKR transports;
175
+ a real credentialed paper run is still an owner step. A dry run suppresses new
176
+ orders but journals observations and can synchronize earlier fills.
177
+
178
+ Live needs `mode = "live"`, `FA_QUANT_ALLOW_LIVE=1`, a passing certificate no older
179
+ than 90 days matching the exact strategy/params, at least 20 distinct clean
180
+ paper sessions from the same broker (Alpaca or IBKR), no recent risk halts/reconciliation breaks, and observed
181
+ paper slippage within twice modeled allowance. Runtime risk limits cannot be
182
+ loosened by config. MCP exposes research and paper previews only. Read
183
+ [safety and go-live steps](https://github.com/BichengWang/financial-agent/blob/v1.2.1/docs/quant/safety.md) before changing mode, and
184
+ [operations](https://github.com/BichengWang/financial-agent/blob/v1.2.1/docs/quant/operations.md) for scheduling, kill/unkill and incidents.
185
+ Kill stops new submissions; it does not cancel orders or liquidate positions.
186
+
187
+ ## Research harness, equity workflow and RL
188
+
189
+ The [native ticker workflow](https://github.com/BichengWang/financial-agent/blob/v1.2.1/docs/research/README.md) combines sourced evidence,
190
+ Decimal arithmetic, optional earnings/DCF/comps models and structural audits;
191
+ [retained research](https://github.com/BichengWang/financial-agent/blob/v1.2.1/docs/research/index.md) remains provisional. The
192
+ [daily equity workflow](https://github.com/BichengWang/financial-agent/blob/v1.2.1/agents/equity/daily_investment_system/main.md) produces
193
+ dated source/prediction packages. The harness provides deterministic report
194
+ checks and ledger audits, not autonomous completion of every prompt stage:
195
+
196
+ ```sh
197
+ uv run python -m financial_agent.harness --help
198
+ uv run python -m financial_agent.harness audit --output-dir agents/equity/output
199
+ ```
200
+
201
+ Generic RL supplies tabular Q-learning, GridWorld, Gymnasium wrappers and bounded
202
+ training/evaluation loops. [Examples](https://github.com/BichengWang/financial-agent/blob/v1.2.1/example/rl/) demonstrate learning APIs;
203
+ [notebooks](https://github.com/BichengWang/financial-agent/blob/v1.2.1/notebooks/README.md) retain historical experiment outputs. Install
204
+ `--extra rl`, `--extra dl` or `--extra notebooks` as needed. The FinRL-derived
205
+ `trading/` and TensorFlow `dl/` stacks are experimental; they do not feed capital
206
+ unless adapted to `Strategy` and passed through the same gates. The historical
207
+ autotrain entrypoint has unresolved signature/name issues and is not turnkey.
208
+
209
+ ## Repository map
210
+
211
+ | Path | Purpose |
212
+ |---|---|
213
+ | [src/financial_agent/quant](https://github.com/BichengWang/financial-agent/blob/v1.2.1/src/financial_agent/quant/) | Data, strategies, backtest, validation, risk, execution, runner and CLI/MCP |
214
+ | [docs/quant](https://github.com/BichengWang/financial-agent/blob/v1.2.1/docs/quant/) | [Architecture](https://github.com/BichengWang/financial-agent/blob/v1.2.1/docs/quant/architecture.md), safety, operations, strategy guide |
215
+ | [examples/quant](https://github.com/BichengWang/financial-agent/blob/v1.2.1/examples/quant/) / [deploy/quant](https://github.com/BichengWang/financial-agent/blob/v1.2.1/deploy/quant/) | Paper TOML and cron/launchd/systemd templates |
216
+ | [reports/quant](https://github.com/BichengWang/financial-agent/blob/v1.2.1/reports/quant/) | Computed default and research-forecast evidence |
217
+ | [tests/quant](https://github.com/BichengWang/financial-agent/blob/v1.2.1/tests/quant/) | Deterministic offline regression coverage |
218
+ | [src/financial_agent/harness](https://github.com/BichengWang/financial-agent/blob/v1.2.1/src/financial_agent/harness/) | Equity schemas, gates, kernels and policy |
219
+ | [agents/equity](https://github.com/BichengWang/financial-agent/blob/v1.2.1/agents/equity/) / [skills](https://github.com/BichengWang/financial-agent/blob/v1.2.1/skills/) | Daily/native equity workflows and Turtle research |
220
+ | [src/financial_agent/rl](https://github.com/BichengWang/financial-agent/blob/v1.2.1/src/financial_agent/rl/) / [example/rl](https://github.com/BichengWang/financial-agent/blob/v1.2.1/example/rl/) | Generic RL APIs and examples |
221
+ | [src/financial_agent/trading](https://github.com/BichengWang/financial-agent/blob/v1.2.1/src/financial_agent/trading/) / [src/financial_agent/dl](https://github.com/BichengWang/financial-agent/blob/v1.2.1/src/financial_agent/dl/) | Financial RL and prediction research |
222
+ | [notebooks](https://github.com/BichengWang/financial-agent/blob/v1.2.1/notebooks/) / [archive](https://github.com/BichengWang/financial-agent/blob/v1.2.1/archive/) | Saved research outputs; avoid incidental reruns |
223
+
224
+ ## Limitations
225
+
226
+ Yahoo's retrospectively adjusted OHLCV can change and is not raw auction
227
+ execution data. The fixed ETF universe retains selection bias. Simulations omit
228
+ taxes, cash interest, capacity/market impact and exact live corporate-action
229
+ accounting. Statistics measure this historical sample, not future profitability.
230
+ The scheduled runner does not continuously monitor intraday loss or guarantee
231
+ fills; reference-price limits do not eliminate gap risk. State/journal hashes
232
+ are integrity checks, not signatures. The POSIX runner targets macOS/Linux.
233
+
234
+ ## License
235
+
236
+ [MIT](https://github.com/BichengWang/financial-agent/blob/v1.2.1/LICENSE). Software is provided as is, without warranty.