VelesQuant 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 (198) hide show
  1. velesquant-0.1.0/.github/workflows/build_wheels.yml +245 -0
  2. velesquant-0.1.0/.gitignore +78 -0
  3. velesquant-0.1.0/CMakeLists.txt +154 -0
  4. velesquant-0.1.0/CODE_OF_CONDUCT.md +128 -0
  5. velesquant-0.1.0/LICENSE +21 -0
  6. velesquant-0.1.0/PKG-INFO +157 -0
  7. velesquant-0.1.0/README.md +120 -0
  8. velesquant-0.1.0/benchmarks/bench_calibration.py +139 -0
  9. velesquant-0.1.0/bindings/bind_common.h +29 -0
  10. velesquant-0.1.0/bindings/bind_enums.cpp +97 -0
  11. velesquant-0.1.0/bindings/bind_exceptions.cpp +60 -0
  12. velesquant-0.1.0/bindings/bind_utility.cpp +32 -0
  13. velesquant-0.1.0/bindings/models/bind_basket.cpp +22 -0
  14. velesquant-0.1.0/bindings/models/bind_cms.cpp +112 -0
  15. velesquant-0.1.0/bindings/models/bind_heston.cpp +80 -0
  16. velesquant-0.1.0/bindings/models/bind_hull_white.cpp +47 -0
  17. velesquant-0.1.0/bindings/models/bind_hybrid.cpp +70 -0
  18. velesquant-0.1.0/bindings/models/bind_local_vol.cpp +39 -0
  19. velesquant-0.1.0/bindings/models/bind_sabr.cpp +75 -0
  20. velesquant-0.1.0/bindings/models/bind_swaption.cpp +24 -0
  21. velesquant-0.1.0/bindings/models/bind_trees.cpp +36 -0
  22. velesquant-0.1.0/bindings/module.cpp +60 -0
  23. velesquant-0.1.0/bindings/pde_solvers/bind_pde_solvers.cpp +196 -0
  24. velesquant-0.1.0/cmake/FindQuantLib.cmake +35 -0
  25. velesquant-0.1.0/docs/README.md +113 -0
  26. velesquant-0.1.0/docs/model_documentation_template.md +222 -0
  27. velesquant-0.1.0/docs/models/README.md +22 -0
  28. velesquant-0.1.0/docs/models/basket.md +146 -0
  29. velesquant-0.1.0/docs/models/cms.md +148 -0
  30. velesquant-0.1.0/docs/models/cms_spread.md +134 -0
  31. velesquant-0.1.0/docs/models/heston.md +294 -0
  32. velesquant-0.1.0/docs/models/hullwhite.md +279 -0
  33. velesquant-0.1.0/docs/models/hybrid_hw.md +125 -0
  34. velesquant-0.1.0/docs/models/localvol.md +136 -0
  35. velesquant-0.1.0/docs/models/quantoed.md +97 -0
  36. velesquant-0.1.0/docs/models/sabr.md +288 -0
  37. velesquant-0.1.0/docs/models/short_rate.md +244 -0
  38. velesquant-0.1.0/docs/models/swaption_sabr.md +134 -0
  39. velesquant-0.1.0/docs/python_api.md +222 -0
  40. velesquant-0.1.0/docs/research_interface_design.md +116 -0
  41. velesquant-0.1.0/docs/supported_instruments.md +52 -0
  42. velesquant-0.1.0/examples/equity_fx.py +133 -0
  43. velesquant-0.1.0/examples/interest_rates.py +154 -0
  44. velesquant-0.1.0/examples/pde_benchmark.py +64 -0
  45. velesquant-0.1.0/examples/portfolio_pricing.py +153 -0
  46. velesquant-0.1.0/include/velesquant/constants.h +51 -0
  47. velesquant-0.1.0/include/velesquant/engines/hullwhite_analytic_engine.h +140 -0
  48. velesquant-0.1.0/include/velesquant/engines/swaption_engine.h +77 -0
  49. velesquant-0.1.0/include/velesquant/errors.h +31 -0
  50. velesquant-0.1.0/include/velesquant/instruments/instrument.h +19 -0
  51. velesquant-0.1.0/include/velesquant/instruments/swaption.h +41 -0
  52. velesquant-0.1.0/include/velesquant/models/black_formula.h +47 -0
  53. velesquant-0.1.0/include/velesquant/models/black_scholes.h +29 -0
  54. velesquant-0.1.0/include/velesquant/models/cms.h +71 -0
  55. velesquant-0.1.0/include/velesquant/models/cms_spread.h +60 -0
  56. velesquant-0.1.0/include/velesquant/models/concepts.h +41 -0
  57. velesquant-0.1.0/include/velesquant/models/hullwhite_calibrator.h +51 -0
  58. velesquant-0.1.0/include/velesquant/models/hullwhite_model.h +79 -0
  59. velesquant-0.1.0/include/velesquant/models/log_basket.h +46 -0
  60. velesquant-0.1.0/include/velesquant/models/model_utils.h +110 -0
  61. velesquant-0.1.0/include/velesquant/models/quantoed_cms.h +41 -0
  62. velesquant-0.1.0/include/velesquant/models/quantoed_cms_spread.h +39 -0
  63. velesquant-0.1.0/include/velesquant/models/short_rate_1f_model.h +77 -0
  64. velesquant-0.1.0/include/velesquant/models/short_rate_2f_model.h +72 -0
  65. velesquant-0.1.0/include/velesquant/models/solver.h +41 -0
  66. velesquant-0.1.0/include/velesquant/models/swaption.h +53 -0
  67. velesquant-0.1.0/include/velesquant/models/utility.h +75 -0
  68. velesquant-0.1.0/include/velesquant/numerics/interpolation.h +17 -0
  69. velesquant-0.1.0/include/velesquant/numerics/tri_diag_matrix.h +19 -0
  70. velesquant-0.1.0/include/velesquant/pde_solvers/cyclic_reduction.h +133 -0
  71. velesquant-0.1.0/include/velesquant/pde_solvers/hw_pde.h +755 -0
  72. velesquant-0.1.0/include/velesquant/pde_solvers/interpolators.h +17 -0
  73. velesquant-0.1.0/include/velesquant/pde_solvers/pde_utility.h +47 -0
  74. velesquant-0.1.0/include/velesquant/pde_solvers/sabr_pde.h +344 -0
  75. velesquant-0.1.0/include/velesquant/pde_solvers/short_rate_1f_pde.h +823 -0
  76. velesquant-0.1.0/include/velesquant/pde_solvers/short_rate_2f_pde.h +1331 -0
  77. velesquant-0.1.0/include/velesquant/types.h +111 -0
  78. velesquant-0.1.0/include/velesquant/volatility/c_tree.h +67 -0
  79. velesquant-0.1.0/include/velesquant/volatility/heston_pde.h +37 -0
  80. velesquant-0.1.0/include/velesquant/volatility/hhw.h +48 -0
  81. velesquant-0.1.0/include/velesquant/volatility/hhw_pde.h +117 -0
  82. velesquant-0.1.0/include/velesquant/volatility/l_vol.h +76 -0
  83. velesquant-0.1.0/include/velesquant/volatility/lm.h +34 -0
  84. velesquant-0.1.0/include/velesquant/volatility/s_vol.h +110 -0
  85. velesquant-0.1.0/include/velesquant/volatility/sabr.h +146 -0
  86. velesquant-0.1.0/include/velesquant/volatility/schobzhu.h +77 -0
  87. velesquant-0.1.0/include/velesquant/volatility/skew_mc.h +43 -0
  88. velesquant-0.1.0/include/velesquant/volatility/svolt.h +160 -0
  89. velesquant-0.1.0/include/velesquant/volatility/termstructure.h +272 -0
  90. velesquant-0.1.0/inspect_localvol.py +3 -0
  91. velesquant-0.1.0/pyproject.toml +95 -0
  92. velesquant-0.1.0/scripts/ci_install_boost.sh +101 -0
  93. velesquant-0.1.0/scripts/ci_install_quantlib.sh +47 -0
  94. velesquant-0.1.0/scripts/clean_all.sh +40 -0
  95. velesquant-0.1.0/scripts/configure_dev.sh +21 -0
  96. velesquant-0.1.0/scripts/run_checks.sh +8 -0
  97. velesquant-0.1.0/src/engines/hullwhite_analytic_engine.cpp +6 -0
  98. velesquant-0.1.0/src/engines/swaption_engine.cpp +8 -0
  99. velesquant-0.1.0/src/models/black_scholes.cpp +28 -0
  100. velesquant-0.1.0/src/models/cms.cpp +165 -0
  101. velesquant-0.1.0/src/models/cms_spread.cpp +148 -0
  102. velesquant-0.1.0/src/models/hullwhite_calibrator.cpp +254 -0
  103. velesquant-0.1.0/src/models/hullwhite_model.cpp +141 -0
  104. velesquant-0.1.0/src/models/log_basket.cpp +193 -0
  105. velesquant-0.1.0/src/models/quantoed_cms.cpp +68 -0
  106. velesquant-0.1.0/src/models/quantoed_cms_spread.cpp +49 -0
  107. velesquant-0.1.0/src/models/swaption.cpp +100 -0
  108. velesquant-0.1.0/src/models/utility.cpp +249 -0
  109. velesquant-0.1.0/src/numerics/interpolation.cpp +45 -0
  110. velesquant-0.1.0/src/numerics/tri_diag_matrix.cpp +31 -0
  111. velesquant-0.1.0/src/velesquant/__init__.py +97 -0
  112. velesquant-0.1.0/src/velesquant/_core.pyi +1300 -0
  113. velesquant-0.1.0/src/velesquant/instruments/__init__.py +0 -0
  114. velesquant-0.1.0/src/velesquant/instruments/base.py +12 -0
  115. velesquant-0.1.0/src/velesquant/instruments/bonds.py +32 -0
  116. velesquant-0.1.0/src/velesquant/instruments/portfolio.py +33 -0
  117. velesquant-0.1.0/src/velesquant/instruments/rates.py +16 -0
  118. velesquant-0.1.0/src/velesquant/market/__init__.py +0 -0
  119. velesquant-0.1.0/src/velesquant/market/base.py +27 -0
  120. velesquant-0.1.0/src/velesquant/market/container.py +78 -0
  121. velesquant-0.1.0/src/velesquant/market/curves.py +41 -0
  122. velesquant-0.1.0/src/velesquant/market/enums.py +17 -0
  123. velesquant-0.1.0/src/velesquant/models/__init__.py +19 -0
  124. velesquant-0.1.0/src/velesquant/models/base.py +282 -0
  125. velesquant-0.1.0/src/velesquant/models/basket.py +76 -0
  126. velesquant-0.1.0/src/velesquant/models/cms.py +115 -0
  127. velesquant-0.1.0/src/velesquant/models/cms_spread.py +138 -0
  128. velesquant-0.1.0/src/velesquant/models/enums.py +42 -0
  129. velesquant-0.1.0/src/velesquant/models/heston.py +85 -0
  130. velesquant-0.1.0/src/velesquant/models/hullwhite.py +294 -0
  131. velesquant-0.1.0/src/velesquant/models/hybrid_hw.py +72 -0
  132. velesquant-0.1.0/src/velesquant/models/localvol.py +188 -0
  133. velesquant-0.1.0/src/velesquant/models/monte_carlo.py +52 -0
  134. velesquant-0.1.0/src/velesquant/models/pde_solvers.py +460 -0
  135. velesquant-0.1.0/src/velesquant/models/quantoed_cms.py +111 -0
  136. velesquant-0.1.0/src/velesquant/models/quantoed_cms_spread.py +146 -0
  137. velesquant-0.1.0/src/velesquant/models/sabr.py +101 -0
  138. velesquant-0.1.0/src/velesquant/models/schobel_zhu.py +147 -0
  139. velesquant-0.1.0/src/velesquant/models/simulation.py +92 -0
  140. velesquant-0.1.0/src/velesquant/models/swaption_sabr.py +111 -0
  141. velesquant-0.1.0/src/velesquant/models/trees.py +106 -0
  142. velesquant-0.1.0/src/velesquant/py.typed +0 -0
  143. velesquant-0.1.0/src/volatility/c_tree.cpp +190 -0
  144. velesquant-0.1.0/src/volatility/hhw.cpp +79 -0
  145. velesquant-0.1.0/src/volatility/hhw_pde.cpp +489 -0
  146. velesquant-0.1.0/src/volatility/l_vol.cpp +757 -0
  147. velesquant-0.1.0/src/volatility/lm.cpp +1088 -0
  148. velesquant-0.1.0/src/volatility/s_vol.cpp +909 -0
  149. velesquant-0.1.0/src/volatility/sabr.cpp +624 -0
  150. velesquant-0.1.0/src/volatility/schobzhu.cpp +180 -0
  151. velesquant-0.1.0/src/volatility/skew_mc.cpp +174 -0
  152. velesquant-0.1.0/src/volatility/svolt.cpp +613 -0
  153. velesquant-0.1.0/src/volatility/termstructure.cpp +75 -0
  154. velesquant-0.1.0/tests/core/test_general.py +38 -0
  155. velesquant-0.1.0/tests/market/test_container.py +39 -0
  156. velesquant-0.1.0/tests/market/test_curves.py +31 -0
  157. velesquant-0.1.0/tests/market/test_serialization.py +28 -0
  158. velesquant-0.1.0/tests/models/test_base_sensitivities.py +24 -0
  159. velesquant-0.1.0/tests/models/test_cms.py +54 -0
  160. velesquant-0.1.0/tests/models/test_cms_spread.py +162 -0
  161. velesquant-0.1.0/tests/models/test_expansion.py +51 -0
  162. velesquant-0.1.0/tests/models/test_heston.py +79 -0
  163. velesquant-0.1.0/tests/models/test_heston_hw.py +13 -0
  164. velesquant-0.1.0/tests/models/test_hull_white.py +101 -0
  165. velesquant-0.1.0/tests/models/test_hullwhite_market.py +42 -0
  166. velesquant-0.1.0/tests/models/test_hullwhite_serialization.py +22 -0
  167. velesquant-0.1.0/tests/models/test_l_basket.py +53 -0
  168. velesquant-0.1.0/tests/models/test_local_vol.py +105 -0
  169. velesquant-0.1.0/tests/models/test_pde_solvers.py +109 -0
  170. velesquant-0.1.0/tests/models/test_quantoed_cms.py +89 -0
  171. velesquant-0.1.0/tests/models/test_quantoed_cms_spread.py +105 -0
  172. velesquant-0.1.0/tests/models/test_sabr.py +87 -0
  173. velesquant-0.1.0/tests/models/test_schobzhu.py +115 -0
  174. velesquant-0.1.0/tests/models/test_simulation.py +72 -0
  175. velesquant-0.1.0/tests/models/test_skew_mc.py +46 -0
  176. velesquant-0.1.0/tests/models/test_swaption.py +61 -0
  177. velesquant-0.1.0/tests/models/test_tree.py +91 -0
  178. velesquant-0.1.0/tests/pde/test_fi_pde.py +87 -0
  179. velesquant-0.1.0/tests/pde/test_hwpde_advanced.py +169 -0
  180. velesquant-0.1.0/tests/pde/test_pde_grid_params.py +137 -0
  181. velesquant-0.1.0/tests/pde/test_sabr_pde.py +83 -0
  182. velesquant-0.1.0/tests/pde/test_short_rate_1f.py +67 -0
  183. velesquant-0.1.0/tests/pde/test_short_rate_2f.py +86 -0
  184. velesquant-0.1.0/tests/termstructure/test_termstructure.py +47 -0
  185. velesquant-0.1.0/tests/test_interface_bond.py +44 -0
  186. velesquant-0.1.0/tests/test_interface_heston.py +58 -0
  187. velesquant-0.1.0/tests/test_interface_portfolio.py +42 -0
  188. velesquant-0.1.0/tests/test_interface_prototype.py +32 -0
  189. velesquant-0.1.0/tests/test_interface_sabr.py +40 -0
  190. velesquant-0.1.0/tests/test_interface_vectorization.py +55 -0
  191. velesquant-0.1.0/tests/test_model_pricing_validation.py +162 -0
  192. velesquant-0.1.0/tests_cpp/CMakeLists.txt +16 -0
  193. velesquant-0.1.0/tests_cpp/test_hw.cpp +151 -0
  194. velesquant-0.1.0/tests_cpp/test_pde.cpp +88 -0
  195. velesquant-0.1.0/tests_cpp/test_sabr.cpp +101 -0
  196. velesquant-0.1.0/tests_cpp/test_tree.cpp +98 -0
  197. velesquant-0.1.0/tests_cpp/test_utilities.cpp +77 -0
  198. velesquant-0.1.0/uv.lock +599 -0
