py10x-fin-base 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.
- py10x_fin_base-0.1.0/.gitignore +8 -0
- py10x_fin_base-0.1.0/.idea/.gitignore +5 -0
- py10x_fin_base-0.1.0/.idea/inspectionProfiles/Project_Default.xml +40 -0
- py10x_fin_base-0.1.0/.idea/inspectionProfiles/profiles_settings.xml +6 -0
- py10x_fin_base-0.1.0/.idea/modules.xml +9 -0
- py10x_fin_base-0.1.0/.idea/py10x-fin-base-cxx.iml +8 -0
- py10x_fin_base-0.1.0/.idea/py10x-fin-base.iml +18 -0
- py10x_fin_base-0.1.0/.idea/vcs.xml +6 -0
- py10x_fin_base-0.1.0/LICENSE +21 -0
- py10x_fin_base-0.1.0/NOTICE +47 -0
- py10x_fin_base-0.1.0/PKG-INFO +115 -0
- py10x_fin_base-0.1.0/README.md +91 -0
- py10x_fin_base-0.1.0/cxxfin/CMakeLists.txt +60 -0
- py10x_fin_base-0.1.0/cxxfin/CMakePresets.json +29 -0
- py10x_fin_base-0.1.0/cxxfin/LICENSE +21 -0
- py10x_fin_base-0.1.0/cxxfin/README.md +53 -0
- py10x_fin_base-0.1.0/cxxfin/bcompounding.h +57 -0
- py10x_fin_base-0.1.0/cxxfin/bday_count_convention.h +143 -0
- py10x_fin_base-0.1.0/cxxfin/brate_curve.h +64 -0
- py10x_fin_base-0.1.0/cxxfin/bzrc_bootstrap.h +177 -0
- py10x_fin_base-0.1.0/cxxfin/cxxfin.cpp +126 -0
- py10x_fin_base-0.1.0/cxxfin/pyproject.toml +52 -0
- py10x_fin_base-0.1.0/docs/OPEN_SOURCE_CHECKLIST.md +160 -0
- py10x_fin_base-0.1.0/pyproject.toml +72 -0
- py10x_fin_base-0.1.0/xxfin/.gitignore +1 -0
- py10x_fin_base-0.1.0/xxfin/__init__.py +13 -0
- py10x_fin_base-0.1.0/xxfin/_version.py +24 -0
- py10x_fin_base-0.1.0/xxfin/bbg_adaptors/__init__.py +0 -0
- py10x_fin_base-0.1.0/xxfin/bbg_adaptors/bbg_adaptor.py +53 -0
- py10x_fin_base-0.1.0/xxfin/bbg_adaptors/bbg_connector.py +26 -0
- py10x_fin_base-0.1.0/xxfin/bbg_adaptors/fx_spot_fwd_quotable_bbg_adaptors.py +22 -0
- py10x_fin_base-0.1.0/xxfin/bbg_adaptors/ir_cash_deposit_quotable_bbg_adaptors.py +35 -0
- py10x_fin_base-0.1.0/xxfin/bbg_adaptors/ir_swap_quotable_bbg_adaptors.py +12 -0
- py10x_fin_base-0.1.0/xxfin/ccy.py +58 -0
- py10x_fin_base-0.1.0/xxfin/ccy_cross.py +268 -0
- py10x_fin_base-0.1.0/xxfin/ccy_forward.py +34 -0
- py10x_fin_base-0.1.0/xxfin/cxx_day_count_convention.py +11 -0
- py10x_fin_base-0.1.0/xxfin/cxx_ir_compounding.py +13 -0
- py10x_fin_base-0.1.0/xxfin/cxx_rate_curve.py +21 -0
- py10x_fin_base-0.1.0/xxfin/cxx_zrc_bootstrap.py +104 -0
- py10x_fin_base-0.1.0/xxfin/day_count_convention.py +7 -0
- py10x_fin_base-0.1.0/xxfin/dev_data_helpers/RUN_ME.py +34 -0
- py10x_fin_base-0.1.0/xxfin/dev_data_helpers/__init__.py +0 -0
- py10x_fin_base-0.1.0/xxfin/dev_data_helpers/basic_mas_create.py +14 -0
- py10x_fin_base-0.1.0/xxfin/dev_data_helpers/bbg_dev_connector_create.py +29 -0
- py10x_fin_base-0.1.0/xxfin/dev_data_helpers/ccys_create.py +77 -0
- py10x_fin_base-0.1.0/xxfin/dev_data_helpers/data_creator.py +65 -0
- py10x_fin_base-0.1.0/xxfin/dev_data_helpers/fin_calendars_create.py +9 -0
- py10x_fin_base-0.1.0/xxfin/dev_data_helpers/fx_mkt_conventions_create.py +49 -0
- py10x_fin_base-0.1.0/xxfin/dev_data_helpers/fx_mkt_data_create.py +59 -0
- py10x_fin_base-0.1.0/xxfin/dev_data_helpers/ir_rate_mkt_conventions_create.py +183 -0
- py10x_fin_base-0.1.0/xxfin/dev_data_helpers/ir_zrc_mkt_data_create.py +149 -0
- py10x_fin_base-0.1.0/xxfin/dev_data_helpers/pricing_contexts_create.py +29 -0
- py10x_fin_base-0.1.0/xxfin/dev_data_helpers/xxfin_stores_and_associations_create.py +26 -0
- py10x_fin_base-0.1.0/xxfin/fin_calendar.py +60 -0
- py10x_fin_base-0.1.0/xxfin/fin_instrument.py +121 -0
- py10x_fin_base-0.1.0/xxfin/future_month.py +89 -0
- py10x_fin_base-0.1.0/xxfin/fx_forward_curve.py +230 -0
- py10x_fin_base-0.1.0/xxfin/fx_forward_curve_mas.py +28 -0
- py10x_fin_base-0.1.0/xxfin/fx_mkt_conventions.py +83 -0
- py10x_fin_base-0.1.0/xxfin/fx_rate.py +46 -0
- py10x_fin_base-0.1.0/xxfin/fx_spot_fwd_quotable.py +35 -0
- py10x_fin_base-0.1.0/xxfin/ir_cash_deposit_quotable.py +58 -0
- py10x_fin_base-0.1.0/xxfin/ir_compounding.py +6 -0
- py10x_fin_base-0.1.0/xxfin/ir_rate_mkt_conventions.py +46 -0
- py10x_fin_base-0.1.0/xxfin/ir_swap_quotable.py +95 -0
- py10x_fin_base-0.1.0/xxfin/ir_zero_rate_curve.py +138 -0
- py10x_fin_base-0.1.0/xxfin/ir_zero_rate_curve_mas.py +33 -0
- py10x_fin_base-0.1.0/xxfin/jit_aadc/__init__.py +0 -0
- py10x_fin_base-0.1.0/xxfin/jit_aadc/aadc_context.py +69 -0
- py10x_fin_base-0.1.0/xxfin/jit_aadc/aadc_doc.md +69 -0
- py10x_fin_base-0.1.0/xxfin/jit_aadc/aadc_kernel.py +115 -0
- py10x_fin_base-0.1.0/xxfin/jit_aadc/aadc_kernel_doc.md +144 -0
- py10x_fin_base-0.1.0/xxfin/jit_aadc/manual_tests/__init__.py +0 -0
- py10x_fin_base-0.1.0/xxfin/jit_aadc/manual_tests/aadc_kernel_test.py +85 -0
- py10x_fin_base-0.1.0/xxfin/jit_aadc/manual_tests/aadc_raw_ccy_forward_test.py +104 -0
- py10x_fin_base-0.1.0/xxfin/jit_aadc/manual_tests/cxx_curve_perf_findings.md +86 -0
- py10x_fin_base-0.1.0/xxfin/manual_tests/ccy_cross_test.py +56 -0
- py10x_fin_base-0.1.0/xxfin/manual_tests/ccy_forward_test.py +64 -0
- py10x_fin_base-0.1.0/xxfin/manual_tests/ccy_unit_test.py +38 -0
- py10x_fin_base-0.1.0/xxfin/manual_tests/cxxfin_test.py +34 -0
- py10x_fin_base-0.1.0/xxfin/manual_tests/date_curve_test.py +39 -0
- py10x_fin_base-0.1.0/xxfin/manual_tests/day_count_convention_test.py +52 -0
- py10x_fin_base-0.1.0/xxfin/manual_tests/dumb_delta.py +15 -0
- py10x_fin_base-0.1.0/xxfin/manual_tests/fin_instrument_test.py +199 -0
- py10x_fin_base-0.1.0/xxfin/manual_tests/fx_forward_curve_test.py +92 -0
- py10x_fin_base-0.1.0/xxfin/manual_tests/fx_fwd_curve_test.py +131 -0
- py10x_fin_base-0.1.0/xxfin/manual_tests/fx_rate_flat_test.py +47 -0
- py10x_fin_base-0.1.0/xxfin/manual_tests/fx_rate_test.py +161 -0
- py10x_fin_base-0.1.0/xxfin/manual_tests/graph_deps_test.py +25 -0
- py10x_fin_base-0.1.0/xxfin/manual_tests/ir_zero_out_discounting_test.py +57 -0
- py10x_fin_base-0.1.0/xxfin/manual_tests/ir_zero_rate_curve_performance_test.py +110 -0
- py10x_fin_base-0.1.0/xxfin/manual_tests/ir_zero_rate_curve_test.py +45 -0
- py10x_fin_base-0.1.0/xxfin/manual_tests/rate_curve_test.py +186 -0
- py10x_fin_base-0.1.0/xxfin/mkt_adaptor.py +78 -0
- py10x_fin_base-0.1.0/xxfin/mkt_conventions.py +78 -0
- py10x_fin_base-0.1.0/xxfin/mkt_data_basis.py +33 -0
- py10x_fin_base-0.1.0/xxfin/mkt_quotable.py +148 -0
- py10x_fin_base-0.1.0/xxfin/mkt_quotables_scope.py +53 -0
- py10x_fin_base-0.1.0/xxfin/pre_basket.py +119 -0
- py10x_fin_base-0.1.0/xxfin/pricing_context.py +72 -0
- py10x_fin_base-0.1.0/xxfin/py_day_count_convention.py +81 -0
- py10x_fin_base-0.1.0/xxfin/py_ir_compounding.py +31 -0
- py10x_fin_base-0.1.0/xxfin/py_rate_curve.py +178 -0
- py10x_fin_base-0.1.0/xxfin/py_zrc_bootstrap.py +48 -0
- py10x_fin_base-0.1.0/xxfin/rate_curve.py +10 -0
- py10x_fin_base-0.1.0/xxfin/root_solver.py +43 -0
- py10x_fin_base-0.1.0/xxfin/snapshot.py +5 -0
- py10x_fin_base-0.1.0/xxfin/synthetic_mkt_data.py +96 -0
- py10x_fin_base-0.1.0/xxfin/testlib/__init__.py +0 -0
- py10x_fin_base-0.1.0/xxfin/testlib/cxx_or_py.py +75 -0
- py10x_fin_base-0.1.0/xxfin/unit_tests/conftest.py +48 -0
- py10x_fin_base-0.1.0/xxfin/unit_tests/test_bbg_adaptor_reconciliation.py +121 -0
- py10x_fin_base-0.1.0/xxfin/unit_tests/test_bbg_adaptors.py +107 -0
- py10x_fin_base-0.1.0/xxfin/unit_tests/test_ccy.py +65 -0
- py10x_fin_base-0.1.0/xxfin/unit_tests/test_ccy_cross.py +77 -0
- py10x_fin_base-0.1.0/xxfin/unit_tests/test_ccy_forward.py +63 -0
- py10x_fin_base-0.1.0/xxfin/unit_tests/test_ccy_unit.py +26 -0
- py10x_fin_base-0.1.0/xxfin/unit_tests/test_cxxfin.py +32 -0
- py10x_fin_base-0.1.0/xxfin/unit_tests/test_day_count_conventions.py +141 -0
- py10x_fin_base-0.1.0/xxfin/unit_tests/test_fin_calendar.py +24 -0
- py10x_fin_base-0.1.0/xxfin/unit_tests/test_fin_instrument.py +148 -0
- py10x_fin_base-0.1.0/xxfin/unit_tests/test_future_month.py +122 -0
- py10x_fin_base-0.1.0/xxfin/unit_tests/test_fx_forward_curve.py +115 -0
- py10x_fin_base-0.1.0/xxfin/unit_tests/test_fx_rate.py +129 -0
- py10x_fin_base-0.1.0/xxfin/unit_tests/test_ir_compounding.py +45 -0
- py10x_fin_base-0.1.0/xxfin/unit_tests/test_rate_curve.py +269 -0
- py10x_fin_base-0.1.0/xxfin/xxfin_env_vars.py +9 -0
- py10x_fin_base-0.1.0/xxfin/zrc_bootstrap.py +6 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<component name="InspectionProjectProfileManager">
|
|
2
|
+
<profile version="1.0">
|
|
3
|
+
<option name="myName" value="Project Default" />
|
|
4
|
+
<inspection_tool class="ProblematicWhitespace" enabled="true" level="WARNING" enabled_by_default="true" />
|
|
5
|
+
<inspection_tool class="PyArgumentEqualDefaultInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
|
6
|
+
<inspection_tool class="PyAugmentAssignmentInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
|
7
|
+
<inspection_tool class="PyClassicStyleClassInspection" enabled="true" level="WARNING" enabled_by_default="true" />
|
|
8
|
+
<inspection_tool class="PyCompatibilityInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
|
9
|
+
<option name="ourVersions">
|
|
10
|
+
<value>
|
|
11
|
+
<list size="5">
|
|
12
|
+
<item index="0" class="java.lang.String" itemvalue="3.13" />
|
|
13
|
+
<item index="1" class="java.lang.String" itemvalue="3.11" />
|
|
14
|
+
<item index="2" class="java.lang.String" itemvalue="3.12" />
|
|
15
|
+
<item index="3" class="java.lang.String" itemvalue="3.14" />
|
|
16
|
+
<item index="4" class="java.lang.String" itemvalue="3.15" />
|
|
17
|
+
</list>
|
|
18
|
+
</value>
|
|
19
|
+
</option>
|
|
20
|
+
</inspection_tool>
|
|
21
|
+
<inspection_tool class="PyMissingTypeHintsInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
|
22
|
+
<inspection_tool class="PyPep8Inspection" enabled="true" level="INFORMATION" enabled_by_default="true">
|
|
23
|
+
<option name="ignoredErrors">
|
|
24
|
+
<list>
|
|
25
|
+
<option value="E302" />
|
|
26
|
+
</list>
|
|
27
|
+
</option>
|
|
28
|
+
</inspection_tool>
|
|
29
|
+
<inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
|
30
|
+
<option name="ignoredErrors">
|
|
31
|
+
<list>
|
|
32
|
+
<option value="N814" />
|
|
33
|
+
<option value="N802" />
|
|
34
|
+
<option value="N801" />
|
|
35
|
+
</list>
|
|
36
|
+
</option>
|
|
37
|
+
</inspection_tool>
|
|
38
|
+
<inspection_tool class="RegExpAnonymousGroup" enabled="true" level="WARNING" enabled_by_default="true" />
|
|
39
|
+
</profile>
|
|
40
|
+
</component>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/py10x-fin-base.iml" filepath="$PROJECT_DIR$/.idea/py10x-fin-base.iml" />
|
|
6
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/py10x-fin-base-cxx.iml" filepath="$PROJECT_DIR$/.idea/py10x-fin-base-cxx.iml" />
|
|
7
|
+
</modules>
|
|
8
|
+
</component>
|
|
9
|
+
</project>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module external.system.id="pyproject.toml" type="PYTHON_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$/cxxfin" />
|
|
5
|
+
<orderEntry type="jdk" jdkName="Python 3.12 (xx_fin)" jdkType="Python SDK" />
|
|
6
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
7
|
+
</component>
|
|
8
|
+
</module>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module external.system.id="pyproject.toml" type="PYTHON_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$">
|
|
5
|
+
<excludeFolder url="file://$MODULE_DIR$/.venv" />
|
|
6
|
+
</content>
|
|
7
|
+
<orderEntry type="jdk" jdkName="Python 3.12 (xx_fin)" jdkType="Python SDK" />
|
|
8
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
9
|
+
<orderEntry type="module" module-name="py10x-fin-base-cxx" exported="" />
|
|
10
|
+
</component>
|
|
11
|
+
<component name="PyDocumentationSettings">
|
|
12
|
+
<option name="format" value="PLAIN" />
|
|
13
|
+
<option name="myDocStringFormat" value="Plain" />
|
|
14
|
+
</component>
|
|
15
|
+
<component name="TestRunnerService">
|
|
16
|
+
<option name="PROJECT_TEST_RUNNER" value="py.test" />
|
|
17
|
+
</component>
|
|
18
|
+
</module>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 10X CONCEPTS LLC, XXFIN LLC and contributors
|
|
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,47 @@
|
|
|
1
|
+
py10x-fin-base / py10x-fin-base-cxx (xxfin / cxxfin)
|
|
2
|
+
Copyright (c) 2025-2026 10X CONCEPTS LLC, XXFIN LLC and contributors
|
|
3
|
+
|
|
4
|
+
This project is licensed under the MIT License. See the LICENSE file for the full text.
|
|
5
|
+
|
|
6
|
+
================================================================================
|
|
7
|
+
Third-party open source software
|
|
8
|
+
================================================================================
|
|
9
|
+
|
|
10
|
+
This software uses or depends on the following open source packages, in
|
|
11
|
+
addition to those already covered by py10x-core's own NOTICE. Their respective
|
|
12
|
+
copyright notices and licenses apply to those components only.
|
|
13
|
+
|
|
14
|
+
- QuantLib / quantlib-python
|
|
15
|
+
Copyright (c) QuantLib contributors. BSD 3-Clause-style QuantLib License.
|
|
16
|
+
https://www.quantlib.org/
|
|
17
|
+
|
|
18
|
+
- xbbg (optional "bbg" extra)
|
|
19
|
+
Copyright (c) Alpha Xie and contributors. Apache License 2.0.
|
|
20
|
+
https://github.com/alpha-xone/xbbg
|
|
21
|
+
|
|
22
|
+
================================================================================
|
|
23
|
+
Dependencies requiring a separate commercial license to run
|
|
24
|
+
================================================================================
|
|
25
|
+
|
|
26
|
+
These are not open source. They are listed here because xxfin/cxxfin can
|
|
27
|
+
optionally depend on them; installing xxfin/cxxfin does not grant any rights
|
|
28
|
+
to them, and using them is subject to their own vendors' terms.
|
|
29
|
+
|
|
30
|
+
- aadc
|
|
31
|
+
Copyright (c) MatLogica Limited. Proprietary Python interface to MatLogica's
|
|
32
|
+
AADC (Adjoint Algorithmic Differentiation Compiler). Installable from PyPI
|
|
33
|
+
without restriction and ships with a time-limited trial license out of the
|
|
34
|
+
box; continued or production use requires a license key obtained from
|
|
35
|
+
MatLogica.
|
|
36
|
+
https://pypi.org/project/aadc/
|
|
37
|
+
|
|
38
|
+
- blpapi (optional "bbg" extra)
|
|
39
|
+
Copyright (c) Bloomberg Finance L.P. Bloomberg's proprietary API, not
|
|
40
|
+
open source. Distributed only via Bloomberg's own dedicated package
|
|
41
|
+
index under Bloomberg's license terms; requires a valid Bloomberg
|
|
42
|
+
entitlement/terminal to use at runtime.
|
|
43
|
+
https://www.bloomberg.com/professional/support/api-library/
|
|
44
|
+
|
|
45
|
+
This NOTICE is not a substitute for the licenses of the above packages.
|
|
46
|
+
Full license texts are typically included in each package's distribution
|
|
47
|
+
or available at the project URLs above.
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: py10x-fin-base
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: 10x Financial Domain Foundation
|
|
5
|
+
Author-email: 10X CONCEPTS LLC <py10x@10x-software.org>
|
|
6
|
+
License: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
License-File: NOTICE
|
|
9
|
+
Requires-Python: <3.14,>=3.11
|
|
10
|
+
Requires-Dist: aadc>=1.8.2; sys_platform != 'darwin' and (sys_platform != 'win32' or python_version != '3.13')
|
|
11
|
+
Requires-Dist: py10x-core==0.3.0
|
|
12
|
+
Requires-Dist: py10x-fin-base-cxx==0.1.0
|
|
13
|
+
Requires-Dist: quantlib-python>=1.18
|
|
14
|
+
Provides-Extra: bbg
|
|
15
|
+
Requires-Dist: blpapi>=3.26.6.1; extra == 'bbg'
|
|
16
|
+
Requires-Dist: xbbg>=1.4.5; extra == 'bbg'
|
|
17
|
+
Provides-Extra: dev
|
|
18
|
+
Requires-Dist: cmake>=3.27; extra == 'dev'
|
|
19
|
+
Requires-Dist: ninja>=1.11; extra == 'dev'
|
|
20
|
+
Requires-Dist: py10x-core[dev]; extra == 'dev'
|
|
21
|
+
Requires-Dist: scikit-build-core>=0.12.2; extra == 'dev'
|
|
22
|
+
Requires-Dist: setuptools-scm>=9.2.2; extra == 'dev'
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
# XXFIN
|
|
26
|
+
|
|
27
|
+
## Install
|
|
28
|
+
|
|
29
|
+
Install the consumer package only:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install py10x-fin-base
|
|
33
|
+
# or: uv pip install py10x-fin-base
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
That pulls **`py10x-fin-base-cxx`** transitively (import `cxxfin`). Do not depend on the cxx
|
|
37
|
+
dist directly. Requires Python `>=3.11,<3.14` and a published `py10x-core` (plus its kernel/infra).
|
|
38
|
+
|
|
39
|
+
In this monorepo the packaging root is [`xx_fin/`](.). Domain developers typically use
|
|
40
|
+
`uv-sync py10x-dev --all-extras --with-downstream` from the py10x repo root — see
|
|
41
|
+
[`CONTRIBUTING.md`](../CONTRIBUTING.md#development-setup).
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
from xxfin.ccy import Ccy
|
|
45
|
+
import cxxfin # native extension from py10x-fin-base-cxx
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## About
|
|
49
|
+
The xxfin package of the 10x project serves a dual purpose:
|
|
50
|
+
|
|
51
|
+
- to illustrate the capabilities of the 10x system by implementing a sufficiently rich example solving an important
|
|
52
|
+
problem in an important subject domain
|
|
53
|
+
- to provide a complete working implementation of the most foundational valuation problem in the financial domain:
|
|
54
|
+
calculating today's price of a fixed amount of a future cash flow denominated in any currency.
|
|
55
|
+
|
|
56
|
+
To achieve this goal, one needs to determine the relevant currency/foreign exchange (FX) rates and discount factors in a
|
|
57
|
+
manner consistent with the current market data. Hence, we define all the necessary data structures for market data,
|
|
58
|
+
including:
|
|
59
|
+
|
|
60
|
+
- an ingestion/translation facility for collecting market data from any chosen data providers
|
|
61
|
+
- generation/population/storage objects for standard quoted market data
|
|
62
|
+
- models for calibrating complex/"synthetic" objects (forward curves), allowing calculation of rates/values that are not
|
|
63
|
+
directly observable but are consistent with all the relevant markets
|
|
64
|
+
|
|
65
|
+
The sequence of the valuation steps is as follows:
|
|
66
|
+
|
|
67
|
+
- We create market data objects ("quotables") that contain the market quotes and are stored in a user-specified market
|
|
68
|
+
data store.
|
|
69
|
+
- The user specifies an external market data provider.
|
|
70
|
+
- An adapter is needed to translate the market data from the provider's format and populate our quotables.
|
|
71
|
+
- We may provide such an adapter for a commonly used provider (e.g., Bloomberg), and, at a later date, add more
|
|
72
|
+
adapters if demand warrants it.
|
|
73
|
+
- We create a sample set of quotables which allow us to illustrate the use of market data.
|
|
74
|
+
- Each piece of market data is quoted as a number (or a collection of numbers) representing values/parameters of certain
|
|
75
|
+
standard financial contracts, and the set of specifications sufficient to describe and value such standardized
|
|
76
|
+
contracts is saved in "market convention" objects.
|
|
77
|
+
|
|
78
|
+
The subset of all market quotables used to build/calibrate synthetic market data (forward curves) is called a market
|
|
79
|
+
assembly. It usually consists of the most liquid contracts that provide the most precise view of market participants on
|
|
80
|
+
the market (e.g., the most liquid swap or FX forward quotes). Once we ingest the market quotes from the data provider(s)
|
|
81
|
+
into the quotables, we use a market assembly to build/calibrate the forward curve using a chosen calibration procedure.
|
|
82
|
+
The subsequent use of the curves built this way is completely agnostic to the curve calibration choices. Hence, the
|
|
83
|
+
market assembly, as well as the calibration analytics, can be replaced by the user's preferred choices.
|
|
84
|
+
|
|
85
|
+
The discount curve for a discount rate in a given currency is built using that currency-denominated standard cash
|
|
86
|
+
deposit and fixed-floating swap market quotes, with that rate as the underlying/reference floating rate for the
|
|
87
|
+
instruments listed in a market assembly (e.g., for the SOFR curve we use USD cash deposits and SOFR standard annual
|
|
88
|
+
fixed/floating swap quotes).
|
|
89
|
+
|
|
90
|
+
For FX forward curve construction, we currently use FX spot and FX forward (point) quotes for rates
|
|
91
|
+
funded/collateralized in the same currency (e.g., USD). We build an FX curve for a market assembly-specified set of FX
|
|
92
|
+
spot and FX USD-collateralized forwards consistent with the funding currency's discount curve.
|
|
93
|
+
|
|
94
|
+
Such an FX forward curve allows us to calculate the present value, in any given currency, of a cash flow denominated in
|
|
95
|
+
any other currency.
|
|
96
|
+
|
|
97
|
+
## Optional JIT acceleration via AADC
|
|
98
|
+
|
|
99
|
+
`xxfin/jit_aadc/` optionally records curve/valuation code into a JIT-compiled adjoint
|
|
100
|
+
differentiation kernel using [MatLogica's AADC](https://pypi.org/project/aadc/) (Adjoint Algorithmic
|
|
101
|
+
Differentiation Compiler), enabled via the `use_cxxfin`/`aadc_license` settings in
|
|
102
|
+
`xxfin_env_vars.py`. `aadc` installs freely from PyPI where MatLogica publishes wheels; it is a
|
|
103
|
+
required dependency except on macOS (no published build) and on Windows under Python 3.13 (no
|
|
104
|
+
wheel yet). It ships with a
|
|
105
|
+
time-limited trial license out of the box, but continued or production use requires a license key
|
|
106
|
+
obtained from MatLogica. `xxfin` itself
|
|
107
|
+
works fully without it — AADC only accelerates the JIT-compiled code path.
|
|
108
|
+
|
|
109
|
+
## An easy setup to start playing with xxfin package
|
|
110
|
+
- install mongodb on your machine and run without authentication (default)
|
|
111
|
+
- set environment variables:
|
|
112
|
+
- XX_MAIN_TS_STORE_URI=mongodb://localhost/xx_fin (or any other MongoDb)
|
|
113
|
+
- XXFIN_DEFAULT_PRICING_CONTEXT_NAME=Abu Dhabi 20251010
|
|
114
|
+
- run xxfin/dev_data_helpers/RUN_ME.py (it will store a number of objects)
|
|
115
|
+
- you are ready to go!
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# XXFIN
|
|
2
|
+
|
|
3
|
+
## Install
|
|
4
|
+
|
|
5
|
+
Install the consumer package only:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install py10x-fin-base
|
|
9
|
+
# or: uv pip install py10x-fin-base
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
That pulls **`py10x-fin-base-cxx`** transitively (import `cxxfin`). Do not depend on the cxx
|
|
13
|
+
dist directly. Requires Python `>=3.11,<3.14` and a published `py10x-core` (plus its kernel/infra).
|
|
14
|
+
|
|
15
|
+
In this monorepo the packaging root is [`xx_fin/`](.). Domain developers typically use
|
|
16
|
+
`uv-sync py10x-dev --all-extras --with-downstream` from the py10x repo root — see
|
|
17
|
+
[`CONTRIBUTING.md`](../CONTRIBUTING.md#development-setup).
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
from xxfin.ccy import Ccy
|
|
21
|
+
import cxxfin # native extension from py10x-fin-base-cxx
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## About
|
|
25
|
+
The xxfin package of the 10x project serves a dual purpose:
|
|
26
|
+
|
|
27
|
+
- to illustrate the capabilities of the 10x system by implementing a sufficiently rich example solving an important
|
|
28
|
+
problem in an important subject domain
|
|
29
|
+
- to provide a complete working implementation of the most foundational valuation problem in the financial domain:
|
|
30
|
+
calculating today's price of a fixed amount of a future cash flow denominated in any currency.
|
|
31
|
+
|
|
32
|
+
To achieve this goal, one needs to determine the relevant currency/foreign exchange (FX) rates and discount factors in a
|
|
33
|
+
manner consistent with the current market data. Hence, we define all the necessary data structures for market data,
|
|
34
|
+
including:
|
|
35
|
+
|
|
36
|
+
- an ingestion/translation facility for collecting market data from any chosen data providers
|
|
37
|
+
- generation/population/storage objects for standard quoted market data
|
|
38
|
+
- models for calibrating complex/"synthetic" objects (forward curves), allowing calculation of rates/values that are not
|
|
39
|
+
directly observable but are consistent with all the relevant markets
|
|
40
|
+
|
|
41
|
+
The sequence of the valuation steps is as follows:
|
|
42
|
+
|
|
43
|
+
- We create market data objects ("quotables") that contain the market quotes and are stored in a user-specified market
|
|
44
|
+
data store.
|
|
45
|
+
- The user specifies an external market data provider.
|
|
46
|
+
- An adapter is needed to translate the market data from the provider's format and populate our quotables.
|
|
47
|
+
- We may provide such an adapter for a commonly used provider (e.g., Bloomberg), and, at a later date, add more
|
|
48
|
+
adapters if demand warrants it.
|
|
49
|
+
- We create a sample set of quotables which allow us to illustrate the use of market data.
|
|
50
|
+
- Each piece of market data is quoted as a number (or a collection of numbers) representing values/parameters of certain
|
|
51
|
+
standard financial contracts, and the set of specifications sufficient to describe and value such standardized
|
|
52
|
+
contracts is saved in "market convention" objects.
|
|
53
|
+
|
|
54
|
+
The subset of all market quotables used to build/calibrate synthetic market data (forward curves) is called a market
|
|
55
|
+
assembly. It usually consists of the most liquid contracts that provide the most precise view of market participants on
|
|
56
|
+
the market (e.g., the most liquid swap or FX forward quotes). Once we ingest the market quotes from the data provider(s)
|
|
57
|
+
into the quotables, we use a market assembly to build/calibrate the forward curve using a chosen calibration procedure.
|
|
58
|
+
The subsequent use of the curves built this way is completely agnostic to the curve calibration choices. Hence, the
|
|
59
|
+
market assembly, as well as the calibration analytics, can be replaced by the user's preferred choices.
|
|
60
|
+
|
|
61
|
+
The discount curve for a discount rate in a given currency is built using that currency-denominated standard cash
|
|
62
|
+
deposit and fixed-floating swap market quotes, with that rate as the underlying/reference floating rate for the
|
|
63
|
+
instruments listed in a market assembly (e.g., for the SOFR curve we use USD cash deposits and SOFR standard annual
|
|
64
|
+
fixed/floating swap quotes).
|
|
65
|
+
|
|
66
|
+
For FX forward curve construction, we currently use FX spot and FX forward (point) quotes for rates
|
|
67
|
+
funded/collateralized in the same currency (e.g., USD). We build an FX curve for a market assembly-specified set of FX
|
|
68
|
+
spot and FX USD-collateralized forwards consistent with the funding currency's discount curve.
|
|
69
|
+
|
|
70
|
+
Such an FX forward curve allows us to calculate the present value, in any given currency, of a cash flow denominated in
|
|
71
|
+
any other currency.
|
|
72
|
+
|
|
73
|
+
## Optional JIT acceleration via AADC
|
|
74
|
+
|
|
75
|
+
`xxfin/jit_aadc/` optionally records curve/valuation code into a JIT-compiled adjoint
|
|
76
|
+
differentiation kernel using [MatLogica's AADC](https://pypi.org/project/aadc/) (Adjoint Algorithmic
|
|
77
|
+
Differentiation Compiler), enabled via the `use_cxxfin`/`aadc_license` settings in
|
|
78
|
+
`xxfin_env_vars.py`. `aadc` installs freely from PyPI where MatLogica publishes wheels; it is a
|
|
79
|
+
required dependency except on macOS (no published build) and on Windows under Python 3.13 (no
|
|
80
|
+
wheel yet). It ships with a
|
|
81
|
+
time-limited trial license out of the box, but continued or production use requires a license key
|
|
82
|
+
obtained from MatLogica. `xxfin` itself
|
|
83
|
+
works fully without it — AADC only accelerates the JIT-compiled code path.
|
|
84
|
+
|
|
85
|
+
## An easy setup to start playing with xxfin package
|
|
86
|
+
- install mongodb on your machine and run without authentication (default)
|
|
87
|
+
- set environment variables:
|
|
88
|
+
- XX_MAIN_TS_STORE_URI=mongodb://localhost/xx_fin (or any other MongoDb)
|
|
89
|
+
- XXFIN_DEFAULT_PRICING_CONTEXT_NAME=Abu Dhabi 20251010
|
|
90
|
+
- run xxfin/dev_data_helpers/RUN_ME.py (it will store a number of objects)
|
|
91
|
+
- you are ready to go!
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.27...3.30)
|
|
2
|
+
project(cxxfin)
|
|
3
|
+
|
|
4
|
+
set(CMAKE_CXX_STANDARD 20)
|
|
5
|
+
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
|
6
|
+
|
|
7
|
+
find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module)
|
|
8
|
+
|
|
9
|
+
# ---------------------------------------------------------------------------
|
|
10
|
+
# Resolve py10x_kernel headers at the exact git commit matching the installed
|
|
11
|
+
# binary. setuptools_scm embeds the hash in the version string as "+gHASH",
|
|
12
|
+
# e.g. "0.1.dev42+gabcdef12.d20260601". For a clean tag release the version
|
|
13
|
+
# is plain "1.2.3" and we reconstruct the tag "py10x-kernel-v1.2.3".
|
|
14
|
+
# GIT_SHALLOW is intentionally omitted: shallow clones cannot fetch by hash.
|
|
15
|
+
#
|
|
16
|
+
# Use importlib.metadata — do NOT `import py10x_kernel` here. Importing the
|
|
17
|
+
# extension runs its import-time incremental rebuild, which prints cmake
|
|
18
|
+
# progress on stdout and corrupts the captured version (FetchContent then
|
|
19
|
+
# tries to checkout a tag like `py10x-kernel-vRunning cmake --build...`).
|
|
20
|
+
# ---------------------------------------------------------------------------
|
|
21
|
+
execute_process(
|
|
22
|
+
COMMAND ${Python3_EXECUTABLE} -c "import importlib.metadata as m; print(m.version('py10x-kernel'))"
|
|
23
|
+
OUTPUT_VARIABLE _PY10X_KERNEL_VERSION
|
|
24
|
+
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
25
|
+
ERROR_VARIABLE _version_err
|
|
26
|
+
RESULT_VARIABLE _version_rc
|
|
27
|
+
)
|
|
28
|
+
if(NOT _version_rc EQUAL 0)
|
|
29
|
+
message(FATAL_ERROR "Could not query py10x-kernel version (${_version_err}). Is it installed in the active environment?")
|
|
30
|
+
endif()
|
|
31
|
+
|
|
32
|
+
string(REGEX MATCH "g([0-9a-f]+)" _hash_match "${_PY10X_KERNEL_VERSION}")
|
|
33
|
+
if(_hash_match)
|
|
34
|
+
string(REGEX REPLACE "g([0-9a-f]+)" "\\1" _PY10X_KERNEL_GIT_TAG "${_hash_match}")
|
|
35
|
+
else()
|
|
36
|
+
# PEP 440 normalizes bare `.dev` tags to `.dev0`; xx-promote git tags keep `.dev`.
|
|
37
|
+
set(_PY10X_KERNEL_GIT_TAG "py10x-kernel-v${_PY10X_KERNEL_VERSION}")
|
|
38
|
+
string(REGEX REPLACE "\\.dev0$" ".dev" _PY10X_KERNEL_GIT_TAG "${_PY10X_KERNEL_GIT_TAG}")
|
|
39
|
+
endif()
|
|
40
|
+
message(STATUS "py10x_kernel ${_PY10X_KERNEL_VERSION} -> fetching headers at ${_PY10X_KERNEL_GIT_TAG}")
|
|
41
|
+
|
|
42
|
+
include(FetchContent)
|
|
43
|
+
FetchContent_Declare(
|
|
44
|
+
cxx10x_core_headers
|
|
45
|
+
GIT_REPOSITORY https://github.com/10x-software/cxx10x.git
|
|
46
|
+
GIT_TAG ${_PY10X_KERNEL_GIT_TAG}
|
|
47
|
+
SOURCE_SUBDIR _headers_only
|
|
48
|
+
)
|
|
49
|
+
FetchContent_MakeAvailable(cxx10x_core_headers)
|
|
50
|
+
|
|
51
|
+
include(${cxx10x_core_headers_SOURCE_DIR}/cmake/XX_pybind11_add_module.cmake)
|
|
52
|
+
|
|
53
|
+
xx_pybind11_add_module(cxxfin
|
|
54
|
+
cxxfin.cpp
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
install(TARGETS cxxfin
|
|
58
|
+
LIBRARY DESTINATION .
|
|
59
|
+
RUNTIME DESTINATION .
|
|
60
|
+
)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"configurePresets": [
|
|
4
|
+
{
|
|
5
|
+
"name": "clion",
|
|
6
|
+
"displayName": "CLion (VS 2022 x64)",
|
|
7
|
+
"generator": "Visual Studio 17 2022",
|
|
8
|
+
"architecture": "x64",
|
|
9
|
+
"binaryDir": "${sourceDir}/build/clion",
|
|
10
|
+
"cacheVariables": {
|
|
11
|
+
"Python3_EXECUTABLE": "${sourceDir}/../../.venv/Scripts/python.exe"
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"buildPresets": [
|
|
16
|
+
{
|
|
17
|
+
"name": "clion-debug",
|
|
18
|
+
"displayName": "Debug",
|
|
19
|
+
"configurePreset": "clion",
|
|
20
|
+
"configuration": "Debug"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "clion-release",
|
|
24
|
+
"displayName": "Release",
|
|
25
|
+
"configurePreset": "clion",
|
|
26
|
+
"configuration": "Release"
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 10X CONCEPTS LLC, XXFIN LLC and contributors
|
|
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,53 @@
|
|
|
1
|
+
# py10x-fin-base-cxx (`cxxfin` import)
|
|
2
|
+
|
|
3
|
+
Native extension for **py10x-fin-base**. Dist name is `py10x-fin-base-cxx`; the import
|
|
4
|
+
module remains `cxxfin`. Install **`py10x-fin-base`** (not this package directly).
|
|
5
|
+
Built with pybind11 and scikit-build-core.
|
|
6
|
+
|
|
7
|
+
## Architecture
|
|
8
|
+
|
|
9
|
+
- `cxxfin.cpp` — pybind11 module source; `PYBIND11_MODULE` name is `cxxfin`
|
|
10
|
+
- `generate_stubs.py` — post-build stub generation; promotes `py10x_kernel` to `RTLD_GLOBAL` before importing `cxxfin` so that `BTraitable` typeinfo is visible (macOS flat namespace requirement)
|
|
11
|
+
- Headers fetched from `cxx10x` at the exact git commit matching the installed `py10x_kernel` binary (version string contains the hash)
|
|
12
|
+
|
|
13
|
+
## Subclassing py10x_kernel types
|
|
14
|
+
|
|
15
|
+
`py10x_kernel` is built with `CXX_VISIBILITY_PRESET default` so its vtables and typeinfo are exported. On import it promotes itself to `RTLD_GLOBAL` via `dladdr` + `dlopen(RTLD_NOW | RTLD_GLOBAL | RTLD_NOLOAD)`, making its symbols visible to subsequently loaded extension modules. `py10x_kernel` must be imported before `cxxfin` — this holds in normal usage since it is always loaded as part of the `py10x-core` import chain.
|
|
16
|
+
|
|
17
|
+
## Incremental, automatic rebuild
|
|
18
|
+
|
|
19
|
+
`cxxfin` is automatically rebuilt on `import cxxfin` whenever the sources changed.
|
|
20
|
+
|
|
21
|
+
## Clean rebuild
|
|
22
|
+
|
|
23
|
+
Needed when changing build structure, e.g. adding source files, editing `CMakeLists.txt`):
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
uv pip uninstall py10x-fin-base-cxx
|
|
27
|
+
rm -rf .venv/py10x-build/cxxfin
|
|
28
|
+
uv sync --reinstall-package py10x-fin-base-cxx
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
- `uv pip uninstall py10x-fin-base-cxx` — removes the editable finder from site-packages, which
|
|
32
|
+
otherwise intercepts `import cxxfin` during stub generation and causes a circular rebuild
|
|
33
|
+
failure
|
|
34
|
+
- `rm -rf .venv/py10x-build/cxxfin` — wipes the stale CMake cache
|
|
35
|
+
- `uv sync --reinstall-package py10x-fin-base-cxx` — rebuilds and reinstalls from scratch
|
|
36
|
+
|
|
37
|
+
Normal development (edit C++ source → run) does not require this; the editable rebuild fires
|
|
38
|
+
automatically on import.
|
|
39
|
+
|
|
40
|
+
## Debug build
|
|
41
|
+
|
|
42
|
+
`cxxfin` builds `Release` by default. For `Debug` build, set the build type via
|
|
43
|
+
scikit-build-core's env override and re-run uv sync, for example:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
SKBUILD_CMAKE_BUILD_TYPE=Debug uv sync --reinstall-package py10x-fin-base-cxx
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The build type is fixed at sync time (baked into the editable install along with the
|
|
50
|
+
build-dir), so switching is just another sync — `SKBUILD_CMAKE_BUILD_TYPE=Debug uv sync --reinstall-package py10x-fin-base-cxx`
|
|
51
|
+
for Debug, plain `uv sync --reinstall-package py10x-fin-base-cxx` for Release. Because each type has its own
|
|
52
|
+
tree under `.venv/py10x-build/cxxfin/<Debug|Release>/`, switching does not rebuild from
|
|
53
|
+
scratch.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <cmath>
|
|
4
|
+
|
|
5
|
+
struct BCompounding {
|
|
6
|
+
static constexpr int SIMPLE = 0;
|
|
7
|
+
static constexpr int ANNUAL = 1;
|
|
8
|
+
static constexpr int SEMI_ANNUAL = 2;
|
|
9
|
+
static constexpr int QUARTERLY = 3;
|
|
10
|
+
static constexpr int MONTHLY = 4;
|
|
11
|
+
static constexpr int WEEKLY = 5;
|
|
12
|
+
static constexpr int CONTINUOUS = 6;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
struct BCompoundTransform {
|
|
16
|
+
static constexpr int RATE_TO_ACCRUAL = 0;
|
|
17
|
+
static constexpr int ACCRUAL_TO_RATE = 1;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
namespace bcompounding_detail {
|
|
21
|
+
|
|
22
|
+
using CompFn = double(*)(double t, double v);
|
|
23
|
+
|
|
24
|
+
//-- (t, r) -> accrual factor
|
|
25
|
+
inline double simple_r2a(double t, double r) { return 1.0 + r * t; }
|
|
26
|
+
inline double annual_r2a(double t, double r) { return std::pow(1.0 + r, t ); }
|
|
27
|
+
inline double semi_r2a (double t, double r) { return std::pow(1.0 + r / 2.0, t * 2.0); }
|
|
28
|
+
inline double qrtr_r2a (double t, double r) { return std::pow(1.0 + r / 4.0, t * 4.0); }
|
|
29
|
+
inline double mnth_r2a (double t, double r) { return std::pow(1.0 + r / 12.0, t * 12.0); }
|
|
30
|
+
inline double wkly_r2a (double t, double r) { return std::pow(1.0 + r / 52.0, t * 52.0); }
|
|
31
|
+
inline double cont_r2a (double t, double r) { return std::exp(r * t); }
|
|
32
|
+
|
|
33
|
+
//-- (t, a) -> rate
|
|
34
|
+
inline double simple_a2r(double t, double a) { return t ? (a - 1.0) / t : 0.0; }
|
|
35
|
+
inline double annual_a2r(double t, double a) { return t ? std::pow(a, 1.0 / t ) - 1.0 : 0.0; }
|
|
36
|
+
inline double semi_a2r (double t, double a) { return t ? (std::pow(a, 1.0 / (t * 2.0)) - 1.0) * 2.0 : 0.0; }
|
|
37
|
+
inline double qrtr_a2r (double t, double a) { return t ? (std::pow(a, 1.0 / (t * 4.0)) - 1.0) * 4.0 : 0.0; }
|
|
38
|
+
inline double mnth_a2r (double t, double a) { return t ? (std::pow(a, 1.0 / (t * 12.0)) - 1.0) * 12.0 : 0.0; }
|
|
39
|
+
inline double wkly_a2r (double t, double a) { return t ? (std::pow(a, 1.0 / (t * 52.0)) - 1.0) * 52.0 : 0.0; }
|
|
40
|
+
inline double cont_a2r (double t, double a) { return t ? std::log(a) / t : 0.0; }
|
|
41
|
+
|
|
42
|
+
} // namespace bcompounding_detail
|
|
43
|
+
|
|
44
|
+
//-- [BCompounding index][BCompoundTransform index]
|
|
45
|
+
inline double compounding_apply(int comp, int transform, double t, double v) {
|
|
46
|
+
using namespace bcompounding_detail;
|
|
47
|
+
static const CompFn matrix[][2] = {
|
|
48
|
+
{ simple_r2a, simple_a2r }, // SIMPLE
|
|
49
|
+
{ annual_r2a, annual_a2r }, // ANNUAL
|
|
50
|
+
{ semi_r2a, semi_a2r }, // SEMI_ANNUAL
|
|
51
|
+
{ qrtr_r2a, qrtr_a2r }, // QUARTERLY
|
|
52
|
+
{ mnth_r2a, mnth_a2r }, // MONTHLY
|
|
53
|
+
{ wkly_r2a, wkly_a2r }, // WEEKLY
|
|
54
|
+
{ cont_r2a, cont_a2r }, // CONTINUOUS
|
|
55
|
+
};
|
|
56
|
+
return matrix[comp][transform](t, v);
|
|
57
|
+
}
|