quantark 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 (401) hide show
  1. quantark-0.1.0/.gitignore +12 -0
  2. quantark-0.1.0/CHANGELOG.md +34 -0
  3. quantark-0.1.0/LICENSE +202 -0
  4. quantark-0.1.0/NOTICE +2 -0
  5. quantark-0.1.0/PKG-INFO +351 -0
  6. quantark-0.1.0/README.md +312 -0
  7. quantark-0.1.0/pyproject.toml +65 -0
  8. quantark-0.1.0/quantark/__init__.py +3 -0
  9. quantark-0.1.0/quantark/_compat.py +150 -0
  10. quantark-0.1.0/quantark/asset/__init__.py +8 -0
  11. quantark-0.1.0/quantark/asset/bond/__init__.py +2 -0
  12. quantark-0.1.0/quantark/asset/bond/engine/__init__.py +44 -0
  13. quantark-0.1.0/quantark/asset/bond/engine/analytical/__init__.py +12 -0
  14. quantark-0.1.0/quantark/asset/bond/engine/analytical/black_engine.py +583 -0
  15. quantark-0.1.0/quantark/asset/bond/engine/analytical/bond_forward_engine.py +390 -0
  16. quantark-0.1.0/quantark/asset/bond/engine/analytical/bond_futures_engine.py +569 -0
  17. quantark-0.1.0/quantark/asset/bond/engine/convertible/__init__.py +12 -0
  18. quantark-0.1.0/quantark/asset/bond/engine/convertible/convertible_bond_engine.py +800 -0
  19. quantark-0.1.0/quantark/asset/bond/engine/discount/__init__.py +10 -0
  20. quantark-0.1.0/quantark/asset/bond/engine/discount/bond_discount_engine.py +517 -0
  21. quantark-0.1.0/quantark/asset/bond/engine/discount/frn_engine.py +913 -0
  22. quantark-0.1.0/quantark/asset/bond/engine/pde/__init__.py +14 -0
  23. quantark-0.1.0/quantark/asset/bond/engine/pde/convertible/__init__.py +21 -0
  24. quantark-0.1.0/quantark/asset/bond/engine/pde/convertible/jump_diffusion_engine.py +603 -0
  25. quantark-0.1.0/quantark/asset/bond/engine/pde/convertible/pde_params.py +59 -0
  26. quantark-0.1.0/quantark/asset/bond/engine/pde/convertible/tf_engine.py +546 -0
  27. quantark-0.1.0/quantark/asset/bond/engine/tree/__init__.py +14 -0
  28. quantark-0.1.0/quantark/asset/bond/engine/tree/convertible/__init__.py +21 -0
  29. quantark-0.1.0/quantark/asset/bond/engine/tree/convertible/binomial_engine.py +488 -0
  30. quantark-0.1.0/quantark/asset/bond/engine/tree/convertible/tree_params.py +72 -0
  31. quantark-0.1.0/quantark/asset/bond/engine/tree/convertible/trinomial_engine.py +1341 -0
  32. quantark-0.1.0/quantark/asset/bond/product/__init__.py +37 -0
  33. quantark-0.1.0/quantark/asset/bond/product/base_bond_product.py +114 -0
  34. quantark-0.1.0/quantark/asset/bond/product/convertible/__init__.py +16 -0
  35. quantark-0.1.0/quantark/asset/bond/product/convertible/convertible_bond.py +595 -0
  36. quantark-0.1.0/quantark/asset/bond/product/couponbond/__init__.py +12 -0
  37. quantark-0.1.0/quantark/asset/bond/product/couponbond/fixed_bond.py +285 -0
  38. quantark-0.1.0/quantark/asset/bond/product/couponbond/frn.py +538 -0
  39. quantark-0.1.0/quantark/asset/bond/product/forward/__init__.py +9 -0
  40. quantark-0.1.0/quantark/asset/bond/product/forward/base_bond_forward.py +92 -0
  41. quantark-0.1.0/quantark/asset/bond/product/forward/bond_forward.py +335 -0
  42. quantark-0.1.0/quantark/asset/bond/product/futures/__init__.py +8 -0
  43. quantark-0.1.0/quantark/asset/bond/product/futures/bond_futures.py +532 -0
  44. quantark-0.1.0/quantark/asset/bond/product/option/__init__.py +9 -0
  45. quantark-0.1.0/quantark/asset/bond/product/option/euro_short_term_bond_option.py +231 -0
  46. quantark-0.1.0/quantark/asset/bond/riskmeasures/__init__.py +13 -0
  47. quantark-0.1.0/quantark/asset/bond/riskmeasures/bond_greeks_calculator.py +484 -0
  48. quantark-0.1.0/quantark/asset/bond/schedule/__init__.py +21 -0
  49. quantark-0.1.0/quantark/asset/bond/schedule/cashflow.py +595 -0
  50. quantark-0.1.0/quantark/asset/equity/__init__.py +11 -0
  51. quantark-0.1.0/quantark/asset/equity/analysis/__init__.py +4 -0
  52. quantark-0.1.0/quantark/asset/equity/analysis/autocallable_path_analyzer.py +257 -0
  53. quantark-0.1.0/quantark/asset/equity/engine/__init__.py +84 -0
  54. quantark-0.1.0/quantark/asset/equity/engine/analytical/__init__.py +37 -0
  55. quantark-0.1.0/quantark/asset/equity/engine/analytical/american_option_engine.py +682 -0
  56. quantark-0.1.0/quantark/asset/equity/engine/analytical/asian_option_analytical_engine.py +1102 -0
  57. quantark-0.1.0/quantark/asset/equity/engine/analytical/barrier_analytical_engine.py +455 -0
  58. quantark-0.1.0/quantark/asset/equity/engine/analytical/black_scholes_engine.py +322 -0
  59. quantark-0.1.0/quantark/asset/equity/engine/analytical/deltaone_engine.py +340 -0
  60. quantark-0.1.0/quantark/asset/equity/engine/analytical/digital_option_engine.py +168 -0
  61. quantark-0.1.0/quantark/asset/equity/engine/analytical/double_barrier_option_engine.py +481 -0
  62. quantark-0.1.0/quantark/asset/equity/engine/analytical/double_sharkfin_option_analytical_engine.py +508 -0
  63. quantark-0.1.0/quantark/asset/equity/engine/analytical/one_touch_analytical_engine.py +302 -0
  64. quantark-0.1.0/quantark/asset/equity/engine/analytical/range_accrual_analytical_engine.py +396 -0
  65. quantark-0.1.0/quantark/asset/equity/engine/analytical/single_sharkfin_option_analytical_engine.py +229 -0
  66. quantark-0.1.0/quantark/asset/equity/engine/base_engine.py +137 -0
  67. quantark-0.1.0/quantark/asset/equity/engine/event_stats.py +85 -0
  68. quantark-0.1.0/quantark/asset/equity/engine/mc/__init__.py +31 -0
  69. quantark-0.1.0/quantark/asset/equity/engine/mc/american_option_mc_engine.py +485 -0
  70. quantark-0.1.0/quantark/asset/equity/engine/mc/asian_option_mc_engine.py +678 -0
  71. quantark-0.1.0/quantark/asset/equity/engine/mc/barrier_option_mc_engine.py +726 -0
  72. quantark-0.1.0/quantark/asset/equity/engine/mc/digital_option_mc_engine.py +419 -0
  73. quantark-0.1.0/quantark/asset/equity/engine/mc/double_sharkfin_option_mc_engine.py +676 -0
  74. quantark-0.1.0/quantark/asset/equity/engine/mc/euro_mc_engine.py +423 -0
  75. quantark-0.1.0/quantark/asset/equity/engine/mc/phoenix_mc_engine.py +1206 -0
  76. quantark-0.1.0/quantark/asset/equity/engine/mc/range_accrual_mc_engine.py +738 -0
  77. quantark-0.1.0/quantark/asset/equity/engine/mc/single_sharkfin_option_mc_engine.py +549 -0
  78. quantark-0.1.0/quantark/asset/equity/engine/mc/snowball_mc_engine.py +2250 -0
  79. quantark-0.1.0/quantark/asset/equity/engine/pde/__init__.py +36 -0
  80. quantark-0.1.0/quantark/asset/equity/engine/pde/american_pde_solver.py +211 -0
  81. quantark-0.1.0/quantark/asset/equity/engine/pde/barrier_pde_solver.py +692 -0
  82. quantark-0.1.0/quantark/asset/equity/engine/pde/base_pde_solver.py +994 -0
  83. quantark-0.1.0/quantark/asset/equity/engine/pde/double_barrier_pde_solver.py +510 -0
  84. quantark-0.1.0/quantark/asset/equity/engine/pde/double_one_touch_pde_solver.py +435 -0
  85. quantark-0.1.0/quantark/asset/equity/engine/pde/european_pde_solver.py +170 -0
  86. quantark-0.1.0/quantark/asset/equity/engine/pde/ko_reset_snowball_pde_solver.py +477 -0
  87. quantark-0.1.0/quantark/asset/equity/engine/pde/one_touch_pde_solver.py +439 -0
  88. quantark-0.1.0/quantark/asset/equity/engine/pde/phoenix_pde_solver.py +613 -0
  89. quantark-0.1.0/quantark/asset/equity/engine/pde/snowball_pde_solver.py +1810 -0
  90. quantark-0.1.0/quantark/asset/equity/engine/pde/spatial_grid.py +750 -0
  91. quantark-0.1.0/quantark/asset/equity/engine/pde/time_grid.py +308 -0
  92. quantark-0.1.0/quantark/asset/equity/engine/pde_engine.py +238 -0
  93. quantark-0.1.0/quantark/asset/equity/engine/quad/__init__.py +23 -0
  94. quantark-0.1.0/quantark/asset/equity/engine/quad/discrete_quad_engine.py +106 -0
  95. quantark-0.1.0/quantark/asset/equity/engine/quad/european_quad_engine.py +325 -0
  96. quantark-0.1.0/quantark/asset/equity/engine/quad/ko_reset_snowball_quad_engine.py +362 -0
  97. quantark-0.1.0/quantark/asset/equity/engine/quad/phoenix_quad_engine.py +614 -0
  98. quantark-0.1.0/quantark/asset/equity/engine/quad/quad_adapters.py +1260 -0
  99. quantark-0.1.0/quantark/asset/equity/engine/quad/quad_core.py +513 -0
  100. quantark-0.1.0/quantark/asset/equity/engine/quad/quad_math.py +219 -0
  101. quantark-0.1.0/quantark/asset/equity/engine/quad/snowball_quad_engine.py +1137 -0
  102. quantark-0.1.0/quantark/asset/equity/engine/validation/script/benchmark_check_american_analytical.py +117 -0
  103. quantark-0.1.0/quantark/asset/equity/engine/validation/script/benchmark_check_american_pde.py +114 -0
  104. quantark-0.1.0/quantark/asset/equity/engine/validation/script/benchmark_check_asian_analytical.py +440 -0
  105. quantark-0.1.0/quantark/asset/equity/engine/validation/script/benchmark_check_barrier_analytical.py +269 -0
  106. quantark-0.1.0/quantark/asset/equity/engine/validation/script/benchmark_check_barrier_pde_solver.py +636 -0
  107. quantark-0.1.0/quantark/asset/equity/engine/validation/script/benchmark_check_digital_option.py +256 -0
  108. quantark-0.1.0/quantark/asset/equity/engine/validation/script/benchmark_check_snowball_pde_solver.py +807 -0
  109. quantark-0.1.0/quantark/asset/equity/engine/validation/script/boundary_check_american_analytical.py +290 -0
  110. quantark-0.1.0/quantark/asset/equity/engine/validation/script/boundary_check_american_pde.py +242 -0
  111. quantark-0.1.0/quantark/asset/equity/engine/validation/script/boundary_check_asian_analytical.py +612 -0
  112. quantark-0.1.0/quantark/asset/equity/engine/validation/script/boundary_check_barrier_analytical.py +434 -0
  113. quantark-0.1.0/quantark/asset/equity/engine/validation/script/boundary_check_barrier_pde_solver.py +748 -0
  114. quantark-0.1.0/quantark/asset/equity/engine/validation/script/boundary_check_digital_option.py +575 -0
  115. quantark-0.1.0/quantark/asset/equity/engine/validation/script/boundary_check_snowball_pde_solver.py +1101 -0
  116. quantark-0.1.0/quantark/asset/equity/engine/validation/script/greeks_check_digital_option.py +349 -0
  117. quantark-0.1.0/quantark/asset/equity/engine/validation/script/mc_comparison_barrier_pde.py +270 -0
  118. quantark-0.1.0/quantark/asset/equity/engine/validation/script/quick_mc_compare.py +51 -0
  119. quantark-0.1.0/quantark/asset/equity/engine/validation/script/validation_stepdown_improved.py +97 -0
  120. quantark-0.1.0/quantark/asset/equity/param/__init__.py +24 -0
  121. quantark-0.1.0/quantark/asset/equity/param/engine_param_profiles.py +325 -0
  122. quantark-0.1.0/quantark/asset/equity/param/engine_params.py +728 -0
  123. quantark-0.1.0/quantark/asset/equity/process/__init__.py +7 -0
  124. quantark-0.1.0/quantark/asset/equity/process/bsm/__init__.py +7 -0
  125. quantark-0.1.0/quantark/asset/equity/process/bsm/bsm_process.py +108 -0
  126. quantark-0.1.0/quantark/asset/equity/process/bsm/qmc_brownian_bridge.py +401 -0
  127. quantark-0.1.0/quantark/asset/equity/process/bsm/qmc_path_generator.py +694 -0
  128. quantark-0.1.0/quantark/asset/equity/process/bsm/qmc_rqmc_driver.py +163 -0
  129. quantark-0.1.0/quantark/asset/equity/process/bsm/qmc_sobol.py +195 -0
  130. quantark-0.1.0/quantark/asset/equity/process/bsm/qmc_variance_reduction.py +292 -0
  131. quantark-0.1.0/quantark/asset/equity/product/__init__.py +8 -0
  132. quantark-0.1.0/quantark/asset/equity/product/base_equity_product.py +72 -0
  133. quantark-0.1.0/quantark/asset/equity/product/deltaone/__init__.py +22 -0
  134. quantark-0.1.0/quantark/asset/equity/product/deltaone/base_deltaone_product.py +147 -0
  135. quantark-0.1.0/quantark/asset/equity/product/deltaone/futures.py +485 -0
  136. quantark-0.1.0/quantark/asset/equity/product/deltaone/spot_instrument.py +118 -0
  137. quantark-0.1.0/quantark/asset/equity/product/option/__init__.py +104 -0
  138. quantark-0.1.0/quantark/asset/equity/product/option/american_option.py +114 -0
  139. quantark-0.1.0/quantark/asset/equity/product/option/asian_option.py +531 -0
  140. quantark-0.1.0/quantark/asset/equity/product/option/barrier_option.py +289 -0
  141. quantark-0.1.0/quantark/asset/equity/product/option/base_equity_option.py +659 -0
  142. quantark-0.1.0/quantark/asset/equity/product/option/digital_option.py +102 -0
  143. quantark-0.1.0/quantark/asset/equity/product/option/double_barrier_option.py +286 -0
  144. quantark-0.1.0/quantark/asset/equity/product/option/double_one_touch_option.py +310 -0
  145. quantark-0.1.0/quantark/asset/equity/product/option/double_sharkfin_option.py +466 -0
  146. quantark-0.1.0/quantark/asset/equity/product/option/european_vanilla_option.py +103 -0
  147. quantark-0.1.0/quantark/asset/equity/product/option/ko_reset_snowball_option.py +563 -0
  148. quantark-0.1.0/quantark/asset/equity/product/option/observation_schedule.py +530 -0
  149. quantark-0.1.0/quantark/asset/equity/product/option/one_touch_option.py +287 -0
  150. quantark-0.1.0/quantark/asset/equity/product/option/phoenix_config.py +116 -0
  151. quantark-0.1.0/quantark/asset/equity/product/option/phoenix_helpers.py +576 -0
  152. quantark-0.1.0/quantark/asset/equity/product/option/phoenix_option.py +1167 -0
  153. quantark-0.1.0/quantark/asset/equity/product/option/range_accrual_config.py +288 -0
  154. quantark-0.1.0/quantark/asset/equity/product/option/range_accrual_helpers.py +608 -0
  155. quantark-0.1.0/quantark/asset/equity/product/option/range_accrual_option.py +526 -0
  156. quantark-0.1.0/quantark/asset/equity/product/option/single_sharkfin_option.py +420 -0
  157. quantark-0.1.0/quantark/asset/equity/product/option/snowball_config.py +261 -0
  158. quantark-0.1.0/quantark/asset/equity/product/option/snowball_helpers.py +977 -0
  159. quantark-0.1.0/quantark/asset/equity/product/option/snowball_option.py +1242 -0
  160. quantark-0.1.0/quantark/asset/equity/report/__init__.py +15 -0
  161. quantark-0.1.0/quantark/asset/equity/report/autocallable_risk_report.py +2118 -0
  162. quantark-0.1.0/quantark/asset/equity/report/plotting.py +87 -0
  163. quantark-0.1.0/quantark/asset/equity/report/snowball_risk_comparison_report.py +2230 -0
  164. quantark-0.1.0/quantark/asset/equity/report/surfaces.py +123 -0
  165. quantark-0.1.0/quantark/asset/equity/report/term_structure.py +126 -0
  166. quantark-0.1.0/quantark/asset/equity/riskmeasures/__init__.py +7 -0
  167. quantark-0.1.0/quantark/asset/equity/riskmeasures/greeks_calculator.py +1204 -0
  168. quantark-0.1.0/quantark/asset/rate/__init__.py +58 -0
  169. quantark-0.1.0/quantark/asset/rate/engine/__init__.py +25 -0
  170. quantark-0.1.0/quantark/asset/rate/engine/cap_floor_engine.py +514 -0
  171. quantark-0.1.0/quantark/asset/rate/engine/fra_engine.py +286 -0
  172. quantark-0.1.0/quantark/asset/rate/engine/irs_discount_engine.py +891 -0
  173. quantark-0.1.0/quantark/asset/rate/engine/swaption_engine.py +587 -0
  174. quantark-0.1.0/quantark/asset/rate/product/__init__.py +67 -0
  175. quantark-0.1.0/quantark/asset/rate/product/cap_floor.py +550 -0
  176. quantark-0.1.0/quantark/asset/rate/product/fra.py +219 -0
  177. quantark-0.1.0/quantark/asset/rate/product/irs.py +1223 -0
  178. quantark-0.1.0/quantark/asset/rate/product/swaption.py +372 -0
  179. quantark-0.1.0/quantark/backtest/__init__.py +153 -0
  180. quantark-0.1.0/quantark/backtest/base.py +263 -0
  181. quantark-0.1.0/quantark/backtest/dashboard.py +874 -0
  182. quantark-0.1.0/quantark/backtest/equity/__init__.py +35 -0
  183. quantark-0.1.0/quantark/backtest/equity/config.py +118 -0
  184. quantark-0.1.0/quantark/backtest/equity/engine.py +408 -0
  185. quantark-0.1.0/quantark/backtest/equity/hedge_executor.py +374 -0
  186. quantark-0.1.0/quantark/backtest/equity/metrics.py +396 -0
  187. quantark-0.1.0/quantark/backtest/equity/results.py +232 -0
  188. quantark-0.1.0/quantark/backtest/equity/state.py +252 -0
  189. quantark-0.1.0/quantark/backtest/examples/__init__.py +4 -0
  190. quantark-0.1.0/quantark/backtest/examples/advanced_backtest.py +345 -0
  191. quantark-0.1.0/quantark/backtest/examples/basic_delta_hedge.py +246 -0
  192. quantark-0.1.0/quantark/backtest/examples/fi_dv01_hedge.py +267 -0
  193. quantark-0.1.0/quantark/backtest/fi/__init__.py +30 -0
  194. quantark-0.1.0/quantark/backtest/fi/config.py +114 -0
  195. quantark-0.1.0/quantark/backtest/fi/engine.py +378 -0
  196. quantark-0.1.0/quantark/backtest/fi/hedge_executor.py +254 -0
  197. quantark-0.1.0/quantark/backtest/fi/metrics.py +308 -0
  198. quantark-0.1.0/quantark/backtest/fi/results.py +193 -0
  199. quantark-0.1.0/quantark/backtest/fi/state.py +212 -0
  200. quantark-0.1.0/quantark/backtest/logger.py +393 -0
  201. quantark-0.1.0/quantark/backtest/otc/__init__.py +74 -0
  202. quantark-0.1.0/quantark/backtest/otc/_replay.py +637 -0
  203. quantark-0.1.0/quantark/backtest/otc/book_engine.py +587 -0
  204. quantark-0.1.0/quantark/backtest/otc/config.py +175 -0
  205. quantark-0.1.0/quantark/backtest/otc/dashboard.py +1006 -0
  206. quantark-0.1.0/quantark/backtest/otc/engine.py +420 -0
  207. quantark-0.1.0/quantark/backtest/otc/engine_factory.py +138 -0
  208. quantark-0.1.0/quantark/backtest/otc/market.py +216 -0
  209. quantark-0.1.0/quantark/backtest/otc/results.py +107 -0
  210. quantark-0.1.0/quantark/backtest/otc/state.py +166 -0
  211. quantark-0.1.0/quantark/backtest/report_generator.py +608 -0
  212. quantark-0.1.0/quantark/backtest/strategy/__init__.py +28 -0
  213. quantark-0.1.0/quantark/backtest/strategy/base_strategy.py +235 -0
  214. quantark-0.1.0/quantark/backtest/strategy/convexity_neutral_strategy.py +247 -0
  215. quantark-0.1.0/quantark/backtest/strategy/delta_neutral_strategy.py +283 -0
  216. quantark-0.1.0/quantark/backtest/strategy/dv01_neutral_strategy.py +283 -0
  217. quantark-0.1.0/quantark/backtest/transaction_costs.py +485 -0
  218. quantark-0.1.0/quantark/backtest/visualizer.py +1019 -0
  219. quantark-0.1.0/quantark/cashleg/__init__.py +31 -0
  220. quantark-0.1.0/quantark/cashleg/accrual_leg.py +120 -0
  221. quantark-0.1.0/quantark/cashleg/base.py +48 -0
  222. quantark-0.1.0/quantark/cashleg/base_amount.py +60 -0
  223. quantark-0.1.0/quantark/cashleg/deterministic_leg.py +39 -0
  224. quantark-0.1.0/quantark/cashleg/event_distribution.py +262 -0
  225. quantark-0.1.0/quantark/cashleg/fixed_payoff_leg.py +92 -0
  226. quantark-0.1.0/quantark/cashleg/leg_schedule.py +95 -0
  227. quantark-0.1.0/quantark/cashleg/leg_valuator.py +40 -0
  228. quantark-0.1.0/quantark/dynamicscenario/__init__.py +97 -0
  229. quantark-0.1.0/quantark/dynamicscenario/base.py +297 -0
  230. quantark-0.1.0/quantark/dynamicscenario/config.py +122 -0
  231. quantark-0.1.0/quantark/dynamicscenario/engine.py +703 -0
  232. quantark-0.1.0/quantark/dynamicscenario/equity/__init__.py +14 -0
  233. quantark-0.1.0/quantark/dynamicscenario/fi/__init__.py +24 -0
  234. quantark-0.1.0/quantark/dynamicscenario/fi/config.py +149 -0
  235. quantark-0.1.0/quantark/dynamicscenario/fi/engine.py +500 -0
  236. quantark-0.1.0/quantark/dynamicscenario/fi/results.py +503 -0
  237. quantark-0.1.0/quantark/dynamicscenario/path/__init__.py +17 -0
  238. quantark-0.1.0/quantark/dynamicscenario/path/day_path.py +397 -0
  239. quantark-0.1.0/quantark/dynamicscenario/path/fi_path_library.py +488 -0
  240. quantark-0.1.0/quantark/dynamicscenario/path/path_builder.py +726 -0
  241. quantark-0.1.0/quantark/dynamicscenario/path/path_library.py +620 -0
  242. quantark-0.1.0/quantark/dynamicscenario/report/__init__.py +12 -0
  243. quantark-0.1.0/quantark/dynamicscenario/report/dynamic_report.py +1175 -0
  244. quantark-0.1.0/quantark/dynamicscenario/report/visualizer.py +1586 -0
  245. quantark-0.1.0/quantark/dynamicscenario/results/__init__.py +19 -0
  246. quantark-0.1.0/quantark/dynamicscenario/results/dynamic_results.py +579 -0
  247. quantark-0.1.0/quantark/dynamicscenario/results/result_exporter.py +438 -0
  248. quantark-0.1.0/quantark/param/__init__.py +75 -0
  249. quantark-0.1.0/quantark/param/basis/__init__.py +19 -0
  250. quantark-0.1.0/quantark/param/basis/basis_yield.py +301 -0
  251. quantark-0.1.0/quantark/param/div/__init__.py +16 -0
  252. quantark-0.1.0/quantark/param/div/dividend_yield.py +123 -0
  253. quantark-0.1.0/quantark/param/index/__init__.py +52 -0
  254. quantark-0.1.0/quantark/param/index/rate_index.py +568 -0
  255. quantark-0.1.0/quantark/param/quote/__init__.py +7 -0
  256. quantark-0.1.0/quantark/param/quote/spot_quote.py +35 -0
  257. quantark-0.1.0/quantark/param/rrf/__init__.py +22 -0
  258. quantark-0.1.0/quantark/param/rrf/rate_curve.py +436 -0
  259. quantark-0.1.0/quantark/param/vol/__init__.py +6 -0
  260. quantark-0.1.0/quantark/param/vol/vol_surface.py +118 -0
  261. quantark-0.1.0/quantark/portfolio/__init__.py +61 -0
  262. quantark-0.1.0/quantark/portfolio/base.py +203 -0
  263. quantark-0.1.0/quantark/portfolio/equity/__init__.py +17 -0
  264. quantark-0.1.0/quantark/portfolio/equity/portfolio.py +391 -0
  265. quantark-0.1.0/quantark/portfolio/equity/position.py +368 -0
  266. quantark-0.1.0/quantark/portfolio/fi/__init__.py +14 -0
  267. quantark-0.1.0/quantark/portfolio/fi/portfolio.py +424 -0
  268. quantark-0.1.0/quantark/portfolio/fi/position.py +272 -0
  269. quantark-0.1.0/quantark/portfolio/portfolio_snapshot.py +221 -0
  270. quantark-0.1.0/quantark/portfolio/portfolio_storage.py +414 -0
  271. quantark-0.1.0/quantark/priceenv/__init__.py +7 -0
  272. quantark-0.1.0/quantark/priceenv/pricing_environment.py +196 -0
  273. quantark-0.1.0/quantark/rfq/__init__.py +32 -0
  274. quantark-0.1.0/quantark/rfq/builders.py +102 -0
  275. quantark-0.1.0/quantark/rfq/models.py +214 -0
  276. quantark-0.1.0/quantark/rfq/registry.py +611 -0
  277. quantark-0.1.0/quantark/rfq/service.py +237 -0
  278. quantark-0.1.0/quantark/simm/__init__.py +155 -0
  279. quantark-0.1.0/quantark/simm/calibration/__init__.py +206 -0
  280. quantark-0.1.0/quantark/simm/calibration/accessors.py +439 -0
  281. quantark-0.1.0/quantark/simm/calibration/commodity.py +156 -0
  282. quantark-0.1.0/quantark/simm/calibration/credit_non_qualifying.py +79 -0
  283. quantark-0.1.0/quantark/simm/calibration/credit_qualifying.py +130 -0
  284. quantark-0.1.0/quantark/simm/calibration/cross_risk.py +39 -0
  285. quantark-0.1.0/quantark/simm/calibration/equity.py +125 -0
  286. quantark-0.1.0/quantark/simm/calibration/fx.py +92 -0
  287. quantark-0.1.0/quantark/simm/calibration/ir.py +152 -0
  288. quantark-0.1.0/quantark/simm/calibration/version.py +33 -0
  289. quantark-0.1.0/quantark/simm/config.py +186 -0
  290. quantark-0.1.0/quantark/simm/crif/__init__.py +35 -0
  291. quantark-0.1.0/quantark/simm/crif/models.py +230 -0
  292. quantark-0.1.0/quantark/simm/crif/parser.py +585 -0
  293. quantark-0.1.0/quantark/simm/engines/__init__.py +62 -0
  294. quantark-0.1.0/quantark/simm/engines/aggregation/__init__.py +67 -0
  295. quantark-0.1.0/quantark/simm/engines/aggregation/addon.py +141 -0
  296. quantark-0.1.0/quantark/simm/engines/aggregation/bucket_aggregator.py +298 -0
  297. quantark-0.1.0/quantark/simm/engines/aggregation/concentration.py +349 -0
  298. quantark-0.1.0/quantark/simm/engines/aggregation/product_class_aggregator.py +183 -0
  299. quantark-0.1.0/quantark/simm/engines/aggregation/risk_class_aggregator.py +403 -0
  300. quantark-0.1.0/quantark/simm/engines/aggregation/simm_calculator.py +430 -0
  301. quantark-0.1.0/quantark/simm/engines/aggregation/weighted_sensitivity.py +272 -0
  302. quantark-0.1.0/quantark/simm/engines/base.py +231 -0
  303. quantark-0.1.0/quantark/simm/engines/classification/__init__.py +10 -0
  304. quantark-0.1.0/quantark/simm/engines/classification/bucket_mapper.py +347 -0
  305. quantark-0.1.0/quantark/simm/engines/factory.py +137 -0
  306. quantark-0.1.0/quantark/simm/engines/portfolio_adapter.py +336 -0
  307. quantark-0.1.0/quantark/simm/engines/result.py +176 -0
  308. quantark-0.1.0/quantark/simm/engines/risk_class/__init__.py +18 -0
  309. quantark-0.1.0/quantark/simm/engines/risk_class/equity_engine.py +263 -0
  310. quantark-0.1.0/quantark/simm/engines/risk_class/ir_engine.py +264 -0
  311. quantark-0.1.0/quantark/simm/report/__init__.py +17 -0
  312. quantark-0.1.0/quantark/simm/report/crif_export.py +284 -0
  313. quantark-0.1.0/quantark/simm/report/excel_generator.py +401 -0
  314. quantark-0.1.0/quantark/simm/report/html_generator.py +840 -0
  315. quantark-0.1.0/quantark/simm/results/__init__.py +38 -0
  316. quantark-0.1.0/quantark/simm/results/attribution.py +313 -0
  317. quantark-0.1.0/quantark/simm/results/simm_result.py +339 -0
  318. quantark-0.1.0/quantark/simm/results/whatif.py +268 -0
  319. quantark-0.1.0/quantark/simm/sensitivity.py +533 -0
  320. quantark-0.1.0/quantark/simm/taxonomy.py +416 -0
  321. quantark-0.1.0/quantark/stresstest/__init__.py +67 -0
  322. quantark-0.1.0/quantark/stresstest/base.py +116 -0
  323. quantark-0.1.0/quantark/stresstest/config.py +5 -0
  324. quantark-0.1.0/quantark/stresstest/engine.py +5 -0
  325. quantark-0.1.0/quantark/stresstest/equity/__init__.py +17 -0
  326. quantark-0.1.0/quantark/stresstest/equity/config.py +69 -0
  327. quantark-0.1.0/quantark/stresstest/equity/engine.py +272 -0
  328. quantark-0.1.0/quantark/stresstest/equity/report/__init__.py +7 -0
  329. quantark-0.1.0/quantark/stresstest/equity/report/report_generator.py +423 -0
  330. quantark-0.1.0/quantark/stresstest/equity/report/visualizer.py +328 -0
  331. quantark-0.1.0/quantark/stresstest/equity/results.py +145 -0
  332. quantark-0.1.0/quantark/stresstest/fi/__init__.py +15 -0
  333. quantark-0.1.0/quantark/stresstest/fi/config.py +59 -0
  334. quantark-0.1.0/quantark/stresstest/fi/engine.py +213 -0
  335. quantark-0.1.0/quantark/stresstest/fi/metrics.py +60 -0
  336. quantark-0.1.0/quantark/stresstest/fi/results.py +64 -0
  337. quantark-0.1.0/quantark/stresstest/report/__init__.py +12 -0
  338. quantark-0.1.0/quantark/stresstest/report/report_generator.py +5 -0
  339. quantark-0.1.0/quantark/stresstest/report/visualizer.py +5 -0
  340. quantark-0.1.0/quantark/stresstest/results/__init__.py +16 -0
  341. quantark-0.1.0/quantark/stresstest/results/result_aggregator.py +325 -0
  342. quantark-0.1.0/quantark/stresstest/results/result_exporter.py +286 -0
  343. quantark-0.1.0/quantark/stresstest/results/stress_results.py +5 -0
  344. quantark-0.1.0/quantark/stresstest/scenario/__init__.py +13 -0
  345. quantark-0.1.0/quantark/stresstest/scenario/scenario.py +242 -0
  346. quantark-0.1.0/quantark/stresstest/scenario/scenario_builder.py +376 -0
  347. quantark-0.1.0/quantark/stresstest/scenario/scenario_library.py +435 -0
  348. quantark-0.1.0/quantark/stresstest/scenario/scenario_storage.py +224 -0
  349. quantark-0.1.0/quantark/stresstest/stress/__init__.py +13 -0
  350. quantark-0.1.0/quantark/stresstest/stress/stress_applicator.py +590 -0
  351. quantark-0.1.0/quantark/stresstest/stress/stress_types.py +142 -0
  352. quantark-0.1.0/quantark/util/__init__.py +23 -0
  353. quantark-0.1.0/quantark/util/barrier_shift.py +44 -0
  354. quantark-0.1.0/quantark/util/calendar/__init__.py +27 -0
  355. quantark-0.1.0/quantark/util/calendar/business_calendar.py +584 -0
  356. quantark-0.1.0/quantark/util/calendar/day_counter.py +517 -0
  357. quantark-0.1.0/quantark/util/calendar/holidayfile/china.csv +1920 -0
  358. quantark-0.1.0/quantark/util/calendar/holidayfile/china_sse.csv +1462 -0
  359. quantark-0.1.0/quantark/util/enum/__init__.py +81 -0
  360. quantark-0.1.0/quantark/util/enum/bond_enums.py +112 -0
  361. quantark-0.1.0/quantark/util/enum/deltaone_enums.py +16 -0
  362. quantark-0.1.0/quantark/util/enum/engine_enums.py +137 -0
  363. quantark-0.1.0/quantark/util/enum/greeks_enums.py +29 -0
  364. quantark-0.1.0/quantark/util/enum/option_enums.py +221 -0
  365. quantark-0.1.0/quantark/util/exceptions.py +66 -0
  366. quantark-0.1.0/quantark/util/marketdata/__init__.py +39 -0
  367. quantark-0.1.0/quantark/util/marketdata/adapter/base_adapter.py +203 -0
  368. quantark-0.1.0/quantark/util/marketdata/adapter/mock_adapter.py +265 -0
  369. quantark-0.1.0/quantark/util/marketdata/converter.py +289 -0
  370. quantark-0.1.0/quantark/util/marketdata/example_usage.py +314 -0
  371. quantark-0.1.0/quantark/util/marketdata/generator/__init__.py +7 -0
  372. quantark-0.1.0/quantark/util/marketdata/generator/mock_generator.py +466 -0
  373. quantark-0.1.0/quantark/util/marketdata/models.py +358 -0
  374. quantark-0.1.0/quantark/util/marketdata/storage/__init__.py +7 -0
  375. quantark-0.1.0/quantark/util/marketdata/storage/parquet_storage.py +340 -0
  376. quantark-0.1.0/quantark/util/numerical/__init__.py +98 -0
  377. quantark-0.1.0/quantark/util/numerical/comparison.py +219 -0
  378. quantark-0.1.0/quantark/util/numerical/constants.py +98 -0
  379. quantark-0.1.0/quantark/util/numerical/formatting.py +380 -0
  380. quantark-0.1.0/quantark/util/numerical/pnl.py +17 -0
  381. quantark-0.1.0/quantark/util/numerical/safe_math.py +238 -0
  382. quantark-0.1.0/quantark/util/numerical/validation.py +315 -0
  383. quantark-0.1.0/quantark/var/__init__.py +39 -0
  384. quantark-0.1.0/quantark/var/attribution.py +398 -0
  385. quantark-0.1.0/quantark/var/backtest/__init__.py +7 -0
  386. quantark-0.1.0/quantark/var/backtest/var_backtester.py +309 -0
  387. quantark-0.1.0/quantark/var/base.py +63 -0
  388. quantark-0.1.0/quantark/var/config.py +219 -0
  389. quantark-0.1.0/quantark/var/engines/__init__.py +13 -0
  390. quantark-0.1.0/quantark/var/engines/historical.py +925 -0
  391. quantark-0.1.0/quantark/var/engines/monte_carlo.py +870 -0
  392. quantark-0.1.0/quantark/var/engines/parametric.py +1199 -0
  393. quantark-0.1.0/quantark/var/results/__init__.py +16 -0
  394. quantark-0.1.0/quantark/var/results/incremental_var_result.py +131 -0
  395. quantark-0.1.0/quantark/var/results/var_report.py +346 -0
  396. quantark-0.1.0/quantark/var/results/var_result.py +134 -0
  397. quantark-0.1.0/quantark/var/risk_factors/__init__.py +22 -0
  398. quantark-0.1.0/quantark/var/risk_factors/base.py +41 -0
  399. quantark-0.1.0/quantark/var/risk_factors/equity_factors.py +158 -0
  400. quantark-0.1.0/quantark/var/risk_factors/fi_factors.py +99 -0
  401. quantark-0.1.0/quantark_compat.pth +1 -0
