finqir 0.1.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.
Files changed (63) hide show
  1. finqir-0.1.0/LICENSE.txt +203 -0
  2. finqir-0.1.0/MANIFEST.in +9 -0
  3. finqir-0.1.0/PKG-INFO +157 -0
  4. finqir-0.1.0/README.md +94 -0
  5. finqir-0.1.0/finqir/VERSION.txt +1 -0
  6. finqir-0.1.0/finqir/__init__.py +53 -0
  7. finqir-0.1.0/finqir/applications/__init__.py +61 -0
  8. finqir-0.1.0/finqir/applications/estimation/__init__.py +26 -0
  9. finqir-0.1.0/finqir/applications/estimation/estimation_application.py +44 -0
  10. finqir-0.1.0/finqir/applications/estimation/european_call_delta.py +88 -0
  11. finqir-0.1.0/finqir/applications/estimation/european_call_pricing.py +93 -0
  12. finqir-0.1.0/finqir/applications/estimation/fixed_income_pricing.py +111 -0
  13. finqir-0.1.0/finqir/applications/optimization/__init__.py +19 -0
  14. finqir-0.1.0/finqir/applications/optimization/portfolio_diversification.py +141 -0
  15. finqir-0.1.0/finqir/applications/optimization/portfolio_optimization.py +239 -0
  16. finqir-0.1.0/finqir/circuit/__init__.py +24 -0
  17. finqir-0.1.0/finqir/circuit/library/__init__.py +58 -0
  18. finqir-0.1.0/finqir/circuit/library/payoff_functions/__init__.py +17 -0
  19. finqir-0.1.0/finqir/circuit/library/payoff_functions/european_call_delta_objective.py +58 -0
  20. finqir-0.1.0/finqir/circuit/library/payoff_functions/european_call_pricing_objective.py +67 -0
  21. finqir-0.1.0/finqir/circuit/library/payoff_functions/fixed_income_pricing_objective.py +135 -0
  22. finqir-0.1.0/finqir/circuit/library/probability_distributions/__init__.py +20 -0
  23. finqir-0.1.0/finqir/circuit/library/probability_distributions/gaussian_conditional_independence_model.py +96 -0
  24. finqir-0.1.0/finqir/circuit/library/probability_distributions/lognormal.py +190 -0
  25. finqir-0.1.0/finqir/circuit/library/probability_distributions/normal.py +273 -0
  26. finqir-0.1.0/finqir/circuit/library/probability_distributions/uniform.py +61 -0
  27. finqir-0.1.0/finqir/data_providers/__init__.py +71 -0
  28. finqir-0.1.0/finqir/data_providers/_base_data_provider.py +251 -0
  29. finqir-0.1.0/finqir/data_providers/data_on_demand_provider.py +124 -0
  30. finqir-0.1.0/finqir/data_providers/exchange_data_provider.py +132 -0
  31. finqir-0.1.0/finqir/data_providers/random_data_provider.py +88 -0
  32. finqir-0.1.0/finqir/data_providers/wikipedia_data_provider.py +116 -0
  33. finqir-0.1.0/finqir/data_providers/yahoo_data_provider.py +132 -0
  34. finqir-0.1.0/finqir/exceptions.py +19 -0
  35. finqir-0.1.0/finqir/py.typed +1 -0
  36. finqir-0.1.0/finqir/version.py +21 -0
  37. finqir-0.1.0/finqir.egg-info/PKG-INFO +157 -0
  38. finqir-0.1.0/finqir.egg-info/SOURCES.txt +61 -0
  39. finqir-0.1.0/finqir.egg-info/dependency_links.txt +1 -0
  40. finqir-0.1.0/finqir.egg-info/requires.txt +39 -0
  41. finqir-0.1.0/finqir.egg-info/top_level.txt +1 -0
  42. finqir-0.1.0/pyproject.toml +98 -0
  43. finqir-0.1.0/requirements.txt +12 -0
  44. finqir-0.1.0/setup.cfg +4 -0
  45. finqir-0.1.0/test/__init__.py +17 -0
  46. finqir-0.1.0/test/applications/__init__.py +11 -0
  47. finqir-0.1.0/test/applications/test_european_call_delta.py +47 -0
  48. finqir-0.1.0/test/applications/test_european_call_pricing.py +62 -0
  49. finqir-0.1.0/test/applications/test_fixed_income_pricing.py +73 -0
  50. finqir-0.1.0/test/applications/test_portfolio_diversification.py +143 -0
  51. finqir-0.1.0/test/applications/test_portfolio_optimization.py +176 -0
  52. finqir-0.1.0/test/circuit/__init__.py +11 -0
  53. finqir-0.1.0/test/circuit/test_european_call_delta_objective.py +101 -0
  54. finqir-0.1.0/test/circuit/test_european_call_pricing_objective.py +105 -0
  55. finqir-0.1.0/test/circuit/test_fixed_income_pricing_objective.py +98 -0
  56. finqir-0.1.0/test/circuit/test_probability_distributions.py +238 -0
  57. finqir-0.1.0/test/data_providers/__init__.py +11 -0
  58. finqir-0.1.0/test/data_providers/test_data_providers.py +236 -0
  59. finqir-0.1.0/test/finance_test_case.py +88 -0
  60. finqir-0.1.0/test/test_package_identity.py +51 -0
  61. finqir-0.1.0/test/test_readme_sample.py +50 -0
  62. finqir-0.1.0/test/test_tutorial_notebooks.py +42 -0
  63. finqir-0.1.0/test/test_verify_headers.py +61 -0