@@ -0,0 +1,245 @@
1
+ name: Build Wheels
2
+
3
+ on:
4
+ push:
5
+ branches: [ "main" ]
6
+ paths-ignore:
7
+ - '**.md'
8
+ - 'docs/**'
9
+ pull_request:
10
+ branches: [ "main" ]
11
+ paths-ignore:
12
+ - '**.md'
13
+ - 'docs/**'
14
+ release:
15
+ types: [published]
16
+ workflow_dispatch:
17
+
18
+ jobs:
19
+ # ── Smoke test ────────────────────────────────────────────────────────────
20
+ # Runs on every push/PR. Builds one wheel (cp312-linux) to catch C++ and
21
+ # CMake breakage fast, without paying for the full 9-wheel matrix.
22
+ smoke_test:
23
+ name: Smoke test (cp312 linux)
24
+ runs-on: ubuntu-latest
25
+ if: github.event_name == 'push' || github.event_name == 'pull_request'
26
+
27
+ steps:
28
+ - uses: actions/checkout@v4
29
+
30
+ - name: Cache Boost
31
+ uses: actions/cache@v4
32
+ with:
33
+ path: ci_cache/boost
34
+ key: boost-1.83.0-manylinux2014-v4-${{ hashFiles('scripts/ci_install_boost.sh') }}
35
+
36
+ - name: Cache QuantLib
37
+ uses: actions/cache@v4
38
+ with:
39
+ path: ci_cache/quantlib
40
+ key: quantlib-v1.41-manylinux2014-v5-${{ hashFiles('scripts/ci_install_quantlib.sh') }}
41
+
42
+ - name: Cache ccache
43
+ uses: actions/cache@v4
44
+ with:
45
+ path: ci_cache/ccache
46
+ key: ccache-Linux-v4-${{ hashFiles('src/**/*.cpp', 'src/**/*.hpp', 'src/**/*.h', 'CMakeLists.txt', 'cmake/**') }}
47
+ restore-keys: |
48
+ ccache-Linux-v4-
49
+
50
+ - name: Create cache directories
51
+ run: |
52
+ mkdir -p ci_cache/quantlib ci_cache/boost
53
+
54
+ - name: Smoke-test build (cp312-manylinux_x86_64 only)
55
+ uses: pypa/cibuildwheel@v2.16.5
56
+ env:
57
+ CCACHE_DIR: "${{ github.workspace }}/ci_cache/ccache"
58
+ CIBW_ENVIRONMENT_LINUX: "SKBUILD_STRIP=false"
59
+ CIBW_CONTAINER_OPTIONS: "-v ${{ github.workspace }}/ci_cache/quantlib:/host/quantlib-cache -v ${{ github.workspace }}/ci_cache/boost:/host/boost-cache -v ${{ github.workspace }}/ci_cache/ccache:/host/ccache -e CCACHE_DIR=/host/ccache"
60
+ # Single wheel: cp312 linux only for fast feedback
61
+ CIBW_BUILD: cp312-manylinux_x86_64
62
+ CIBW_SKIP: "pp* *-musllinux_*"
63
+ CIBW_ARCHS_LINUX: "x86_64"
64
+ CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
65
+ CIBW_BEFORE_ALL_LINUX: >
66
+ yum install -y epel-release &&
67
+ yum install -y ccache &&
68
+ yum install -y wget tar gzip gcc-c++ make &&
69
+ if [ -f "{project}/scripts/ci_install_boost.sh" ]; then
70
+ echo "Running Boost install script..." &&
71
+ sh "{project}/scripts/ci_install_boost.sh"
72
+ else
73
+ echo "Boost install script not found" && exit 1
74
+ fi &&
75
+ yum install -y eigen3-devel &&
76
+ if [ -f "{project}/scripts/ci_install_quantlib.sh" ]; then
77
+ echo "Running QuantLib install script..." &&
78
+ sh "{project}/scripts/ci_install_quantlib.sh"
79
+ else
80
+ echo "QuantLib install script not found" && exit 1
81
+ fi
82
+ CIBW_TEST_COMMAND: pytest {project}/tests
83
+ CIBW_TEST_REQUIRES: "pytest numpy"
84
+ CMAKE_ARGS: >
85
+ -DBUILD_TESTING=OFF
86
+ -DBUILD_EXAMPLES=OFF
87
+ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
88
+ -DCMAKE_PREFIX_PATH="/usr/local"
89
+
90
+ # ── Full wheel build ───────────────────────────────────────────────────────
91
+ # Runs only on release or manual workflow_dispatch.
92
+ # Builds cp310/cp311/cp312 × linux + macOS-arm64 + macOS-intel.
93
+ build_wheels:
94
+ name: Build wheels on ${{ matrix.os }}
95
+ runs-on: ${{ matrix.os }}
96
+ if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
97
+ strategy:
98
+ fail-fast: false
99
+ matrix:
100
+ os: [ubuntu-latest, macos-14, macos-15-intel]
101
+
102
+ steps:
103
+ - uses: actions/checkout@v4
104
+
105
+ - name: Cache Boost
106
+ id: cache-boost
107
+ uses: actions/cache@v4
108
+ with:
109
+ path: ci_cache/boost
110
+ key: boost-1.83.0-manylinux2014-v4-${{ hashFiles('scripts/ci_install_boost.sh') }}
111
+
112
+ - name: Cache QuantLib
113
+ id: cache-quantlib
114
+ uses: actions/cache@v4
115
+ with:
116
+ path: ci_cache/quantlib
117
+ key: quantlib-v1.41-manylinux2014-v5-${{ hashFiles('scripts/ci_install_quantlib.sh') }}
118
+
119
+ - name: Cache ccache
120
+ uses: actions/cache@v4
121
+ with:
122
+ path: ci_cache/ccache
123
+ # Key on C++ sources + CMake, NOT the workflow file.
124
+ # This prevents workflow edits (e.g. skip flags) from busting the compiler cache.
125
+ key: ccache-${{ runner.os }}-v4-${{ hashFiles('src/**/*.cpp', 'src/**/*.hpp', 'src/**/*.h', 'CMakeLists.txt', 'cmake/**') }}
126
+ restore-keys: |
127
+ ccache-${{ runner.os }}-v4-
128
+
129
+ - name: Cache Homebrew packages (macOS)
130
+ if: runner.os == 'macOS'
131
+ uses: actions/cache@v4
132
+ with:
133
+ # Cache downloaded bottles; keyed on the install script so a dep upgrade busts it.
134
+ path: ~/Library/Caches/Homebrew
135
+ key: homebrew-${{ runner.os }}-${{ hashFiles('scripts/ci_install_*.sh', '.github/workflows/build_wheels.yml') }}
136
+ restore-keys: |
137
+ homebrew-${{ runner.os }}-
138
+
139
+ - name: Install dependencies (macOS)
140
+ if: runner.os == 'macOS'
141
+ run: |
142
+ # Install everything in one brew call to minimise resolver overhead.
143
+ # libomp is split-keg-only so we export its paths explicitly below.
144
+ brew install boost quantlib eigen ccache libomp
145
+ LIBOMP_DIR=$(brew --prefix libomp)
146
+ echo "LIBOMP_DIR=$LIBOMP_DIR" >> $GITHUB_ENV
147
+ # Make compiler and CMake find the headers and libs
148
+ echo "CPPFLAGS=-I$LIBOMP_DIR/include" >> $GITHUB_ENV
149
+ echo "CFLAGS=-I$LIBOMP_DIR/include" >> $GITHUB_ENV
150
+ echo "CXXFLAGS=-I$LIBOMP_DIR/include" >> $GITHUB_ENV
151
+ echo "LDFLAGS=-L$LIBOMP_DIR/lib" >> $GITHUB_ENV
152
+ # Provide CMake args so FindOpenMP can pick up the flags on macOS
153
+ echo "CMAKE_ARGS=-DOpenMP_C_FLAGS='-Xpreprocessor -fopenmp -I$LIBOMP_DIR/include' -DOpenMP_CXX_FLAGS='-Xpreprocessor -fopenmp -I$LIBOMP_DIR/include' -DOpenMP_C_LIB_NAMES='omp' -DOpenMP_CXX_LIB_NAMES='omp'" >> $GITHUB_ENV
154
+
155
+ - name: Create Cache Directory (Ensure exists)
156
+ run: |
157
+ mkdir -p ci_cache/quantlib
158
+ mkdir -p ci_cache/boost
159
+
160
+ - name: Build wheels
161
+ uses: pypa/cibuildwheel@v2.16.5
162
+ env:
163
+ CCACHE_DIR: "${{ github.workspace }}/ci_cache/ccache"
164
+ CIBW_ENVIRONMENT_LINUX: "SKBUILD_STRIP=false"
165
+ CIBW_CONTAINER_OPTIONS: "-v ${{ github.workspace }}/ci_cache/quantlib:/host/quantlib-cache -v ${{ github.workspace }}/ci_cache/boost:/host/boost-cache -v ${{ github.workspace }}/ci_cache/ccache:/host/ccache -e CCACHE_DIR=/host/ccache"
166
+ CIBW_BUILD: cp310-* cp311-* cp312-*
167
+ # Skip PyPy and musllinux (Alpine-based) builds.
168
+ # musllinux containers don't have yum; our CIBW_BEFORE_ALL_LINUX uses yum.
169
+ # Only manylinux_2_28 (glibc) wheels are targeted by this config.
170
+ CIBW_SKIP: "pp* *-musllinux_*"
171
+ CIBW_ARCHS_LINUX: "x86_64"
172
+ CIBW_ARCHS_MACOS: "auto"
173
+ # Use manylinux_2_28 for C++20 support (modern GCC)
174
+ CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
175
+ CIBW_BEFORE_ALL_LINUX: >
176
+ yum install -y epel-release &&
177
+ yum install -y ccache &&
178
+ yum install -y wget tar gzip gcc-c++ make &&
179
+ if [ -f "{project}/scripts/ci_install_boost.sh" ]; then
180
+ echo "Running Boost install script..." &&
181
+ sh "{project}/scripts/ci_install_boost.sh"
182
+ else
183
+ echo "Boost install script not found at {project}/scripts/ci_install_boost.sh" && exit 1
184
+ fi &&
185
+ yum install -y eigen3-devel &&
186
+ if [ -f "{project}/scripts/ci_install_quantlib.sh" ]; then
187
+ echo "Running QuantLib install script..." &&
188
+ sh "{project}/scripts/ci_install_quantlib.sh"
189
+ else
190
+ echo "QuantLib install script not found at {project}/scripts/ci_install_quantlib.sh" && exit 1
191
+ fi
192
+ CIBW_TEST_COMMAND: >
193
+ export SITE_PKG=$(pip show velesquant | grep Location | awk '{print $2}')/velesquant &&
194
+ echo "Install loc: '${SITE_PKG}'" &&
195
+ ls -R ${SITE_PKG} &&
196
+ echo "Searching for _core.so..." &&
197
+ SO_FILE=$(find ${SITE_PKG} -name "_core*.so" | head -n 1) &&
198
+ echo "Found SO: $SO_FILE" &&
199
+ nm -D $SO_FILE || true &&
200
+ objdump -T $SO_FILE || true &&
201
+ pytest {project}/tests
202
+ CIBW_TEST_REQUIRES: "pytest numpy"
203
+ CMAKE_ARGS: >
204
+ ${{ env.CMAKE_ARGS }}
205
+ -DBUILD_TESTING=OFF
206
+ -DBUILD_EXAMPLES=OFF
207
+ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
208
+ -DCMAKE_PREFIX_PATH="/usr/local"
209
+
210
+ - uses: actions/upload-artifact@v4
211
+ with:
212
+ name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
213
+ path: ./wheelhouse/*.whl
214
+
215
+ make_sdist:
216
+ name: Make SDist
217
+ runs-on: ubuntu-latest
218
+ steps:
219
+ - uses: actions/checkout@v4
220
+
221
+ - name: Build SDist
222
+ run: pipx run build --sdist
223
+
224
+ - uses: actions/upload-artifact@v4
225
+ with:
226
+ name: cibw-sdist
227
+ path: dist/*.tar.gz
228
+
229
+ publish_to_pypi:
230
+ needs: [build_wheels, make_sdist]
231
+ runs-on: ubuntu-latest
232
+ environment:
233
+ name: pypi
234
+ url: https://pypi.org/p/VelesQuant
235
+ permissions:
236
+ id-token: write
237
+ if: github.event_name == 'release' && github.event.action == 'published'
238
+ steps:
239
+ - uses: actions/download-artifact@v4
240
+ with:
241
+ pattern: cibw-*
242
+ path: dist
243
+ merge-multiple: true
244
+
245
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,78 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ share/python-wheels/
20
+ *.egg-info/
21
+ .installed.cfg
22
+ *.egg
23
+ MANIFEST
24
+ .mypy_cache
25
+ .ruff_cache
26
+ # Poetry
27
+ .venv/
28
+
29
+ # CMake
30
+ cmake-build-*/
31
+ CMakeFiles/
32
+ CMakeCache.txt
33
+ cmake_install.cmake
34
+ CTestTestfile.cmake
35
+ _deps/
36
+ Makefile
37
+
38
+ # C++
39
+ *.d
40
+ *.o
41
+ *.obj
42
+ *.ilib
43
+ *.run
44
+ *.gcda
45
+ *.gcno
46
+ *.gcov
47
+ *.a
48
+ *.dylib
49
+
50
+ # Mac
51
+ .DS_Store
52
+
53
+ # IDEs
54
+ .vscode/
55
+ .idea/
56
+
57
+ # Testing
58
+ .pytest_cache/
59
+ htmlcov/
60
+ .coverage
61
+ .coverage.*
62
+ Testing/
63
+ tests_cpp/velesquant_tests
64
+ tests_cpp/*_tests.cmake
65
+ tests_cpp/*_include.cmake
66
+ tests_cpp/cmake_test_discovery_*.json
67
+
68
+ # Custom
69
+ test_output/
70
+ # *.txt <-- Removed to support CMakeLists.txt
71
+ build_tests/
72
+ build_coverage/
73
+ build_debug/
74
+ build_core/
75
+ .cache
76
+ .agent
77
+ *.whlsrc/velesquant/_version.py
78
+ src/velesquant/_version.py
@@ -0,0 +1,154 @@
1
+ cmake_minimum_required(VERSION 3.15)
2
+ project(velesquant LANGUAGES CXX)
3
+
4
+ set(CMAKE_CXX_STANDARD 20)
5
+ set(CMAKE_CXX_STANDARD_REQUIRED ON)
6
+ # Globally disable LTO to prevent symbol stripping/lto-slim artifacts in extensions
7
+ set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF)
8
+
9
+ if(MSVC)
10
+ add_compile_options(/W4)
11
+ else()
12
+ add_compile_options(-Wall -Wextra -Wshadow -Wno-unused-variable -Wno-unused-but-set-variable -Wno-sign-compare)
13
+ endif()
14
+
15
+ # Find Dependencies
16
+ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
17
+
18
+ find_package(QuantLib REQUIRED)
19
+ set(Boost_USE_STATIC_LIBS ON)
20
+ find_package(Boost REQUIRED)
21
+ find_package(Python3 COMPONENTS Interpreter Development.Module REQUIRED)
22
+ # Handle pybind11 matching the Python version
23
+ execute_process(
24
+ COMMAND "${Python3_EXECUTABLE}" -c "import pybind11; print(pybind11.get_cmake_dir())"
25
+ OUTPUT_VARIABLE _pybind11_cmake_dir
26
+ OUTPUT_STRIP_TRAILING_WHITESPACE
27
+ )
28
+ list(APPEND CMAKE_PREFIX_PATH "${_pybind11_cmake_dir}")
29
+ find_package(pybind11 CONFIG REQUIRED)
30
+ find_package(Eigen3 QUIET)
31
+
32
+ # If Eigen3 not found via config, try standard include paths or environment variables
33
+ if(NOT EIGEN3_INCLUDE_DIR AND NOT TARGET Eigen3::Eigen)
34
+ find_path(EIGEN3_INCLUDE_DIR NAMES Eigen/Core
35
+ HINTS ${EIGEN3_ROOT} $ENV{EIGEN3_ROOT} /opt/homebrew/include/eigen3 /opt/homebrew/include
36
+ PATH_SUFFIXES include/eigen3 include
37
+ )
38
+ endif()
39
+
40
+ message(STATUS "Eigen3 include dir: ${EIGEN3_INCLUDE_DIR}")
41
+
42
+ # OpenMP Check (set variables here, apply to targets later)
43
+ find_package(OpenMP)
44
+ set(USE_OPENMP_FALLBACK FALSE)
45
+ if(NOT OpenMP_FOUND AND APPLE)
46
+ # Fallback for Homebrew OpenMP on macOS
47
+ set(OMP_HOMEBREW_ROOT "")
48
+ if(EXISTS "/opt/homebrew/opt/libomp")
49
+ set(OMP_HOMEBREW_ROOT "/opt/homebrew/opt/libomp")
50
+ elseif(EXISTS "/usr/local/opt/libomp")
51
+ set(OMP_HOMEBREW_ROOT "/usr/local/opt/libomp")
52
+ endif()
53
+
54
+ if(OMP_HOMEBREW_ROOT)
55
+ message(STATUS "Found Homebrew OpenMP at ${OMP_HOMEBREW_ROOT}")
56
+ set(USE_OPENMP_FALLBACK TRUE)
57
+ set(OMP_FALLBACK_INCLUDE "${OMP_HOMEBREW_ROOT}/include")
58
+ set(OMP_FALLBACK_LIB "${OMP_HOMEBREW_ROOT}/lib/libomp.dylib")
59
+ else()
60
+ message(WARNING "OpenMP not found. Compilation may fail if code relies on <omp.h>")
61
+ endif()
62
+ endif()
63
+
64
+ include(FetchContent)
65
+ FetchContent_Declare(
66
+ googletest
67
+ URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip
68
+ )
69
+ # For Windows: Prevent overriding the parent project's compiler/linker settings
70
+ set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
71
+ FetchContent_MakeAvailable(googletest)
72
+
73
+ enable_testing()
74
+
75
+ # Collect Source Files
76
+ file(GLOB_RECURSE SOURCES
77
+ "src/volatility/*.cpp"
78
+ "src/pde_solvers/*.cpp"
79
+ "src/models/*.cpp"
80
+ "src/engines/*.cpp"
81
+ "src/instruments/*.cpp"
82
+ "src/numerics/*.cpp"
83
+ )
84
+ list(FILTER SOURCES EXCLUDE REGEX "test_simplex.cpp")
85
+
86
+ # Create the Core C++ Library
87
+ add_library(velesquant_core STATIC ${SOURCES})
88
+ set_target_properties(velesquant_core PROPERTIES
89
+ POSITION_INDEPENDENT_CODE ON
90
+ INTERPROCEDURAL_OPTIMIZATION FALSE
91
+ )
92
+ target_compile_options(velesquant_core PRIVATE -fno-lto)
93
+
94
+ target_link_libraries(velesquant_core
95
+ PRIVATE
96
+ ${QuantLib_LIBRARIES}
97
+ ${Boost_LIBRARIES}
98
+ )
99
+ target_include_directories(velesquant_core PUBLIC include)
100
+ target_include_directories(velesquant_core SYSTEM PUBLIC
101
+ ${QuantLib_INCLUDE_DIRS}
102
+ ${Boost_INCLUDE_DIRS}
103
+ ${EIGEN3_INCLUDE_DIR}
104
+ )
105
+
106
+ if(TARGET Eigen3::Eigen)
107
+ target_link_libraries(velesquant_core PUBLIC Eigen3::Eigen)
108
+ endif()
109
+
110
+ # Apply OpenMP settings
111
+ if(OpenMP_FOUND)
112
+ target_link_libraries(velesquant_core PRIVATE OpenMP::OpenMP_CXX)
113
+ elseif(USE_OPENMP_FALLBACK)
114
+ target_compile_options(velesquant_core PUBLIC -Xpreprocessor -fopenmp)
115
+ target_include_directories(velesquant_core PUBLIC "${OMP_FALLBACK_INCLUDE}")
116
+ target_link_libraries(velesquant_core PUBLIC "${OMP_FALLBACK_LIB}")
117
+ endif()
118
+
119
+ # Create the Python Extension Module (modular bindings)
120
+ pybind11_add_module(_core
121
+ bindings/module.cpp
122
+ bindings/bind_enums.cpp
123
+ bindings/bind_exceptions.cpp
124
+ bindings/bind_utility.cpp
125
+ bindings/models/bind_heston.cpp
126
+ bindings/models/bind_hull_white.cpp
127
+ bindings/models/bind_sabr.cpp
128
+ bindings/models/bind_local_vol.cpp
129
+ bindings/models/bind_swaption.cpp
130
+ bindings/models/bind_cms.cpp
131
+ bindings/models/bind_basket.cpp
132
+ bindings/models/bind_hybrid.cpp
133
+ bindings/models/bind_trees.cpp
134
+ bindings/pde_solvers/bind_pde_solvers.cpp
135
+ )
136
+
137
+
138
+
139
+ target_link_libraries(_core PRIVATE velesquant_core)
140
+ set_target_properties(_core PROPERTIES
141
+ INTERPROCEDURAL_OPTIMIZATION FALSE
142
+ CXX_VISIBILITY_PRESET default
143
+ )
144
+ target_compile_options(_core PRIVATE -fno-lto -fvisibility=default)
145
+ target_link_options(_core PRIVATE -fno-lto -fvisibility=default)
146
+ if(UNIX AND NOT APPLE)
147
+ target_link_options(_core PRIVATE -Wl,--export-dynamic)
148
+ endif()
149
+
150
+ # Install the module to the python package
151
+ install(TARGETS _core DESTINATION velesquant)
152
+
153
+ # Tests
154
+ add_subdirectory(tests_cpp)
@@ -0,0 +1,128 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, religion, or sexual identity
10
+ and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the
26
+ overall community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or
31
+ advances of any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email
35
+ address, without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official e-mail address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ .
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series
86
+ of actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or
93
+ permanent ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within
113
+ the community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.0, available at
119
+ https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120
+
121
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct
122
+ enforcement ladder](https://github.com/mozilla/diversity).
123
+
124
+ [homepage]: https://www.contributor-covenant.org
125
+
126
+ For answers to common questions about this code of conduct, see the FAQ at
127
+ https://www.contributor-covenant.org/faq. Translations are available at
128
+ https://www.contributor-covenant.org/translations.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Suren Islyaev
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.