@@ -0,0 +1,12 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ .venv/
5
+ venv/
6
+ build/
7
+ dist/
8
+ .pytest_cache/
9
+ .coverage
10
+ htmlcov/
11
+ .ipynb_checkpoints/
12
+ .DS_Store
@@ -0,0 +1,34 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
5
+ and the project adheres to [Semantic Versioning](https://semver.org/).
6
+ During 0.x the public API may still change between minor versions.
7
+
8
+ ## [0.1.0] - 2026-06-11
9
+
10
+ ### Added
11
+ - First public release.
12
+ - Equity derivatives: European/American/Asian vanilla options, barrier,
13
+ one-touch, digital, sharkfin, and autocallable products (snowball,
14
+ phoenix, KO-reset snowball, range accrual) with analytical, Monte
15
+ Carlo, PDE, quadrature, and tree engines.
16
+ - Fixed income: fixed bonds, FRNs, bond options, bond forwards/futures,
17
+ convertible bonds, interest rate swaps.
18
+ - Market data layer (`quantark.param`, `quantark.priceenv`), Greeks
19
+ calculators, portfolio VaR (parametric/historical/Monte Carlo),
20
+ ISDA SIMM v2.6, stress testing, multi-day scenario simulation, and a
21
+ hedging backtest framework.
22
+ - Legacy flat-import compatibility shim (`asset`, `util`, …) with
23
+ `DeprecationWarning`; slated for removal in 1.0.
24
+
25
+ ### Fixed
26
+ - `SnowballQuadEngine`: the dense-discrete-KI-to-continuous bridge
27
+ approximation now applies a Broadie-Glasserman-Kou barrier shift to
28
+ emulate discrete monitoring. Previously the conversion monitored the
29
+ unshifted barrier continuously, overstating knock-in probability (fair
30
+ KO-rate bias of up to ~0.9 coupon points vs PDE/MC on daily-KI
31
+ snowballs). A first-order residual can remain for strongly drifted
32
+ (deep-carry) underlyings; set
33
+ `QuadParams.dense_discrete_ki_as_continuous_threshold=0` with a
34
+ sufficiently fine grid for exact discrete pricing.
quantark-0.1.0/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
quantark-0.1.0/NOTICE ADDED
@@ -0,0 +1,2 @@
1
+ QuantArk
2
+ Copyright 2026 fuxinyao (https://github.com/deiiiiii93)
@@ -0,0 +1,351 @@
1
+ Metadata-Version: 2.4
2
+ Name: quantark
3
+ Version: 0.1.0
4
+ Summary: Modular derivatives pricing and risk library: options, autocallables, bonds, VaR, SIMM
5
+ Project-URL: Homepage, https://github.com/deiiiiii93/quantark
6
+ Project-URL: Repository, https://github.com/deiiiiii93/quantark
7
+ Project-URL: Issues, https://github.com/deiiiiii93/quantark/issues
8
+ Project-URL: Changelog, https://github.com/deiiiiii93/quantark/blob/main/CHANGELOG.md
9
+ Author-email: fuxinyao <ianchris0113@gmail.com>
10
+ License-Expression: Apache-2.0
11
+ License-File: LICENSE
12
+ License-File: NOTICE
13
+ Keywords: autocallable,derivatives,monte-carlo,option-pricing,pde,quantitative-finance,risk-management,simm,snowball,var
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Intended Audience :: Financial and Insurance Industry
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Office/Business :: Financial :: Investment
23
+ Requires-Python: >=3.10
24
+ Requires-Dist: kaleido>=0.2.1
25
+ Requires-Dist: matplotlib>=3.7.0
26
+ Requires-Dist: numpy>=1.24.0
27
+ Requires-Dist: openpyxl>=3.0.0
28
+ Requires-Dist: pandas>=2.0.0
29
+ Requires-Dist: plotly>=5.14.0
30
+ Requires-Dist: pyarrow>=12.0.0
31
+ Requires-Dist: python-dateutil>=2.8.0
32
+ Requires-Dist: python-docx>=1.0.0
33
+ Requires-Dist: pyyaml>=6.0.0
34
+ Requires-Dist: scipy>=1.10.0
35
+ Requires-Dist: seaborn>=0.12.0
36
+ Provides-Extra: dev
37
+ Requires-Dist: pytest>=7.0.0; extra == 'dev'
38
+ Description-Content-Type: text/markdown
39
+
40
+ # QuantArk — Financial Derivatives Pricing & Risk Library
41
+
42
+ [![tests](https://github.com/deiiiiii93/quantark/actions/workflows/tests.yml/badge.svg)](https://github.com/deiiiiii93/quantark/actions/workflows/tests.yml)
43
+ [![PyPI](https://img.shields.io/pypi/v/quantark)](https://pypi.org/project/quantark/)
44
+ [![Python](https://img.shields.io/pypi/pyversions/quantark)](https://pypi.org/project/quantark/)
45
+ [![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)
46
+
47
+ A modular, professional-grade Python library for pricing and risk management of financial derivatives.
48
+
49
+ ## Overview
50
+
51
+ QuantArk is designed with a clean, modular architecture that separates concerns across different components:
52
+
53
+ - **Products**: Define instrument specifications (options, swaps, etc.)
54
+ - **Processes**: Stochastic models (Black-Scholes-Merton, Heston, Local Vol, etc.)
55
+ - **Engines**: Pricing algorithms (Analytical, Monte Carlo, PDE, Quadrature)
56
+ - **Parameters**: Market data (spot prices, volatility surfaces, rate curves, dividends)
57
+ - **PriceEnv**: Unified pricing environment bundling all market data
58
+ - **RiskMeasures**: Greeks calculation (both analytical and numerical)
59
+
60
+ ## Features
61
+
62
+ ### Current Implementation
63
+
64
+ - **European Vanilla Options**: Full support for calls and puts
65
+ - **American Options**: Analytical and numerical methods (Barone-Adesi-Whaley, Longstaff-Schwartz)
66
+ - **Black-Scholes-Merton Model**: With continuous dividend yield
67
+ - **Analytical Pricing**: Closed-form Black-Scholes formula
68
+ - **Monte Carlo Engine**: Path-dependent pricing with variance reduction techniques
69
+ - **PDE Engine**: Finite difference methods for American options
70
+ - **Portfolio Value-at-Risk (VaR)**: Three calculation methods
71
+ - Historical VaR (full revaluation under historical scenarios)
72
+ - Parametric VaR (variance-covariance with Greeks/DV01)
73
+ - Monte Carlo VaR (simulation-based with stress testing)
74
+ - **Bond Pricing**: Fixed rate bonds, FRNs, and bond options
75
+ - **Interest Rate Swaps**: Pricing and risk metrics (DV01)
76
+ - **Greeks Calculation**:
77
+ - Analytical Greeks using closed-form formulas
78
+ - Numerical Greeks using finite difference method (FDM)
79
+ - Delta, Gamma, Vega, Theta, Rho, DV01
80
+ - **Robust Error Handling**: Professional exception hierarchy
81
+ - **Numerical Stability**: Careful boundary checking and validation
82
+
83
+ ### Key Design Principles
84
+
85
+ 1. **Modularity**: Each component is independent and reusable
86
+ 2. **Extensibility**: Easy to add new products, processes, and engines
87
+ 3. **Type Safety**: Extensive use of dataclasses and type hints
88
+ 4. **Validation**: Input validation at every level
89
+ 5. **Professional Exception Handling**: Custom exception hierarchy for different error types
90
+
91
+ ## Installation
92
+
93
+ ```bash
94
+ pip install quantark
95
+ ```
96
+
97
+ From source / latest development version:
98
+
99
+ ```bash
100
+ pip install git+https://github.com/deiiiiii93/quantark
101
+ ```
102
+
103
+ For development (editable install with test tooling):
104
+
105
+ ```bash
106
+ git clone https://github.com/deiiiiii93/quantark && cd quantark
107
+ python3 -m venv .venv
108
+ .venv/bin/pip install -e ".[dev]"
109
+ .venv/bin/python -m pytest
110
+ ```
111
+
112
+ **Migration note**: imports use the `quantark.*` namespace
113
+ (`from quantark.util.enum import OptionType`). The historical flat
114
+ top-level packages (`asset`, `util`, `param`, …) still work through a
115
+ compatibility shim that aliases them to the same modules and emits a
116
+ `DeprecationWarning` — migrate existing code to `quantark.*` at your
117
+ convenience.
118
+
119
+ ## Quick Start
120
+
121
+ ```python
122
+ from quantark.asset.equity.product.option import EuropeanVanillaOption
123
+ from datetime import datetime
124
+
125
+ from quantark.asset.equity.engine.analytical import BlackScholesEngine
126
+ from quantark.asset.equity.riskmeasures import GreeksCalculator
127
+ from quantark.param import SpotQuote, FlatVolSurface, FlatRateCurve, ContinuousDividendYield
128
+ from quantark.priceenv import PricingEnvironment
129
+ from quantark.util.enum import OptionType
130
+
131
+ # Set up market data
132
+ spot = SpotQuote(spot=100.0)
133
+ vol = FlatVolSurface(volatility=0.20) # 20% vol
134
+ rate = FlatRateCurve(rate=0.05) # 5% risk-free rate
135
+ div = ContinuousDividendYield(div_yield=0.02) # 2% dividend yield
136
+
137
+ pricing_env = PricingEnvironment(
138
+ spot_quote=spot,
139
+ vol_surface=vol,
140
+ rate_curve=rate,
141
+ div_yield=div,
142
+ valuation_date=datetime(2024, 1, 1),
143
+ )
144
+
145
+ # Create a European call option
146
+ call_option = EuropeanVanillaOption(
147
+ strike=100.0,
148
+ maturity=1.0, # 1 year
149
+ option_type=OptionType.CALL
150
+ )
151
+
152
+ # Price the option
153
+ engine = BlackScholesEngine()
154
+ price = engine.price(call_option, pricing_env)
155
+ print(f"Call Price: ${price:.6f}")
156
+
157
+ # Calculate Greeks
158
+ greeks_calc = GreeksCalculator()
159
+ analytical_greeks = greeks_calc.calculate_analytical_greeks(
160
+ call_option, pricing_env, price
161
+ )
162
+
163
+ print(f"Delta: {analytical_greeks['delta']:.6f}")
164
+ print(f"Gamma: {analytical_greeks['gamma']:.6f}")
165
+ print(f"Vega: {analytical_greeks['vega']:.6f}")
166
+ print(f"Theta: {analytical_greeks['theta']:.6f} (per day)")
167
+ print(f"Rho: {analytical_greeks['rho']:.6f}")
168
+
169
+ ```
170
+
171
+ For portfolio Value-at-Risk (parametric, historical, and Monte Carlo engines
172
+ with risk-factor attribution), see the runnable demos:
173
+ `example/parametric_var_demo.py`, `example/portfolio_var_demo.py`, and
174
+ `example/var_backtest_demo.py`.
175
+
176
+ ## Batch-Friendly Engine Params
177
+
178
+ For QUAD/PDE batch pricing, you can use named presets, factory helpers, or YAML/JSON
179
+ configs instead of tuning many individual parameters.
180
+
181
+ ```python
182
+ from quantark.asset.equity.param import make_quad_params, make_pde_params
183
+
184
+ quad_params = make_quad_params(profile="barrier_sensitive")
185
+ pde_params = make_pde_params(profile="balanced")
186
+ ```
187
+
188
+ Engine parameter presets accept either preset names or explicit config objects; see the docstrings in `quantark/asset/equity/param/` for the full schema.
189
+
190
+ ## RQMC Target Std Scaling (MC Benchmarking)
191
+
192
+ Randomized QMC uses a target standard error for adaptive batching. For large
193
+ notionals, prefer relative scaling to avoid overly strict absolute tolerances:
194
+
195
+ ```python
196
+ from quantark.asset.equity.param import MCParams
197
+
198
+ mc_params = MCParams(
199
+ num_paths=100000,
200
+ rqmc_target_std=1e-4, # 1 bp relative
201
+ rqmc_target_std_mode="relative_notional",
202
+ rqmc_paths_mode="total",
203
+ )
204
+ ```
205
+
206
+ ## Running the Demo
207
+
208
+ A comprehensive demonstration is provided:
209
+
210
+ ```bash
211
+ python example/european_option_demo.py
212
+ ```
213
+
214
+ The demo showcases:
215
+ 1. European Call option pricing and Greeks
216
+ 2. European Put option pricing and Greeks
217
+ 3. Put-Call Parity verification
218
+ 4. Comparison between analytical and numerical Greeks
219
+
220
+ ## Project Structure
221
+
222
+ ```
223
+ QuantArk/
224
+ ├── asset/ # Asset classes
225
+ │ ├── equity/
226
+ │ │ ├── engine/ # Pricing engines
227
+ │ │ │ ├── analytical/
228
+ │ │ │ ├── mc/
229
+ │ │ │ ├── pde/
230
+ │ │ │ └── quad/
231
+ │ │ ├── param/ # Engine parameters
232
+ │ │ ├── process/ # Stochastic processes
233
+ │ │ │ ├── bsm/
234
+ │ │ │ ├── heston/
235
+ │ │ │ ├── localvol/
236
+ │ │ │ └── slv/
237
+ │ │ ├── product/ # Derivative products
238
+ │ │ │ └── option/
239
+ │ │ └── riskmeasures/ # Greeks calculation
240
+ │ ├── bond/ # Fixed income instruments
241
+ │ │ ├── engine/ # Bond pricing engines
242
+ │ │ ├── product/ # Bond products
243
+ │ │ └── riskmeasures/ # Bond risk measures
244
+ │ └── rate/ # Interest rate derivatives
245
+ │ ├── engine/ # IR pricing engines
246
+ │ ├── product/ # IR products
247
+ │ └── riskmeasures/ # IR risk measures
248
+ ├── param/ # Market data parameters
249
+ │ ├── div/ # Dividend yields
250
+ │ ├── quote/ # Spot quotes
251
+ │ ├── rrf/ # Risk-free rates
252
+ │ └── vol/ # Volatility surfaces
253
+ ├── priceenv/ # Pricing environment
254
+ ├── var/ # Value-at-Risk (VaR) calculations
255
+ │ ├── engines/ # VaR calculation engines
256
+ │ │ ├── historical.py # Historical VaR
257
+ │ │ ├── parametric.py # Parametric VaR
258
+ │ │ └── monte_carlo.py # Monte Carlo VaR
259
+ │ ├── risk_factors/ # Risk factor models
260
+ │ │ ├── base.py
261
+ │ │ ├── equity_factors.py
262
+ │ │ └── fi_factors.py
263
+ │ ├── backtest/ # VaR backtesting framework
264
+ │ ├── base.py # VaR base classes
265
+ │ └── config.py # VaR configuration
266
+ ├── portfolio/ # Portfolio management
267
+ │ ├── equity/ # Equity portfolios
268
+ │ └── fi/ # Fixed income portfolios
269
+ ├── backtest/ # Hedging strategy backtesting
270
+ ├── dynamicscenario/ # Multi-day scenario simulation
271
+ ├── stresstest/ # Stress testing framework
272
+ ├── util/ # Utilities
273
+ │ ├── enum/ # Enumerations
274
+ │ └── exceptions.py # Exception hierarchy
275
+ ├── example/ # Example scripts
276
+ └── test/ # Unit tests
277
+ ```
278
+
279
+ ## Exception Hierarchy
280
+
281
+ QuantArk uses a professional exception hierarchy:
282
+
283
+ - `QuantArkException`: Base exception
284
+ - `ValidationError`: Invalid input parameters
285
+ - `NumericalError`: Numerical instability/convergence issues
286
+ - `MarketDataError`: Missing or invalid market data
287
+ - `PricingError`: General pricing failures
288
+
289
+ ## Numerical Stability
290
+
291
+ The Black-Scholes engine includes extensive checks for numerical stability:
292
+
293
+ - Input parameter validation (spot, strike, volatility, rates)
294
+ - Overflow protection in exponential calculations
295
+ - Boundary condition handling (near expiry, deep ITM/OTM)
296
+ - Sanity checks on computed prices vs intrinsic values
297
+ - Extreme parameter detection and rejection
298
+
299
+ ## Roadmap
300
+
301
+ ### Short-term
302
+ - [x] American options (analytical and numerical methods)
303
+ - [ ] Asian options
304
+ - [ ] Barrier options
305
+ - [x] Monte Carlo engine implementation
306
+ - [x] PDE engine implementation
307
+ - [x] Portfolio VaR calculations
308
+ - [x] Fixed income instruments (bonds, swaps)
309
+
310
+ ### Medium-term
311
+ - [ ] Heston stochastic volatility model
312
+ - [ ] Local volatility model
313
+ - [ ] Credit derivatives
314
+ - [ ] Calibration framework
315
+ - [ ] XVA calculations
316
+ - [ ] Multi-asset derivatives
317
+ - [ ] Hybrid models
318
+
319
+ ### Long-term
320
+ - [ ] Performance optimization (Cython, GPU)
321
+ - [ ] Real-time risk metrics
322
+ - [ ] Portfolio optimization
323
+ - [ ] Market data integration
324
+ - [ ] Cloud deployment support
325
+
326
+ ## Contributing
327
+
328
+ Contributions are welcome! Please follow these guidelines:
329
+
330
+ 1. Follow the existing code structure and style
331
+ 2. Add comprehensive docstrings
332
+ 3. Include unit tests for new features
333
+ 4. Validate inputs and handle edge cases
334
+ 5. Add professional error handling
335
+
336
+ ## Disclaimer
337
+
338
+ QuantArk is provided for research and educational purposes. It is not
339
+ investment advice, and no warranty is made as to the correctness of any
340
+ price, risk figure, or model output. Validate independently before any
341
+ production or trading use. See the LICENSE file for the full terms.
342
+
343
+ ## License
344
+
345
+ Apache License 2.0 — see [LICENSE](LICENSE) and [NOTICE](NOTICE).
346
+
347
+ ## Acknowledgments
348
+
349
+ - Black-Scholes-Merton model from Fischer Black, Myron Scholes, and Robert Merton
350
+ - Greeks formulas from standard derivatives textbooks
351
+ - Design patterns inspired by QuantLib and similar professional libraries