@@ -0,0 +1,203 @@
1
+ Copyright 2017 IBM and its contributors
2
+
3
+ Apache License
4
+ Version 2.0, January 2004
5
+ http://www.apache.org/licenses/
6
+
7
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
+
9
+ 1. Definitions.
10
+
11
+ "License" shall mean the terms and conditions for use, reproduction,
12
+ and distribution as defined by Sections 1 through 9 of this document.
13
+
14
+ "Licensor" shall mean the copyright owner or entity authorized by
15
+ the copyright owner that is granting the License.
16
+
17
+ "Legal Entity" shall mean the union of the acting entity and all
18
+ other entities that control, are controlled by, or are under common
19
+ control with that entity. For the purposes of this definition,
20
+ "control" means (i) the power, direct or indirect, to cause the
21
+ direction or management of such entity, whether by contract or
22
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
23
+ outstanding shares, or (iii) beneficial ownership of such entity.
24
+
25
+ "You" (or "Your") shall mean an individual or Legal Entity
26
+ exercising permissions granted by this License.
27
+
28
+ "Source" form shall mean the preferred form for making modifications,
29
+ including but not limited to software source code, documentation
30
+ source, and configuration files.
31
+
32
+ "Object" form shall mean any form resulting from mechanical
33
+ transformation or translation of a Source form, including but
34
+ not limited to compiled object code, generated documentation,
35
+ and conversions to other media types.
36
+
37
+ "Work" shall mean the work of authorship, whether in Source or
38
+ Object form, made available under the License, as indicated by a
39
+ copyright notice that is included in or attached to the work
40
+ (an example is provided in the Appendix below).
41
+
42
+ "Derivative Works" shall mean any work, whether in Source or Object
43
+ form, that is based on (or derived from) the Work and for which the
44
+ editorial revisions, annotations, elaborations, or other modifications
45
+ represent, as a whole, an original work of authorship. For the purposes
46
+ of this License, Derivative Works shall not include works that remain
47
+ separable from, or merely link (or bind by name) to the interfaces of,
48
+ the Work and Derivative Works thereof.
49
+
50
+ "Contribution" shall mean any work of authorship, including
51
+ the original version of the Work and any modifications or additions
52
+ to that Work or Derivative Works thereof, that is intentionally
53
+ submitted to Licensor for inclusion in the Work by the copyright owner
54
+ or by an individual or Legal Entity authorized to submit on behalf of
55
+ the copyright owner. For the purposes of this definition, "submitted"
56
+ means any form of electronic, verbal, or written communication sent
57
+ to the Licensor or its representatives, including but not limited to
58
+ communication on electronic mailing lists, source code control systems,
59
+ and issue tracking systems that are managed by, or on behalf of, the
60
+ Licensor for the purpose of discussing and improving the Work, but
61
+ excluding communication that is conspicuously marked or otherwise
62
+ designated in writing by the copyright owner as "Not a Contribution."
63
+
64
+ "Contributor" shall mean Licensor and any individual or Legal Entity
65
+ on behalf of whom a Contribution has been received by Licensor and
66
+ subsequently incorporated within the Work.
67
+
68
+ 2. Grant of Copyright License. Subject to the terms and conditions of
69
+ this License, each Contributor hereby grants to You a perpetual,
70
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
71
+ copyright license to reproduce, prepare Derivative Works of,
72
+ publicly display, publicly perform, sublicense, and distribute the
73
+ Work and such Derivative Works in Source or Object form.
74
+
75
+ 3. Grant of Patent License. Subject to the terms and conditions of
76
+ this License, each Contributor hereby grants to You a perpetual,
77
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
78
+ (except as stated in this section) patent license to make, have made,
79
+ use, offer to sell, sell, import, and otherwise transfer the Work,
80
+ where such license applies only to those patent claims licensable
81
+ by such Contributor that are necessarily infringed by their
82
+ Contribution(s) alone or by combination of their Contribution(s)
83
+ with the Work to which such Contribution(s) was submitted. If You
84
+ institute patent litigation against any entity (including a
85
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
86
+ or a Contribution incorporated within the Work constitutes direct
87
+ or contributory patent infringement, then any patent licenses
88
+ granted to You under this License for that Work shall terminate
89
+ as of the date such litigation is filed.
90
+
91
+ 4. Redistribution. You may reproduce and distribute copies of the
92
+ Work or Derivative Works thereof in any medium, with or without
93
+ modifications, and in Source or Object form, provided that You
94
+ meet the following conditions:
95
+
96
+ (a) You must give any other recipients of the Work or
97
+ Derivative Works a copy of this License; and
98
+
99
+ (b) You must cause any modified files to carry prominent notices
100
+ stating that You changed the files; and
101
+
102
+ (c) You must retain, in the Source form of any Derivative Works
103
+ that You distribute, all copyright, patent, trademark, and
104
+ attribution notices from the Source form of the Work,
105
+ excluding those notices that do not pertain to any part of
106
+ the Derivative Works; and
107
+
108
+ (d) If the Work includes a "NOTICE" text file as part of its
109
+ distribution, then any Derivative Works that You distribute must
110
+ include a readable copy of the attribution notices contained
111
+ within such NOTICE file, excluding those notices that do not
112
+ pertain to any part of the Derivative Works, in at least one
113
+ of the following places: within a NOTICE text file distributed
114
+ as part of the Derivative Works; within the Source form or
115
+ documentation, if provided along with the Derivative Works; or,
116
+ within a display generated by the Derivative Works, if and
117
+ wherever such third-party notices normally appear. The contents
118
+ of the NOTICE file are for informational purposes only and
119
+ do not modify the License. You may add Your own attribution
120
+ notices within Derivative Works that You distribute, alongside
121
+ or as an addendum to the NOTICE text from the Work, provided
122
+ that such additional attribution notices cannot be construed
123
+ as modifying the License.
124
+
125
+ You may add Your own copyright statement to Your modifications and
126
+ may provide additional or different license terms and conditions
127
+ for use, reproduction, or distribution of Your modifications, or
128
+ for any such Derivative Works as a whole, provided Your use,
129
+ reproduction, and distribution of the Work otherwise complies with
130
+ the conditions stated in this License.
131
+
132
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
133
+ any Contribution intentionally submitted for inclusion in the Work
134
+ by You to the Licensor shall be under the terms and conditions of
135
+ this License, without any additional terms or conditions.
136
+ Notwithstanding the above, nothing herein shall supersede or modify
137
+ the terms of any separate license agreement you may have executed
138
+ with Licensor regarding such Contributions.
139
+
140
+ 6. Trademarks. This License does not grant permission to use the trade
141
+ names, trademarks, service marks, or product names of the Licensor,
142
+ except as required for reasonable and customary use in describing the
143
+ origin of the Work and reproducing the content of the NOTICE file.
144
+
145
+ 7. Disclaimer of Warranty. Unless required by applicable law or
146
+ agreed to in writing, Licensor provides the Work (and each
147
+ Contributor provides its Contributions) on an "AS IS" BASIS,
148
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
149
+ implied, including, without limitation, any warranties or conditions
150
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
151
+ PARTICULAR PURPOSE. You are solely responsible for determining the
152
+ appropriateness of using or redistributing the Work and assume any
153
+ risks associated with Your exercise of permissions under this License.
154
+
155
+ 8. Limitation of Liability. In no event and under no legal theory,
156
+ whether in tort (including negligence), contract, or otherwise,
157
+ unless required by applicable law (such as deliberate and grossly
158
+ negligent acts) or agreed to in writing, shall any Contributor be
159
+ liable to You for damages, including any direct, indirect, special,
160
+ incidental, or consequential damages of any character arising as a
161
+ result of this License or out of the use or inability to use the
162
+ Work (including but not limited to damages for loss of goodwill,
163
+ work stoppage, computer failure or malfunction, or any and all
164
+ other commercial damages or losses), even if such Contributor
165
+ has been advised of the possibility of such damages.
166
+
167
+ 9. Accepting Warranty or Additional Liability. While redistributing
168
+ the Work or Derivative Works thereof, You may choose to offer,
169
+ and charge a fee for, acceptance of support, warranty, indemnity,
170
+ or other liability obligations and/or rights consistent with this
171
+ License. However, in accepting such obligations, You may act only
172
+ on Your own behalf and on Your sole responsibility, not on behalf
173
+ of any other Contributor, and only if You agree to indemnify,
174
+ defend, and hold each Contributor harmless for any liability
175
+ incurred by, or claims asserted against, such Contributor by reason
176
+ of your accepting any such warranty or additional liability.
177
+
178
+ END OF TERMS AND CONDITIONS
179
+
180
+ APPENDIX: How to apply the Apache License to your work.
181
+
182
+ To apply the Apache License to your work, attach the following
183
+ boilerplate notice, with the fields enclosed by brackets "[]"
184
+ replaced with your own identifying information. (Don't include
185
+ the brackets!) The text should be enclosed in the appropriate
186
+ comment syntax for the file format. We also recommend that a
187
+ file or class name and description of purpose be included on the
188
+ same "printed page" as the copyright notice for easier
189
+ identification within third-party archives.
190
+
191
+ Copyright 2017 IBM and its contributors.
192
+
193
+ Licensed under the Apache License, Version 2.0 (the "License");
194
+ you may not use this file except in compliance with the License.
195
+ You may obtain a copy of the License at
196
+
197
+ http://www.apache.org/licenses/LICENSE-2.0
198
+
199
+ Unless required by applicable law or agreed to in writing, software
200
+ distributed under the License is distributed on an "AS IS" BASIS,
201
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
202
+ See the License for the specific language governing permissions and
203
+ limitations under the License.
@@ -0,0 +1,9 @@
1
+ include LICENSE.txt
2
+ include requirements.txt
3
+ include finqir/py.typed
4
+ recursive-include finqir *.txt
5
+ graft test
6
+ prune docs
7
+ prune tools
8
+ prune tutorials
9
+ global-exclude *.py[co] .DS_Store
finqir-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,157 @@
1
+ Metadata-Version: 2.4
2
+ Name: finqir
3
+ Version: 0.1.0
4
+ Summary: Structured quantum-finance modeling and compilation for Qiskit
5
+ Author: FinQIR Contributors
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Documentation, https://bilgin-kocak.github.io/finqir/
8
+ Project-URL: Issues, https://github.com/bilgin-kocak/finqir/issues
9
+ Project-URL: Repository, https://github.com/bilgin-kocak/finqir
10
+ Keywords: finance,optimization,portfolio,qaoa,qiskit,quantum computing
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Financial and Insurance Industry
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Office/Business :: Financial :: Investment
22
+ Classifier: Topic :: Scientific/Engineering
23
+ Requires-Python: >=3.10
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE.txt
26
+ Requires-Dist: certifi
27
+ Requires-Dist: fastdtw>=0.3.4
28
+ Requires-Dist: nasdaq-data-link>=1.0.4
29
+ Requires-Dist: numpy>=1.26
30
+ Requires-Dist: pandas>=2.0
31
+ Requires-Dist: psutil>=5
32
+ Requires-Dist: qiskit<3,>=2.5.2
33
+ Requires-Dist: qiskit-algorithms<0.5,>=0.4.0
34
+ Requires-Dist: qiskit-optimization<0.8,>=0.7.0
35
+ Requires-Dist: scipy>=1.11
36
+ Requires-Dist: urllib3
37
+ Requires-Dist: yfinance>=0.2.66
38
+ Provides-Extra: test
39
+ Requires-Dist: coverage>=7; extra == "test"
40
+ Requires-Dist: ddt!=1.7.0,>=1.6; extra == "test"
41
+ Requires-Dist: qiskit-aer>=0.17; extra == "test"
42
+ Requires-Dist: stestr>=4; extra == "test"
43
+ Requires-Dist: tomli>=2; extra == "test"
44
+ Provides-Extra: dev
45
+ Requires-Dist: black[jupyter]>=24.10; extra == "dev"
46
+ Requires-Dist: build>=1.2; extra == "dev"
47
+ Requires-Dist: mypy>=1.11; extra == "dev"
48
+ Requires-Dist: pylint>=3.2; extra == "dev"
49
+ Requires-Dist: Sphinx>=7; extra == "dev"
50
+ Requires-Dist: twine>=6; extra == "dev"
51
+ Requires-Dist: types-certifi; extra == "dev"
52
+ Provides-Extra: docs
53
+ Requires-Dist: jupyter-sphinx; extra == "docs"
54
+ Requires-Dist: matplotlib>=3.8; extra == "docs"
55
+ Requires-Dist: nbsphinx; extra == "docs"
56
+ Requires-Dist: pylatexenc>=1.4; extra == "docs"
57
+ Requires-Dist: qiskit-sphinx-theme>=1.16; extra == "docs"
58
+ Requires-Dist: reno>=4; extra == "docs"
59
+ Requires-Dist: Sphinx>=7; extra == "docs"
60
+ Requires-Dist: sphinx-design>=0.6; extra == "docs"
61
+ Requires-Dist: sphinxcontrib-spelling; extra == "docs"
62
+ Dynamic: license-file
63
+
64
+ # FinQIR
65
+
66
+ **Financial Quantum Intermediate Representation**
67
+
68
+ FinQIR is an independent, Apache-2.0-licensed Python toolkit for structured
69
+ quantum-finance modeling, compilation, and optimization on Qiskit. It is built
70
+ for finance engineers who need recognizable financial concepts and quantum
71
+ engineers who need inspectable mappings, constraints, circuits, and results.
72
+
73
+ > [!IMPORTANT]
74
+ > FinQIR is an independent community project. It is not an IBM product and is
75
+ > not affiliated with or endorsed by IBM or the Qiskit project.
76
+
77
+ FinQIR begins with useful portfolio, pricing, probability-distribution, and
78
+ market-data components derived from the Apache-licensed Qiskit Finance project.
79
+ Its roadmap adds structured portfolio problems, traceable financial mappings,
80
+ finance-aware compilation passes, constraint-preserving QAOA, and reproducible
81
+ benchmarks.
82
+
83
+ ## Installation
84
+
85
+ After the first PyPI release, install FinQIR with:
86
+
87
+ ```bash
88
+ pip install finqir
89
+ ```
90
+
91
+ Until then, install the development version from source:
92
+
93
+ ```bash
94
+ git clone https://github.com/bilgin-kocak/finqir.git
95
+ cd finqir
96
+ python -m pip install -e ".[test,dev]"
97
+ ```
98
+
99
+ FinQIR 0.1 targets Python 3.10 or newer and Qiskit 2.5.2.
100
+
101
+ ## Example
102
+
103
+ ```python
104
+ import numpy as np
105
+
106
+ from finqir.applications.optimization import PortfolioOptimization
107
+
108
+ problem = PortfolioOptimization(
109
+ expected_returns=np.array([0.10, 0.08, 0.12]),
110
+ covariances=np.array(
111
+ [
112
+ [0.10, 0.02, 0.03],
113
+ [0.02, 0.08, 0.01],
114
+ [0.03, 0.01, 0.09],
115
+ ]
116
+ ),
117
+ risk_factor=0.5,
118
+ budget=2,
119
+ )
120
+
121
+ quadratic_program = problem.to_quadratic_program()
122
+ print(quadratic_program.prettyprint())
123
+ ```
124
+
125
+ ## Planned structured API
126
+
127
+ The design and implementation roadmap cover:
128
+
129
+ - `StructuredPortfolioProblem` with named financial constraints;
130
+ - binary, integer, unary, domain-wall, and fixed-cardinality mappings;
131
+ - finance-aware problem and circuit compilation passes;
132
+ - constraint-preserving QAOA mixers;
133
+ - conflict-graph portfolios and constrained MIS problems;
134
+ - multi-period rebalancing, risk, pricing, and benchmarking extensions.
135
+
136
+ These APIs are roadmap items and are not part of the initial package foundation.
137
+ See the [approved design](docs/superpowers/specs/2026-09-04-structured-quantum-finance-design.md)
138
+ and [implementation plan](docs/superpowers/plans/2026-09-04-structured-quantum-finance.md).
139
+
140
+ ## Development
141
+
142
+ ```bash
143
+ python -m pip install -e ".[test,dev]"
144
+ python -m unittest discover -s test -v
145
+ python -m build
146
+ python -m twine check dist/*
147
+ ```
148
+
149
+ ## Project history and license
150
+
151
+ FinQIR is an independent derivative of
152
+ [Qiskit Finance](https://github.com/qiskit-community/qiskit-finance). Existing
153
+ copyright notices are retained in derived files. New FinQIR work is released
154
+ under the same [Apache License 2.0](LICENSE.txt).
155
+
156
+ FinQIR is research software. It does not provide investment advice and must not
157
+ be treated as a guarantee of financial performance or quantum advantage.
finqir-0.1.0/README.md ADDED
@@ -0,0 +1,94 @@
1
+ # FinQIR
2
+
3
+ **Financial Quantum Intermediate Representation**
4
+
5
+ FinQIR is an independent, Apache-2.0-licensed Python toolkit for structured
6
+ quantum-finance modeling, compilation, and optimization on Qiskit. It is built
7
+ for finance engineers who need recognizable financial concepts and quantum
8
+ engineers who need inspectable mappings, constraints, circuits, and results.
9
+
10
+ > [!IMPORTANT]
11
+ > FinQIR is an independent community project. It is not an IBM product and is
12
+ > not affiliated with or endorsed by IBM or the Qiskit project.
13
+
14
+ FinQIR begins with useful portfolio, pricing, probability-distribution, and
15
+ market-data components derived from the Apache-licensed Qiskit Finance project.
16
+ Its roadmap adds structured portfolio problems, traceable financial mappings,
17
+ finance-aware compilation passes, constraint-preserving QAOA, and reproducible
18
+ benchmarks.
19
+
20
+ ## Installation
21
+
22
+ After the first PyPI release, install FinQIR with:
23
+
24
+ ```bash
25
+ pip install finqir
26
+ ```
27
+
28
+ Until then, install the development version from source:
29
+
30
+ ```bash
31
+ git clone https://github.com/bilgin-kocak/finqir.git
32
+ cd finqir
33
+ python -m pip install -e ".[test,dev]"
34
+ ```
35
+
36
+ FinQIR 0.1 targets Python 3.10 or newer and Qiskit 2.5.2.
37
+
38
+ ## Example
39
+
40
+ ```python
41
+ import numpy as np
42
+
43
+ from finqir.applications.optimization import PortfolioOptimization
44
+
45
+ problem = PortfolioOptimization(
46
+ expected_returns=np.array([0.10, 0.08, 0.12]),
47
+ covariances=np.array(
48
+ [
49
+ [0.10, 0.02, 0.03],
50
+ [0.02, 0.08, 0.01],
51
+ [0.03, 0.01, 0.09],
52
+ ]
53
+ ),
54
+ risk_factor=0.5,
55
+ budget=2,
56
+ )
57
+
58
+ quadratic_program = problem.to_quadratic_program()
59
+ print(quadratic_program.prettyprint())
60
+ ```
61
+
62
+ ## Planned structured API
63
+
64
+ The design and implementation roadmap cover:
65
+
66
+ - `StructuredPortfolioProblem` with named financial constraints;
67
+ - binary, integer, unary, domain-wall, and fixed-cardinality mappings;
68
+ - finance-aware problem and circuit compilation passes;
69
+ - constraint-preserving QAOA mixers;
70
+ - conflict-graph portfolios and constrained MIS problems;
71
+ - multi-period rebalancing, risk, pricing, and benchmarking extensions.
72
+
73
+ These APIs are roadmap items and are not part of the initial package foundation.
74
+ See the [approved design](docs/superpowers/specs/2026-09-04-structured-quantum-finance-design.md)
75
+ and [implementation plan](docs/superpowers/plans/2026-09-04-structured-quantum-finance.md).
76
+
77
+ ## Development
78
+
79
+ ```bash
80
+ python -m pip install -e ".[test,dev]"
81
+ python -m unittest discover -s test -v
82
+ python -m build
83
+ python -m twine check dist/*
84
+ ```
85
+
86
+ ## Project history and license
87
+
88
+ FinQIR is an independent derivative of
89
+ [Qiskit Finance](https://github.com/qiskit-community/qiskit-finance). Existing
90
+ copyright notices are retained in derived files. New FinQIR work is released
91
+ under the same [Apache License 2.0](LICENSE.txt).
92
+
93
+ FinQIR is research software. It does not provide investment advice and must not
94
+ be treated as a guarantee of financial performance or quantum advantage.
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,53 @@
1
+ # This file is derived from Qiskit Finance for use in FinQIR.
2
+ #
3
+ # (C) Copyright IBM 2019, 2024.
4
+ #
5
+ # This code is licensed under the Apache License, Version 2.0. You may
6
+ # obtain a copy of this license in the LICENSE.txt file in the root directory
7
+ # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
8
+ #
9
+ # Any modifications or derivative works of this code must retain this
10
+ # copyright notice, and modified files need to carry a notice indicating
11
+ # that they have been altered from the originals.
12
+ """
13
+ =============================================
14
+ FinQIR module (:mod:`finqir`)
15
+ =============================================
16
+
17
+ .. currentmodule:: finqir
18
+
19
+ This is the FinQIR module. It has applications based on
20
+ `Amplitude Estimation
21
+ <https://qiskit-community.github.io/qiskit-algorithms/apidocs/qiskit_algorithms.html#amplitude-estimators>`__
22
+ and optimization using
23
+ `Qiskit Optimization <https://qiskit-community.github.io/qiskit-optimization/>`__,
24
+ some library circuits useful for finance applications,
25
+ and data providers which supply a source of financial data.
26
+
27
+ .. autosummary::
28
+ :toctree: ../stubs/
29
+ :nosignatures:
30
+
31
+ FinQIRError
32
+
33
+ In addition to standard Python errors the FinQIR module will raise this error
34
+ if circumstances are that it cannot proceed to completion.
35
+
36
+ Submodules
37
+ ==========
38
+
39
+ .. autosummary::
40
+ :toctree:
41
+
42
+ applications
43
+ circuit
44
+ data_providers
45
+
46
+ """
47
+
48
+ from .version import __version__
49
+ from .exceptions import FinQIRError
50
+
51
+ __title__ = "FinQIR"
52
+
53
+ __all__ = ["__title__", "__version__", "FinQIRError"]
@@ -0,0 +1,61 @@
1
+ # This file is derived from Qiskit Finance for use in FinQIR.
2
+ #
3
+ # (C) Copyright IBM 2020, 2023.
4
+ #
5
+ # This code is licensed under the Apache License, Version 2.0. You may
6
+ # obtain a copy of this license in the LICENSE.txt file in the root directory
7
+ # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
8
+ #
9
+ # Any modifications or derivative works of this code must retain this
10
+ # copyright notice, and modified files need to carry a notice indicating
11
+ # that they have been altered from the originals.
12
+
13
+ """
14
+ Finance applications (:mod:`finqir.applications`)
15
+ =========================================================
16
+
17
+ .. currentmodule:: finqir.applications
18
+
19
+ FinQIR ready-made applications.
20
+
21
+ Optimization Applications
22
+ -------------------------
23
+
24
+ .. autosummary::
25
+ :toctree: ../stubs/
26
+ :nosignatures:
27
+
28
+ PortfolioOptimization
29
+ PortfolioDiversification
30
+
31
+ Estimation Applications
32
+ -----------------------
33
+
34
+ .. autosummary::
35
+ :toctree: ../stubs/
36
+ :nosignatures:
37
+
38
+ EstimationApplication
39
+ EuropeanCallDelta
40
+ EuropeanCallPricing
41
+ FixedIncomePricing
42
+
43
+
44
+ """
45
+
46
+ from .estimation import (
47
+ EstimationApplication,
48
+ EuropeanCallDelta,
49
+ EuropeanCallPricing,
50
+ FixedIncomePricing,
51
+ )
52
+ from .optimization import PortfolioOptimization, PortfolioDiversification
53
+
54
+ __all__ = [
55
+ "PortfolioOptimization",
56
+ "PortfolioDiversification",
57
+ "EstimationApplication",
58
+ "EuropeanCallDelta",
59
+ "EuropeanCallPricing",
60
+ "FixedIncomePricing",
61
+ ]
@@ -0,0 +1,26 @@
1
+ # This file is derived from Qiskit Finance for use in FinQIR.
2
+ #
3
+ # (C) Copyright IBM 2019, 2023.
4
+ #
5
+ # This code is licensed under the Apache License, Version 2.0. You may
6
+ # obtain a copy of this license in the LICENSE.txt file in the root directory
7
+ # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
8
+ #
9
+ # Any modifications or derivative works of this code must retain this
10
+ # copyright notice, and modified files need to carry a notice indicating
11
+ # that they have been altered from the originals.
12
+
13
+
14
+ """Estimation applications for finance"""
15
+
16
+ from .estimation_application import EstimationApplication
17
+ from .european_call_delta import EuropeanCallDelta
18
+ from .european_call_pricing import EuropeanCallPricing
19
+ from .fixed_income_pricing import FixedIncomePricing
20
+
21
+ __all__ = [
22
+ "EstimationApplication",
23
+ "EuropeanCallDelta",
24
+ "EuropeanCallPricing",
25
+ "FixedIncomePricing",
26
+ ]
@@ -0,0 +1,44 @@
1
+ # This file is derived from Qiskit Finance for use in FinQIR.
2
+ #
3
+ # (C) Copyright IBM 2018, 2023.
4
+ #
5
+ # This code is licensed under the Apache License, Version 2.0. You may
6
+ # obtain a copy of this license in the LICENSE.txt file in the root directory
7
+ # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
8
+ #
9
+ # Any modifications or derivative works of this code must retain this
10
+ # copyright notice, and modified files need to carry a notice indicating
11
+ # that they have been altered from the originals.
12
+
13
+ """An abstract class for estimation application classes."""
14
+
15
+ from abc import ABC, abstractmethod
16
+
17
+ from qiskit_algorithms import (
18
+ EstimationProblem,
19
+ AmplitudeEstimatorResult,
20
+ )
21
+
22
+
23
+ class EstimationApplication(ABC):
24
+ """
25
+ An abstract class for estimation applications
26
+ """
27
+
28
+ @abstractmethod
29
+ def to_estimation_problem(self) -> EstimationProblem:
30
+ """Convert a problem instance into a
31
+ :class:`qiskit_algorithms.EstimationProblem`
32
+ """
33
+ pass
34
+
35
+ @abstractmethod
36
+ def interpret(self, result: AmplitudeEstimatorResult) -> float:
37
+ """Convert the calculation result of the problem
38
+ (:class:`qiskit_algorithms.AmplitudeEstimatorResult`)
39
+ to the answer of the problem.
40
+
41
+ Args:
42
+ result: The calculated result of the problem
43
+ """
44
+ pass