quantark 0.1.0__py3-none-any.whl
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.
- quantark/__init__.py +3 -0
- quantark/_compat.py +150 -0
- quantark/asset/__init__.py +8 -0
- quantark/asset/bond/__init__.py +2 -0
- quantark/asset/bond/engine/__init__.py +44 -0
- quantark/asset/bond/engine/analytical/__init__.py +12 -0
- quantark/asset/bond/engine/analytical/black_engine.py +583 -0
- quantark/asset/bond/engine/analytical/bond_forward_engine.py +390 -0
- quantark/asset/bond/engine/analytical/bond_futures_engine.py +569 -0
- quantark/asset/bond/engine/convertible/__init__.py +12 -0
- quantark/asset/bond/engine/convertible/convertible_bond_engine.py +800 -0
- quantark/asset/bond/engine/discount/__init__.py +10 -0
- quantark/asset/bond/engine/discount/bond_discount_engine.py +517 -0
- quantark/asset/bond/engine/discount/frn_engine.py +913 -0
- quantark/asset/bond/engine/pde/__init__.py +14 -0
- quantark/asset/bond/engine/pde/convertible/__init__.py +21 -0
- quantark/asset/bond/engine/pde/convertible/jump_diffusion_engine.py +603 -0
- quantark/asset/bond/engine/pde/convertible/pde_params.py +59 -0
- quantark/asset/bond/engine/pde/convertible/tf_engine.py +546 -0
- quantark/asset/bond/engine/tree/__init__.py +14 -0
- quantark/asset/bond/engine/tree/convertible/__init__.py +21 -0
- quantark/asset/bond/engine/tree/convertible/binomial_engine.py +488 -0
- quantark/asset/bond/engine/tree/convertible/tree_params.py +72 -0
- quantark/asset/bond/engine/tree/convertible/trinomial_engine.py +1341 -0
- quantark/asset/bond/product/__init__.py +37 -0
- quantark/asset/bond/product/base_bond_product.py +114 -0
- quantark/asset/bond/product/convertible/__init__.py +16 -0
- quantark/asset/bond/product/convertible/convertible_bond.py +595 -0
- quantark/asset/bond/product/couponbond/__init__.py +12 -0
- quantark/asset/bond/product/couponbond/fixed_bond.py +285 -0
- quantark/asset/bond/product/couponbond/frn.py +538 -0
- quantark/asset/bond/product/forward/__init__.py +9 -0
- quantark/asset/bond/product/forward/base_bond_forward.py +92 -0
- quantark/asset/bond/product/forward/bond_forward.py +335 -0
- quantark/asset/bond/product/futures/__init__.py +8 -0
- quantark/asset/bond/product/futures/bond_futures.py +532 -0
- quantark/asset/bond/product/option/__init__.py +9 -0
- quantark/asset/bond/product/option/euro_short_term_bond_option.py +231 -0
- quantark/asset/bond/riskmeasures/__init__.py +13 -0
- quantark/asset/bond/riskmeasures/bond_greeks_calculator.py +484 -0
- quantark/asset/bond/schedule/__init__.py +21 -0
- quantark/asset/bond/schedule/cashflow.py +595 -0
- quantark/asset/equity/__init__.py +11 -0
- quantark/asset/equity/analysis/__init__.py +4 -0
- quantark/asset/equity/analysis/autocallable_path_analyzer.py +257 -0
- quantark/asset/equity/engine/__init__.py +84 -0
- quantark/asset/equity/engine/analytical/__init__.py +37 -0
- quantark/asset/equity/engine/analytical/american_option_engine.py +682 -0
- quantark/asset/equity/engine/analytical/asian_option_analytical_engine.py +1102 -0
- quantark/asset/equity/engine/analytical/barrier_analytical_engine.py +455 -0
- quantark/asset/equity/engine/analytical/black_scholes_engine.py +322 -0
- quantark/asset/equity/engine/analytical/deltaone_engine.py +340 -0
- quantark/asset/equity/engine/analytical/digital_option_engine.py +168 -0
- quantark/asset/equity/engine/analytical/double_barrier_option_engine.py +481 -0
- quantark/asset/equity/engine/analytical/double_sharkfin_option_analytical_engine.py +508 -0
- quantark/asset/equity/engine/analytical/one_touch_analytical_engine.py +302 -0
- quantark/asset/equity/engine/analytical/range_accrual_analytical_engine.py +396 -0
- quantark/asset/equity/engine/analytical/single_sharkfin_option_analytical_engine.py +229 -0
- quantark/asset/equity/engine/base_engine.py +137 -0
- quantark/asset/equity/engine/event_stats.py +85 -0
- quantark/asset/equity/engine/mc/__init__.py +31 -0
- quantark/asset/equity/engine/mc/american_option_mc_engine.py +485 -0
- quantark/asset/equity/engine/mc/asian_option_mc_engine.py +678 -0
- quantark/asset/equity/engine/mc/barrier_option_mc_engine.py +726 -0
- quantark/asset/equity/engine/mc/digital_option_mc_engine.py +419 -0
- quantark/asset/equity/engine/mc/double_sharkfin_option_mc_engine.py +676 -0
- quantark/asset/equity/engine/mc/euro_mc_engine.py +423 -0
- quantark/asset/equity/engine/mc/phoenix_mc_engine.py +1206 -0
- quantark/asset/equity/engine/mc/range_accrual_mc_engine.py +738 -0
- quantark/asset/equity/engine/mc/single_sharkfin_option_mc_engine.py +549 -0
- quantark/asset/equity/engine/mc/snowball_mc_engine.py +2250 -0
- quantark/asset/equity/engine/pde/__init__.py +36 -0
- quantark/asset/equity/engine/pde/american_pde_solver.py +211 -0
- quantark/asset/equity/engine/pde/barrier_pde_solver.py +692 -0
- quantark/asset/equity/engine/pde/base_pde_solver.py +994 -0
- quantark/asset/equity/engine/pde/double_barrier_pde_solver.py +510 -0
- quantark/asset/equity/engine/pde/double_one_touch_pde_solver.py +435 -0
- quantark/asset/equity/engine/pde/european_pde_solver.py +170 -0
- quantark/asset/equity/engine/pde/ko_reset_snowball_pde_solver.py +477 -0
- quantark/asset/equity/engine/pde/one_touch_pde_solver.py +439 -0
- quantark/asset/equity/engine/pde/phoenix_pde_solver.py +613 -0
- quantark/asset/equity/engine/pde/snowball_pde_solver.py +1810 -0
- quantark/asset/equity/engine/pde/spatial_grid.py +750 -0
- quantark/asset/equity/engine/pde/time_grid.py +308 -0
- quantark/asset/equity/engine/pde_engine.py +238 -0
- quantark/asset/equity/engine/quad/__init__.py +23 -0
- quantark/asset/equity/engine/quad/discrete_quad_engine.py +106 -0
- quantark/asset/equity/engine/quad/european_quad_engine.py +325 -0
- quantark/asset/equity/engine/quad/ko_reset_snowball_quad_engine.py +362 -0
- quantark/asset/equity/engine/quad/phoenix_quad_engine.py +614 -0
- quantark/asset/equity/engine/quad/quad_adapters.py +1260 -0
- quantark/asset/equity/engine/quad/quad_core.py +513 -0
- quantark/asset/equity/engine/quad/quad_math.py +219 -0
- quantark/asset/equity/engine/quad/snowball_quad_engine.py +1137 -0
- quantark/asset/equity/engine/validation/script/benchmark_check_american_analytical.py +117 -0
- quantark/asset/equity/engine/validation/script/benchmark_check_american_pde.py +114 -0
- quantark/asset/equity/engine/validation/script/benchmark_check_asian_analytical.py +440 -0
- quantark/asset/equity/engine/validation/script/benchmark_check_barrier_analytical.py +269 -0
- quantark/asset/equity/engine/validation/script/benchmark_check_barrier_pde_solver.py +636 -0
- quantark/asset/equity/engine/validation/script/benchmark_check_digital_option.py +256 -0
- quantark/asset/equity/engine/validation/script/benchmark_check_snowball_pde_solver.py +807 -0
- quantark/asset/equity/engine/validation/script/boundary_check_american_analytical.py +290 -0
- quantark/asset/equity/engine/validation/script/boundary_check_american_pde.py +242 -0
- quantark/asset/equity/engine/validation/script/boundary_check_asian_analytical.py +612 -0
- quantark/asset/equity/engine/validation/script/boundary_check_barrier_analytical.py +434 -0
- quantark/asset/equity/engine/validation/script/boundary_check_barrier_pde_solver.py +748 -0
- quantark/asset/equity/engine/validation/script/boundary_check_digital_option.py +575 -0
- quantark/asset/equity/engine/validation/script/boundary_check_snowball_pde_solver.py +1101 -0
- quantark/asset/equity/engine/validation/script/greeks_check_digital_option.py +349 -0
- quantark/asset/equity/engine/validation/script/mc_comparison_barrier_pde.py +270 -0
- quantark/asset/equity/engine/validation/script/quick_mc_compare.py +51 -0
- quantark/asset/equity/engine/validation/script/validation_stepdown_improved.py +97 -0
- quantark/asset/equity/param/__init__.py +24 -0
- quantark/asset/equity/param/engine_param_profiles.py +325 -0
- quantark/asset/equity/param/engine_params.py +728 -0
- quantark/asset/equity/process/__init__.py +7 -0
- quantark/asset/equity/process/bsm/__init__.py +7 -0
- quantark/asset/equity/process/bsm/bsm_process.py +108 -0
- quantark/asset/equity/process/bsm/qmc_brownian_bridge.py +401 -0
- quantark/asset/equity/process/bsm/qmc_path_generator.py +694 -0
- quantark/asset/equity/process/bsm/qmc_rqmc_driver.py +163 -0
- quantark/asset/equity/process/bsm/qmc_sobol.py +195 -0
- quantark/asset/equity/process/bsm/qmc_variance_reduction.py +292 -0
- quantark/asset/equity/product/__init__.py +8 -0
- quantark/asset/equity/product/base_equity_product.py +72 -0
- quantark/asset/equity/product/deltaone/__init__.py +22 -0
- quantark/asset/equity/product/deltaone/base_deltaone_product.py +147 -0
- quantark/asset/equity/product/deltaone/futures.py +485 -0
- quantark/asset/equity/product/deltaone/spot_instrument.py +118 -0
- quantark/asset/equity/product/option/__init__.py +104 -0
- quantark/asset/equity/product/option/american_option.py +114 -0
- quantark/asset/equity/product/option/asian_option.py +531 -0
- quantark/asset/equity/product/option/barrier_option.py +289 -0
- quantark/asset/equity/product/option/base_equity_option.py +659 -0
- quantark/asset/equity/product/option/digital_option.py +102 -0
- quantark/asset/equity/product/option/double_barrier_option.py +286 -0
- quantark/asset/equity/product/option/double_one_touch_option.py +310 -0
- quantark/asset/equity/product/option/double_sharkfin_option.py +466 -0
- quantark/asset/equity/product/option/european_vanilla_option.py +103 -0
- quantark/asset/equity/product/option/ko_reset_snowball_option.py +563 -0
- quantark/asset/equity/product/option/observation_schedule.py +530 -0
- quantark/asset/equity/product/option/one_touch_option.py +287 -0
- quantark/asset/equity/product/option/phoenix_config.py +116 -0
- quantark/asset/equity/product/option/phoenix_helpers.py +576 -0
- quantark/asset/equity/product/option/phoenix_option.py +1167 -0
- quantark/asset/equity/product/option/range_accrual_config.py +288 -0
- quantark/asset/equity/product/option/range_accrual_helpers.py +608 -0
- quantark/asset/equity/product/option/range_accrual_option.py +526 -0
- quantark/asset/equity/product/option/single_sharkfin_option.py +420 -0
- quantark/asset/equity/product/option/snowball_config.py +261 -0
- quantark/asset/equity/product/option/snowball_helpers.py +977 -0
- quantark/asset/equity/product/option/snowball_option.py +1242 -0
- quantark/asset/equity/report/__init__.py +15 -0
- quantark/asset/equity/report/autocallable_risk_report.py +2118 -0
- quantark/asset/equity/report/plotting.py +87 -0
- quantark/asset/equity/report/snowball_risk_comparison_report.py +2230 -0
- quantark/asset/equity/report/surfaces.py +123 -0
- quantark/asset/equity/report/term_structure.py +126 -0
- quantark/asset/equity/riskmeasures/__init__.py +7 -0
- quantark/asset/equity/riskmeasures/greeks_calculator.py +1204 -0
- quantark/asset/rate/__init__.py +58 -0
- quantark/asset/rate/engine/__init__.py +25 -0
- quantark/asset/rate/engine/cap_floor_engine.py +514 -0
- quantark/asset/rate/engine/fra_engine.py +286 -0
- quantark/asset/rate/engine/irs_discount_engine.py +891 -0
- quantark/asset/rate/engine/swaption_engine.py +587 -0
- quantark/asset/rate/product/__init__.py +67 -0
- quantark/asset/rate/product/cap_floor.py +550 -0
- quantark/asset/rate/product/fra.py +219 -0
- quantark/asset/rate/product/irs.py +1223 -0
- quantark/asset/rate/product/swaption.py +372 -0
- quantark/backtest/__init__.py +153 -0
- quantark/backtest/base.py +263 -0
- quantark/backtest/dashboard.py +874 -0
- quantark/backtest/equity/__init__.py +35 -0
- quantark/backtest/equity/config.py +118 -0
- quantark/backtest/equity/engine.py +408 -0
- quantark/backtest/equity/hedge_executor.py +374 -0
- quantark/backtest/equity/metrics.py +396 -0
- quantark/backtest/equity/results.py +232 -0
- quantark/backtest/equity/state.py +252 -0
- quantark/backtest/examples/__init__.py +4 -0
- quantark/backtest/examples/advanced_backtest.py +345 -0
- quantark/backtest/examples/basic_delta_hedge.py +246 -0
- quantark/backtest/examples/fi_dv01_hedge.py +267 -0
- quantark/backtest/fi/__init__.py +30 -0
- quantark/backtest/fi/config.py +114 -0
- quantark/backtest/fi/engine.py +378 -0
- quantark/backtest/fi/hedge_executor.py +254 -0
- quantark/backtest/fi/metrics.py +308 -0
- quantark/backtest/fi/results.py +193 -0
- quantark/backtest/fi/state.py +212 -0
- quantark/backtest/logger.py +393 -0
- quantark/backtest/otc/__init__.py +74 -0
- quantark/backtest/otc/_replay.py +637 -0
- quantark/backtest/otc/book_engine.py +587 -0
- quantark/backtest/otc/config.py +175 -0
- quantark/backtest/otc/dashboard.py +1006 -0
- quantark/backtest/otc/engine.py +420 -0
- quantark/backtest/otc/engine_factory.py +138 -0
- quantark/backtest/otc/market.py +216 -0
- quantark/backtest/otc/results.py +107 -0
- quantark/backtest/otc/state.py +166 -0
- quantark/backtest/report_generator.py +608 -0
- quantark/backtest/strategy/__init__.py +28 -0
- quantark/backtest/strategy/base_strategy.py +235 -0
- quantark/backtest/strategy/convexity_neutral_strategy.py +247 -0
- quantark/backtest/strategy/delta_neutral_strategy.py +283 -0
- quantark/backtest/strategy/dv01_neutral_strategy.py +283 -0
- quantark/backtest/transaction_costs.py +485 -0
- quantark/backtest/visualizer.py +1019 -0
- quantark/cashleg/__init__.py +31 -0
- quantark/cashleg/accrual_leg.py +120 -0
- quantark/cashleg/base.py +48 -0
- quantark/cashleg/base_amount.py +60 -0
- quantark/cashleg/deterministic_leg.py +39 -0
- quantark/cashleg/event_distribution.py +262 -0
- quantark/cashleg/fixed_payoff_leg.py +92 -0
- quantark/cashleg/leg_schedule.py +95 -0
- quantark/cashleg/leg_valuator.py +40 -0
- quantark/dynamicscenario/__init__.py +97 -0
- quantark/dynamicscenario/base.py +297 -0
- quantark/dynamicscenario/config.py +122 -0
- quantark/dynamicscenario/engine.py +703 -0
- quantark/dynamicscenario/equity/__init__.py +14 -0
- quantark/dynamicscenario/fi/__init__.py +24 -0
- quantark/dynamicscenario/fi/config.py +149 -0
- quantark/dynamicscenario/fi/engine.py +500 -0
- quantark/dynamicscenario/fi/results.py +503 -0
- quantark/dynamicscenario/path/__init__.py +17 -0
- quantark/dynamicscenario/path/day_path.py +397 -0
- quantark/dynamicscenario/path/fi_path_library.py +488 -0
- quantark/dynamicscenario/path/path_builder.py +726 -0
- quantark/dynamicscenario/path/path_library.py +620 -0
- quantark/dynamicscenario/report/__init__.py +12 -0
- quantark/dynamicscenario/report/dynamic_report.py +1175 -0
- quantark/dynamicscenario/report/visualizer.py +1586 -0
- quantark/dynamicscenario/results/__init__.py +19 -0
- quantark/dynamicscenario/results/dynamic_results.py +579 -0
- quantark/dynamicscenario/results/result_exporter.py +438 -0
- quantark/param/__init__.py +75 -0
- quantark/param/basis/__init__.py +19 -0
- quantark/param/basis/basis_yield.py +301 -0
- quantark/param/div/__init__.py +16 -0
- quantark/param/div/dividend_yield.py +123 -0
- quantark/param/index/__init__.py +52 -0
- quantark/param/index/rate_index.py +568 -0
- quantark/param/quote/__init__.py +7 -0
- quantark/param/quote/spot_quote.py +35 -0
- quantark/param/rrf/__init__.py +22 -0
- quantark/param/rrf/rate_curve.py +436 -0
- quantark/param/vol/__init__.py +6 -0
- quantark/param/vol/vol_surface.py +118 -0
- quantark/portfolio/__init__.py +61 -0
- quantark/portfolio/base.py +203 -0
- quantark/portfolio/equity/__init__.py +17 -0
- quantark/portfolio/equity/portfolio.py +391 -0
- quantark/portfolio/equity/position.py +368 -0
- quantark/portfolio/fi/__init__.py +14 -0
- quantark/portfolio/fi/portfolio.py +424 -0
- quantark/portfolio/fi/position.py +272 -0
- quantark/portfolio/portfolio_snapshot.py +221 -0
- quantark/portfolio/portfolio_storage.py +414 -0
- quantark/priceenv/__init__.py +7 -0
- quantark/priceenv/pricing_environment.py +196 -0
- quantark/rfq/__init__.py +32 -0
- quantark/rfq/builders.py +102 -0
- quantark/rfq/models.py +214 -0
- quantark/rfq/registry.py +611 -0
- quantark/rfq/service.py +237 -0
- quantark/simm/__init__.py +155 -0
- quantark/simm/calibration/__init__.py +206 -0
- quantark/simm/calibration/accessors.py +439 -0
- quantark/simm/calibration/commodity.py +156 -0
- quantark/simm/calibration/credit_non_qualifying.py +79 -0
- quantark/simm/calibration/credit_qualifying.py +130 -0
- quantark/simm/calibration/cross_risk.py +39 -0
- quantark/simm/calibration/equity.py +125 -0
- quantark/simm/calibration/fx.py +92 -0
- quantark/simm/calibration/ir.py +152 -0
- quantark/simm/calibration/version.py +33 -0
- quantark/simm/config.py +186 -0
- quantark/simm/crif/__init__.py +35 -0
- quantark/simm/crif/models.py +230 -0
- quantark/simm/crif/parser.py +585 -0
- quantark/simm/engines/__init__.py +62 -0
- quantark/simm/engines/aggregation/__init__.py +67 -0
- quantark/simm/engines/aggregation/addon.py +141 -0
- quantark/simm/engines/aggregation/bucket_aggregator.py +298 -0
- quantark/simm/engines/aggregation/concentration.py +349 -0
- quantark/simm/engines/aggregation/product_class_aggregator.py +183 -0
- quantark/simm/engines/aggregation/risk_class_aggregator.py +403 -0
- quantark/simm/engines/aggregation/simm_calculator.py +430 -0
- quantark/simm/engines/aggregation/weighted_sensitivity.py +272 -0
- quantark/simm/engines/base.py +231 -0
- quantark/simm/engines/classification/__init__.py +10 -0
- quantark/simm/engines/classification/bucket_mapper.py +347 -0
- quantark/simm/engines/factory.py +137 -0
- quantark/simm/engines/portfolio_adapter.py +336 -0
- quantark/simm/engines/result.py +176 -0
- quantark/simm/engines/risk_class/__init__.py +18 -0
- quantark/simm/engines/risk_class/equity_engine.py +263 -0
- quantark/simm/engines/risk_class/ir_engine.py +264 -0
- quantark/simm/report/__init__.py +17 -0
- quantark/simm/report/crif_export.py +284 -0
- quantark/simm/report/excel_generator.py +401 -0
- quantark/simm/report/html_generator.py +840 -0
- quantark/simm/results/__init__.py +38 -0
- quantark/simm/results/attribution.py +313 -0
- quantark/simm/results/simm_result.py +339 -0
- quantark/simm/results/whatif.py +268 -0
- quantark/simm/sensitivity.py +533 -0
- quantark/simm/taxonomy.py +416 -0
- quantark/stresstest/__init__.py +67 -0
- quantark/stresstest/base.py +116 -0
- quantark/stresstest/config.py +5 -0
- quantark/stresstest/engine.py +5 -0
- quantark/stresstest/equity/__init__.py +17 -0
- quantark/stresstest/equity/config.py +69 -0
- quantark/stresstest/equity/engine.py +272 -0
- quantark/stresstest/equity/report/__init__.py +7 -0
- quantark/stresstest/equity/report/report_generator.py +423 -0
- quantark/stresstest/equity/report/visualizer.py +328 -0
- quantark/stresstest/equity/results.py +145 -0
- quantark/stresstest/fi/__init__.py +15 -0
- quantark/stresstest/fi/config.py +59 -0
- quantark/stresstest/fi/engine.py +213 -0
- quantark/stresstest/fi/metrics.py +60 -0
- quantark/stresstest/fi/results.py +64 -0
- quantark/stresstest/report/__init__.py +12 -0
- quantark/stresstest/report/report_generator.py +5 -0
- quantark/stresstest/report/visualizer.py +5 -0
- quantark/stresstest/results/__init__.py +16 -0
- quantark/stresstest/results/result_aggregator.py +325 -0
- quantark/stresstest/results/result_exporter.py +286 -0
- quantark/stresstest/results/stress_results.py +5 -0
- quantark/stresstest/scenario/__init__.py +13 -0
- quantark/stresstest/scenario/scenario.py +242 -0
- quantark/stresstest/scenario/scenario_builder.py +376 -0
- quantark/stresstest/scenario/scenario_library.py +435 -0
- quantark/stresstest/scenario/scenario_storage.py +224 -0
- quantark/stresstest/stress/__init__.py +13 -0
- quantark/stresstest/stress/stress_applicator.py +590 -0
- quantark/stresstest/stress/stress_types.py +142 -0
- quantark/util/__init__.py +23 -0
- quantark/util/barrier_shift.py +44 -0
- quantark/util/calendar/__init__.py +27 -0
- quantark/util/calendar/business_calendar.py +584 -0
- quantark/util/calendar/day_counter.py +517 -0
- quantark/util/calendar/holidayfile/china.csv +1920 -0
- quantark/util/calendar/holidayfile/china_sse.csv +1462 -0
- quantark/util/enum/__init__.py +81 -0
- quantark/util/enum/bond_enums.py +112 -0
- quantark/util/enum/deltaone_enums.py +16 -0
- quantark/util/enum/engine_enums.py +137 -0
- quantark/util/enum/greeks_enums.py +29 -0
- quantark/util/enum/option_enums.py +221 -0
- quantark/util/exceptions.py +66 -0
- quantark/util/marketdata/__init__.py +39 -0
- quantark/util/marketdata/adapter/base_adapter.py +203 -0
- quantark/util/marketdata/adapter/mock_adapter.py +265 -0
- quantark/util/marketdata/converter.py +289 -0
- quantark/util/marketdata/example_usage.py +314 -0
- quantark/util/marketdata/generator/__init__.py +7 -0
- quantark/util/marketdata/generator/mock_generator.py +466 -0
- quantark/util/marketdata/models.py +358 -0
- quantark/util/marketdata/storage/__init__.py +7 -0
- quantark/util/marketdata/storage/parquet_storage.py +340 -0
- quantark/util/numerical/__init__.py +98 -0
- quantark/util/numerical/comparison.py +219 -0
- quantark/util/numerical/constants.py +98 -0
- quantark/util/numerical/formatting.py +380 -0
- quantark/util/numerical/pnl.py +17 -0
- quantark/util/numerical/safe_math.py +238 -0
- quantark/util/numerical/validation.py +315 -0
- quantark/var/__init__.py +39 -0
- quantark/var/attribution.py +398 -0
- quantark/var/backtest/__init__.py +7 -0
- quantark/var/backtest/var_backtester.py +309 -0
- quantark/var/base.py +63 -0
- quantark/var/config.py +219 -0
- quantark/var/engines/__init__.py +13 -0
- quantark/var/engines/historical.py +925 -0
- quantark/var/engines/monte_carlo.py +870 -0
- quantark/var/engines/parametric.py +1199 -0
- quantark/var/results/__init__.py +16 -0
- quantark/var/results/incremental_var_result.py +131 -0
- quantark/var/results/var_report.py +346 -0
- quantark/var/results/var_result.py +134 -0
- quantark/var/risk_factors/__init__.py +22 -0
- quantark/var/risk_factors/base.py +41 -0
- quantark/var/risk_factors/equity_factors.py +158 -0
- quantark/var/risk_factors/fi_factors.py +99 -0
- quantark-0.1.0.dist-info/METADATA +351 -0
- quantark-0.1.0.dist-info/RECORD +399 -0
- quantark-0.1.0.dist-info/WHEEL +4 -0
- quantark-0.1.0.dist-info/licenses/LICENSE +202 -0
- quantark-0.1.0.dist-info/licenses/NOTICE +2 -0
- quantark_compat.pth +1 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Analytical pricing engine for single sharkfin options.
|
|
3
|
+
|
|
4
|
+
The payoff is decomposed into:
|
|
5
|
+
- a no-rebate knock-out vanilla option,
|
|
6
|
+
- a one-touch cash leg for the knock-out rebate, and
|
|
7
|
+
- a no-touch cash leg for the no-hit rebate.
|
|
8
|
+
|
|
9
|
+
Discrete monitoring is handled by the underlying barrier and one-touch
|
|
10
|
+
analytical engines using the Broadie-Glasserman-Kou barrier shift.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from typing import Optional
|
|
14
|
+
|
|
15
|
+
from quantark.asset.equity.engine.base_engine import BaseEngine
|
|
16
|
+
from quantark.asset.equity.product.base_equity_product import BaseEquityProduct
|
|
17
|
+
from quantark.asset.equity.product.option import (
|
|
18
|
+
BarrierOption,
|
|
19
|
+
OneTouchOption,
|
|
20
|
+
SingleSharkfinOption,
|
|
21
|
+
)
|
|
22
|
+
from quantark.asset.equity.param import EngineParams
|
|
23
|
+
from quantark.priceenv import PricingEnvironment
|
|
24
|
+
from quantark.util.enum import BarrierDirection, BarrierType, ObservationType, TouchType
|
|
25
|
+
from quantark.util.enum.engine_enums import EngineType
|
|
26
|
+
from quantark.util.exceptions import PricingError, ValidationError
|
|
27
|
+
from quantark.util.numerical import validate_non_negative, validate_positive
|
|
28
|
+
|
|
29
|
+
from .barrier_analytical_engine import BarrierAnalyticalEngine
|
|
30
|
+
from .one_touch_analytical_engine import OneTouchAnalyticalEngine
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class SingleSharkfinOptionAnalyticalEngine(BaseEngine):
|
|
34
|
+
"""
|
|
35
|
+
Closed-form analytical engine for SingleSharkfinOption.
|
|
36
|
+
|
|
37
|
+
Supports expiry-only and continuous monitoring exactly under Black-Scholes
|
|
38
|
+
assumptions. Discrete monitoring uses the standard BGK continuity correction
|
|
39
|
+
implemented by the composed barrier and one-touch engines, so daily
|
|
40
|
+
observation schedules are approximated by shifting the barrier away from spot.
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
engine_type = EngineType.ANALYTICAL
|
|
44
|
+
|
|
45
|
+
MIN_MATURITY = 1e-10
|
|
46
|
+
MAX_MATURITY = 50.0
|
|
47
|
+
MIN_VOL = 0.001
|
|
48
|
+
MAX_VOL = 5.0
|
|
49
|
+
|
|
50
|
+
def __init__(self, params: Optional[EngineParams] = None):
|
|
51
|
+
super().__init__(params)
|
|
52
|
+
self._barrier_engine = BarrierAnalyticalEngine(params)
|
|
53
|
+
self._one_touch_engine = OneTouchAnalyticalEngine(params)
|
|
54
|
+
|
|
55
|
+
def price(
|
|
56
|
+
self, product: BaseEquityProduct, pricing_env: PricingEnvironment
|
|
57
|
+
) -> float:
|
|
58
|
+
"""
|
|
59
|
+
Price a single sharkfin option analytically.
|
|
60
|
+
|
|
61
|
+
Args:
|
|
62
|
+
product: SingleSharkfinOption instance.
|
|
63
|
+
pricing_env: Market data environment.
|
|
64
|
+
|
|
65
|
+
Returns:
|
|
66
|
+
Present value scaled by product.contract_multiplier.
|
|
67
|
+
|
|
68
|
+
Raises:
|
|
69
|
+
PricingError: If product type or observation mode is unsupported.
|
|
70
|
+
ValidationError: If pricing inputs are invalid.
|
|
71
|
+
"""
|
|
72
|
+
if not isinstance(product, SingleSharkfinOption):
|
|
73
|
+
raise PricingError(
|
|
74
|
+
"SingleSharkfinOptionAnalyticalEngine only supports "
|
|
75
|
+
f"SingleSharkfinOption, got {type(product).__name__}"
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
spot = pricing_env.spot
|
|
79
|
+
maturity = product.get_maturity(pricing_env)
|
|
80
|
+
rate = pricing_env.get_rate(maturity)
|
|
81
|
+
div = pricing_env.get_div_yield(maturity)
|
|
82
|
+
vol = pricing_env.get_vol(product.strike, maturity)
|
|
83
|
+
|
|
84
|
+
self._validate_inputs(
|
|
85
|
+
spot=spot,
|
|
86
|
+
strike=product.strike,
|
|
87
|
+
barrier=product.barrier,
|
|
88
|
+
maturity=maturity,
|
|
89
|
+
rate=rate,
|
|
90
|
+
div=div,
|
|
91
|
+
vol=vol,
|
|
92
|
+
participation_rate=product.participation_rate,
|
|
93
|
+
knock_out_rebate=product.knock_out_rebate,
|
|
94
|
+
no_hit_rebate=product.no_hit_rebate,
|
|
95
|
+
contract_multiplier=product.contract_multiplier,
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
if maturity < self.MIN_MATURITY:
|
|
99
|
+
return product.get_payoff(spot)
|
|
100
|
+
|
|
101
|
+
if product.observation_type not in (
|
|
102
|
+
ObservationType.EXPIRY,
|
|
103
|
+
ObservationType.CONTINUOUS,
|
|
104
|
+
ObservationType.DISCRETE,
|
|
105
|
+
):
|
|
106
|
+
raise PricingError(
|
|
107
|
+
f"Unsupported observation type: {product.observation_type}"
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
ko_option_value = self._price_no_rebate_knock_out(product, pricing_env)
|
|
111
|
+
knock_out_rebate_value = self._price_touch_leg(
|
|
112
|
+
product=product,
|
|
113
|
+
pricing_env=pricing_env,
|
|
114
|
+
rebate=product.knock_out_rebate,
|
|
115
|
+
touch_type=TouchType.ONE_TOUCH,
|
|
116
|
+
)
|
|
117
|
+
no_hit_rebate_value = self._price_touch_leg(
|
|
118
|
+
product=product,
|
|
119
|
+
pricing_env=pricing_env,
|
|
120
|
+
rebate=product.no_hit_rebate,
|
|
121
|
+
touch_type=TouchType.NO_TOUCH,
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
value = (
|
|
125
|
+
product.participation_rate * ko_option_value
|
|
126
|
+
+ knock_out_rebate_value
|
|
127
|
+
+ no_hit_rebate_value
|
|
128
|
+
)
|
|
129
|
+
return max(value, 0.0) * product.contract_multiplier
|
|
130
|
+
|
|
131
|
+
def _price_no_rebate_knock_out(
|
|
132
|
+
self, product: SingleSharkfinOption, pricing_env: PricingEnvironment
|
|
133
|
+
) -> float:
|
|
134
|
+
"""Value the capped sharkfin participation leg as a knock-out option."""
|
|
135
|
+
barrier_option = BarrierOption(
|
|
136
|
+
strike=product.strike,
|
|
137
|
+
option_type=product.option_type,
|
|
138
|
+
barrier=product.barrier,
|
|
139
|
+
barrier_type=self._barrier_type(product),
|
|
140
|
+
maturity=product.maturity,
|
|
141
|
+
exercise_date=product.exercise_date,
|
|
142
|
+
settlement_date=product.settlement_date,
|
|
143
|
+
rebate=0.0,
|
|
144
|
+
participation_rate=1.0,
|
|
145
|
+
pay_at_hit=False,
|
|
146
|
+
observation_type=product.observation_type,
|
|
147
|
+
observation_dates=product.observation_dates,
|
|
148
|
+
observation_schedule=product.observation_schedule,
|
|
149
|
+
contract_multiplier=1.0,
|
|
150
|
+
)
|
|
151
|
+
return self._barrier_engine.price(barrier_option, pricing_env)
|
|
152
|
+
|
|
153
|
+
def _price_touch_leg(
|
|
154
|
+
self,
|
|
155
|
+
product: SingleSharkfinOption,
|
|
156
|
+
pricing_env: PricingEnvironment,
|
|
157
|
+
rebate: float,
|
|
158
|
+
touch_type: TouchType,
|
|
159
|
+
) -> float:
|
|
160
|
+
"""Value a fixed cash leg conditional on touch or no-touch."""
|
|
161
|
+
if rebate <= 0.0:
|
|
162
|
+
return 0.0
|
|
163
|
+
|
|
164
|
+
touch_option = OneTouchOption(
|
|
165
|
+
barrier=product.barrier,
|
|
166
|
+
barrier_direction=self._barrier_direction(product),
|
|
167
|
+
maturity=product.maturity,
|
|
168
|
+
exercise_date=product.exercise_date,
|
|
169
|
+
settlement_date=product.settlement_date,
|
|
170
|
+
rebate=rebate,
|
|
171
|
+
payment_at_hit=(
|
|
172
|
+
product.pay_at_hit if touch_type == TouchType.ONE_TOUCH else False
|
|
173
|
+
),
|
|
174
|
+
touch_type=touch_type,
|
|
175
|
+
observation_type=product.observation_type,
|
|
176
|
+
observation_dates=product.observation_dates,
|
|
177
|
+
observation_schedule=product.observation_schedule,
|
|
178
|
+
)
|
|
179
|
+
return self._one_touch_engine.price(touch_option, pricing_env)
|
|
180
|
+
|
|
181
|
+
def _barrier_type(self, product: SingleSharkfinOption) -> BarrierType:
|
|
182
|
+
"""Map sharkfin orientation to a knock-out barrier type."""
|
|
183
|
+
return BarrierType.UP_OUT if product.is_call() else BarrierType.DOWN_OUT
|
|
184
|
+
|
|
185
|
+
def _barrier_direction(self, product: SingleSharkfinOption) -> BarrierDirection:
|
|
186
|
+
"""Map sharkfin orientation to a one-touch barrier direction."""
|
|
187
|
+
return BarrierDirection.UP if product.is_call() else BarrierDirection.DOWN
|
|
188
|
+
|
|
189
|
+
def _validate_inputs(
|
|
190
|
+
self,
|
|
191
|
+
spot: float,
|
|
192
|
+
strike: float,
|
|
193
|
+
barrier: float,
|
|
194
|
+
maturity: float,
|
|
195
|
+
rate: float,
|
|
196
|
+
div: float,
|
|
197
|
+
vol: float,
|
|
198
|
+
participation_rate: float,
|
|
199
|
+
knock_out_rebate: float,
|
|
200
|
+
no_hit_rebate: float,
|
|
201
|
+
contract_multiplier: float,
|
|
202
|
+
) -> None:
|
|
203
|
+
"""Validate market and product inputs for analytical pricing."""
|
|
204
|
+
validate_positive(spot, "spot")
|
|
205
|
+
validate_positive(strike, "strike")
|
|
206
|
+
validate_positive(barrier, "barrier")
|
|
207
|
+
validate_non_negative(maturity, "maturity")
|
|
208
|
+
validate_positive(vol, "volatility")
|
|
209
|
+
validate_non_negative(participation_rate, "participation_rate")
|
|
210
|
+
validate_non_negative(knock_out_rebate, "knock_out_rebate")
|
|
211
|
+
validate_non_negative(no_hit_rebate, "no_hit_rebate")
|
|
212
|
+
validate_positive(contract_multiplier, "contract_multiplier")
|
|
213
|
+
|
|
214
|
+
if vol < self.MIN_VOL or vol > self.MAX_VOL:
|
|
215
|
+
raise ValidationError(
|
|
216
|
+
f"Volatility {vol} outside supported range "
|
|
217
|
+
f"[{self.MIN_VOL}, {self.MAX_VOL}]"
|
|
218
|
+
)
|
|
219
|
+
if maturity > self.MAX_MATURITY:
|
|
220
|
+
raise ValidationError(
|
|
221
|
+
f"Maturity too long for analytical sharkfin pricing: {maturity}"
|
|
222
|
+
)
|
|
223
|
+
if div < 0:
|
|
224
|
+
raise ValidationError(f"Dividend yield must be non-negative, got {div}")
|
|
225
|
+
if abs(rate) > 1.0:
|
|
226
|
+
raise ValidationError(f"Risk-free rate outside reasonable bounds: {rate}")
|
|
227
|
+
|
|
228
|
+
def __repr__(self):
|
|
229
|
+
return "SingleSharkfinOptionAnalyticalEngine()"
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Base class for pricing engines.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from abc import ABC, abstractmethod
|
|
6
|
+
from typing import Dict, Optional
|
|
7
|
+
from quantark.asset.equity.product.base_equity_product import BaseEquityProduct
|
|
8
|
+
from quantark.priceenv import PricingEnvironment
|
|
9
|
+
from quantark.asset.equity.param import EngineParams
|
|
10
|
+
from quantark.asset.equity.engine.event_stats import AutocallableEventStats
|
|
11
|
+
from quantark.util.enum.engine_enums import EngineType
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class BaseEngine(ABC):
|
|
15
|
+
"""
|
|
16
|
+
Abstract base class for all pricing engines.
|
|
17
|
+
|
|
18
|
+
Engines are responsible for computing prices and Greeks for derivatives.
|
|
19
|
+
|
|
20
|
+
Attributes:
|
|
21
|
+
engine_type: The type category of this engine (ANALYTICAL, MONTE_CARLO, PDE, etc.)
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
engine_type: EngineType = EngineType.ANALYTICAL
|
|
25
|
+
|
|
26
|
+
def __init__(self, params: Optional[EngineParams] = None):
|
|
27
|
+
"""
|
|
28
|
+
Initialize the engine.
|
|
29
|
+
|
|
30
|
+
Args:
|
|
31
|
+
params: Engine configuration parameters
|
|
32
|
+
"""
|
|
33
|
+
self.params = params if params is not None else EngineParams()
|
|
34
|
+
|
|
35
|
+
@abstractmethod
|
|
36
|
+
def price(
|
|
37
|
+
self, product: BaseEquityProduct, pricing_env: PricingEnvironment
|
|
38
|
+
) -> float:
|
|
39
|
+
"""
|
|
40
|
+
Calculate the price of the product.
|
|
41
|
+
|
|
42
|
+
Args:
|
|
43
|
+
product: The derivative product to price
|
|
44
|
+
pricing_env: Pricing environment with market data
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
Product price
|
|
48
|
+
"""
|
|
49
|
+
pass
|
|
50
|
+
|
|
51
|
+
def price_with_events(
|
|
52
|
+
self,
|
|
53
|
+
product: BaseEquityProduct,
|
|
54
|
+
pricing_env: PricingEnvironment,
|
|
55
|
+
emit_distribution: bool = True,
|
|
56
|
+
) -> "PricingResult":
|
|
57
|
+
"""
|
|
58
|
+
Return product NPV and an event distribution for cash-leg valuation.
|
|
59
|
+
|
|
60
|
+
Engines that already implement calculate_event_stats are adapted to the
|
|
61
|
+
generalized EventDistribution. Engines without event stats fall back to
|
|
62
|
+
a maturity-only distribution, which is sufficient for deterministic and
|
|
63
|
+
full-schedule cash legs.
|
|
64
|
+
"""
|
|
65
|
+
from quantark.cashleg.event_distribution import EventDistribution, PricingResult
|
|
66
|
+
|
|
67
|
+
if emit_distribution:
|
|
68
|
+
stats = self.calculate_event_stats(product, pricing_env)
|
|
69
|
+
if stats is not None:
|
|
70
|
+
return PricingResult(
|
|
71
|
+
npv=float(stats.pv),
|
|
72
|
+
event_distribution=EventDistribution.from_autocallable_stats(stats),
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
npv = self.price(product, pricing_env)
|
|
76
|
+
return PricingResult(
|
|
77
|
+
npv=npv,
|
|
78
|
+
event_distribution=EventDistribution.trivial(product.get_maturity(pricing_env)),
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
def calculate_greeks(
|
|
82
|
+
self, product: BaseEquityProduct, pricing_env: PricingEnvironment
|
|
83
|
+
) -> Dict[str, float]:
|
|
84
|
+
"""
|
|
85
|
+
Calculate Greeks using finite difference method.
|
|
86
|
+
|
|
87
|
+
This default implementation uses bump-and-reprice.
|
|
88
|
+
Subclasses can override to provide analytical Greeks.
|
|
89
|
+
|
|
90
|
+
Args:
|
|
91
|
+
product: The derivative product
|
|
92
|
+
pricing_env: Pricing environment with market data
|
|
93
|
+
|
|
94
|
+
Returns:
|
|
95
|
+
Dictionary of Greeks
|
|
96
|
+
"""
|
|
97
|
+
from copy import deepcopy
|
|
98
|
+
|
|
99
|
+
base_price = self.price(product, pricing_env)
|
|
100
|
+
greeks = {"price": base_price}
|
|
101
|
+
|
|
102
|
+
# Delta: dV/dS
|
|
103
|
+
env_up = deepcopy(pricing_env)
|
|
104
|
+
env_up.spot_quote.spot *= 1 + self.params.bump_size
|
|
105
|
+
price_up = self.price(product, env_up)
|
|
106
|
+
|
|
107
|
+
env_down = deepcopy(pricing_env)
|
|
108
|
+
env_down.spot_quote.spot *= 1 - self.params.bump_size
|
|
109
|
+
price_down = self.price(product, env_down)
|
|
110
|
+
|
|
111
|
+
delta = (price_up - price_down) / (2 * pricing_env.spot * self.params.bump_size)
|
|
112
|
+
greeks["delta"] = delta
|
|
113
|
+
|
|
114
|
+
# Gamma: d²V/dS²
|
|
115
|
+
gamma = (price_up - 2 * base_price + price_down) / (
|
|
116
|
+
pricing_env.spot * self.params.bump_size
|
|
117
|
+
) ** 2
|
|
118
|
+
greeks["gamma"] = gamma
|
|
119
|
+
|
|
120
|
+
return greeks
|
|
121
|
+
|
|
122
|
+
def calculate_event_stats(
|
|
123
|
+
self, product: BaseEquityProduct, pricing_env: PricingEnvironment
|
|
124
|
+
) -> Optional[AutocallableEventStats]:
|
|
125
|
+
"""
|
|
126
|
+
Optionally provide per-observation event stats and cashflow decomposition.
|
|
127
|
+
|
|
128
|
+
Engines MAY override this method to provide per-observation probabilities and
|
|
129
|
+
expected discounted cashflows for autocallable products. This enables faster
|
|
130
|
+
reporting (especially for QUAD/PDE engines) compared to Monte Carlo analyzers.
|
|
131
|
+
|
|
132
|
+
Default behavior: return None (not supported).
|
|
133
|
+
"""
|
|
134
|
+
return None
|
|
135
|
+
|
|
136
|
+
def __repr__(self):
|
|
137
|
+
return f"{self.__class__.__name__}()"
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Engine-level event stats and cashflow decomposition types.
|
|
3
|
+
|
|
4
|
+
These types define an optional API that engines MAY implement to provide
|
|
5
|
+
per-observation event probabilities and expected discounted cashflows for
|
|
6
|
+
autocallable products (Snowball-first).
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from dataclasses import dataclass, field
|
|
12
|
+
|
|
13
|
+
import numpy as np
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@dataclass(frozen=True)
|
|
17
|
+
class AutocallableEventStats:
|
|
18
|
+
"""
|
|
19
|
+
Event probabilities and expected discounted cashflows.
|
|
20
|
+
|
|
21
|
+
Attributes:
|
|
22
|
+
pv: Present value produced by the engine for the given product/env.
|
|
23
|
+
ko_times: KO observation times (year fractions from valuation date).
|
|
24
|
+
ko_probability: Probability of KO occurring at each observation time.
|
|
25
|
+
survival_probability: Probability of surviving (not KO'd) up to each observation.
|
|
26
|
+
expected_discounted_ko_cashflow: Expected discounted KO redemption cashflow at each observation.
|
|
27
|
+
ki_probability: Probability that KI occurred at least once before maturity (if applicable).
|
|
28
|
+
expected_discounted_maturity_cashflow: Expected discounted maturity cashflow (conditional on no KO).
|
|
29
|
+
reconciliation_error: pv minus sum(expected discounted cashflows) if computed, else 0.0.
|
|
30
|
+
ki_times: KI observation/monitoring times where event probabilities are available.
|
|
31
|
+
ki_event_probability: Probability of first KI occurring at each KI time.
|
|
32
|
+
ki_survival_probability: Probability of surviving without KI up to each KI time.
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
pv: float
|
|
36
|
+
ko_times: np.ndarray
|
|
37
|
+
ko_probability: np.ndarray
|
|
38
|
+
survival_probability: np.ndarray
|
|
39
|
+
expected_discounted_ko_cashflow: np.ndarray
|
|
40
|
+
ki_probability: float
|
|
41
|
+
expected_discounted_maturity_cashflow: float
|
|
42
|
+
reconciliation_error: float = 0.0
|
|
43
|
+
ki_times: np.ndarray = field(default_factory=lambda: np.array([]))
|
|
44
|
+
ki_event_probability: np.ndarray = field(default_factory=lambda: np.array([]))
|
|
45
|
+
ki_survival_probability: np.ndarray = field(default_factory=lambda: np.array([]))
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@dataclass(frozen=True)
|
|
49
|
+
class PhoenixEventStats(AutocallableEventStats):
|
|
50
|
+
"""
|
|
51
|
+
Event stats for Phoenix options including coupon diagnostics.
|
|
52
|
+
|
|
53
|
+
Attributes:
|
|
54
|
+
coupon_probability: Coupon trigger probability at each observation time.
|
|
55
|
+
expected_discounted_coupon_cashflow: Expected discounted coupon cashflow per observation.
|
|
56
|
+
"""
|
|
57
|
+
|
|
58
|
+
coupon_probability: np.ndarray = field(default_factory=lambda: np.array([]))
|
|
59
|
+
expected_discounted_coupon_cashflow: np.ndarray = field(
|
|
60
|
+
default_factory=lambda: np.array([])
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@dataclass(frozen=True)
|
|
65
|
+
class KOResetEventStats(AutocallableEventStats):
|
|
66
|
+
"""
|
|
67
|
+
Event stats for KO-reset snowball options.
|
|
68
|
+
|
|
69
|
+
Attributes:
|
|
70
|
+
pre_ko_times: Pre-KI KO observation times (absolute).
|
|
71
|
+
pre_ko_probability: KO probability per pre-KI observation.
|
|
72
|
+
post_ko_times: Post-KI KO observation times (absolute or offsets for REBASED).
|
|
73
|
+
post_ko_probability: KO probability per post-KI observation (or offset).
|
|
74
|
+
pre_ko_probability_total: Total probability of pre-KI KO.
|
|
75
|
+
post_ko_probability_total: Total probability of post-KI KO.
|
|
76
|
+
expected_discounted_post_ko_cashflow: Total expected discounted KO cashflow after KI.
|
|
77
|
+
"""
|
|
78
|
+
|
|
79
|
+
pre_ko_times: np.ndarray = field(default_factory=lambda: np.array([]))
|
|
80
|
+
pre_ko_probability: np.ndarray = field(default_factory=lambda: np.array([]))
|
|
81
|
+
post_ko_times: np.ndarray = field(default_factory=lambda: np.array([]))
|
|
82
|
+
post_ko_probability: np.ndarray = field(default_factory=lambda: np.array([]))
|
|
83
|
+
pre_ko_probability_total: float = 0.0
|
|
84
|
+
post_ko_probability_total: float = 0.0
|
|
85
|
+
expected_discounted_post_ko_cashflow: float = 0.0
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Monte Carlo pricing engines for equity derivatives.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from .euro_mc_engine import EuropeanMCEngine
|
|
6
|
+
from .american_option_mc_engine import AmericanOptionMCEngine, AmericanMCResult
|
|
7
|
+
from .snowball_mc_engine import SnowballMCEngine
|
|
8
|
+
from .phoenix_mc_engine import PhoenixMCEngine, PhoenixMCResult
|
|
9
|
+
from .asian_option_mc_engine import AsianOptionMCEngine, AsianMCResult
|
|
10
|
+
from .digital_option_mc_engine import DigitalOptionMCEngine
|
|
11
|
+
from .barrier_option_mc_engine import BarrierOptionMCEngine
|
|
12
|
+
from .single_sharkfin_option_mc_engine import SingleSharkfinOptionMCEngine
|
|
13
|
+
from .double_sharkfin_option_mc_engine import DoubleSharkfinOptionMCEngine
|
|
14
|
+
from .range_accrual_mc_engine import RangeAccrualMCEngine, RangeAccrualMCResult
|
|
15
|
+
|
|
16
|
+
__all__ = [
|
|
17
|
+
"EuropeanMCEngine",
|
|
18
|
+
"AmericanOptionMCEngine",
|
|
19
|
+
"AmericanMCResult",
|
|
20
|
+
"SnowballMCEngine",
|
|
21
|
+
"PhoenixMCEngine",
|
|
22
|
+
"PhoenixMCResult",
|
|
23
|
+
"AsianOptionMCEngine",
|
|
24
|
+
"AsianMCResult",
|
|
25
|
+
"DigitalOptionMCEngine",
|
|
26
|
+
"BarrierOptionMCEngine",
|
|
27
|
+
"SingleSharkfinOptionMCEngine",
|
|
28
|
+
"DoubleSharkfinOptionMCEngine",
|
|
29
|
+
"RangeAccrualMCEngine",
|
|
30
|
+
"RangeAccrualMCResult",
|
|
31
|
+
]
|