quantsupport 0.1.9__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.
- quantsupport-0.1.9/.DS_Store +0 -0
- quantsupport-0.1.9/.github/scripts/release.py +345 -0
- quantsupport-0.1.9/.github/workflows/bindings.yml +105 -0
- quantsupport-0.1.9/.github/workflows/pages.yml +49 -0
- quantsupport-0.1.9/.github/workflows/release.yml +124 -0
- quantsupport-0.1.9/.github/workflows/rust.yml +43 -0
- quantsupport-0.1.9/.gitignore +11 -0
- quantsupport-0.1.9/.vscode/launch.json +120 -0
- quantsupport-0.1.9/CITATION.cff +25 -0
- quantsupport-0.1.9/Cargo.lock +2242 -0
- quantsupport-0.1.9/Cargo.toml +64 -0
- quantsupport-0.1.9/LICENSE +21 -0
- quantsupport-0.1.9/PKG-INFO +666 -0
- quantsupport-0.1.9/README.md +438 -0
- quantsupport-0.1.9/bindings/python/Cargo.toml +26 -0
- quantsupport-0.1.9/bindings/python/README.md +650 -0
- quantsupport-0.1.9/bindings/python/examples/.gitignore +1 -0
- quantsupport-0.1.9/bindings/python/examples/README.md +173 -0
- quantsupport-0.1.9/bindings/python/examples/bootstrap/README.md +20 -0
- quantsupport-0.1.9/bindings/python/examples/bootstrap/curves.ipynb +679 -0
- quantsupport-0.1.9/bindings/python/examples/bootstrap/market_data.py +48 -0
- quantsupport-0.1.9/bindings/python/examples/cva/README.md +36 -0
- quantsupport-0.1.9/bindings/python/examples/cva/data/credit_curves.json +17 -0
- quantsupport-0.1.9/bindings/python/examples/cva/data/credit_quotes.json +17 -0
- quantsupport-0.1.9/bindings/python/examples/cva/data/xva.json +30 -0
- quantsupport-0.1.9/bindings/python/examples/cva/market_data.py +60 -0
- quantsupport-0.1.9/bindings/python/examples/cva/xva.ipynb +942 -0
- quantsupport-0.1.9/bindings/python/examples/hullwhite/README.md +22 -0
- quantsupport-0.1.9/bindings/python/examples/hullwhite/data/simulation.json +25 -0
- quantsupport-0.1.9/bindings/python/examples/hullwhite/market_data.py +48 -0
- quantsupport-0.1.9/bindings/python/examples/hullwhite/simulations.ipynb +283 -0
- quantsupport-0.1.9/bindings/python/examples/requirements.txt +7 -0
- quantsupport-0.1.9/bindings/python/examples/scripting/README.md +22 -0
- quantsupport-0.1.9/bindings/python/examples/scripting/market_data.py +48 -0
- quantsupport-0.1.9/bindings/python/examples/scripting/scripted_cashflows.ipynb +283 -0
- quantsupport-0.1.9/bindings/python/examples/scripting/stepped_cashflows.py +64 -0
- quantsupport-0.1.9/bindings/python/examples/sensitivity/README.md +20 -0
- quantsupport-0.1.9/bindings/python/examples/sensitivity/market_data.py +48 -0
- quantsupport-0.1.9/bindings/python/examples/sensitivity/portfolio_risk.ipynb +412 -0
- quantsupport-0.1.9/bindings/python/examples/valuation/README.md +40 -0
- quantsupport-0.1.9/bindings/python/examples/valuation/currency_conversion.ipynb +275 -0
- quantsupport-0.1.9/bindings/python/examples/valuation/data/bond_fourier.json +46 -0
- quantsupport-0.1.9/bindings/python/examples/valuation/data/bond_tree.json +42 -0
- quantsupport-0.1.9/bindings/python/examples/valuation/market_data.py +70 -0
- quantsupport-0.1.9/bindings/python/examples/valuation/product_valuations.ipynb +887 -0
- quantsupport-0.1.9/bindings/python/examples/valuation/stepped_coupon_bond.ipynb +724 -0
- quantsupport-0.1.9/bindings/python/examples/valuation/tour.ipynb +307 -0
- quantsupport-0.1.9/bindings/python/examples/volatilitysurface/README.md +21 -0
- quantsupport-0.1.9/bindings/python/examples/volatilitysurface/curves_and_volatility.ipynb +372 -0
- quantsupport-0.1.9/bindings/python/examples/volatilitysurface/market_data.py +48 -0
- quantsupport-0.1.9/bindings/python/src/bondpricinganchor.rs +86 -0
- quantsupport-0.1.9/bindings/python/src/collateral.rs +122 -0
- quantsupport-0.1.9/bindings/python/src/context.rs +873 -0
- quantsupport-0.1.9/bindings/python/src/conv.rs +327 -0
- quantsupport-0.1.9/bindings/python/src/curves.rs +283 -0
- quantsupport-0.1.9/bindings/python/src/enums.rs +777 -0
- quantsupport-0.1.9/bindings/python/src/explore.rs +394 -0
- quantsupport-0.1.9/bindings/python/src/extension.rs +571 -0
- quantsupport-0.1.9/bindings/python/src/lib.rs +186 -0
- quantsupport-0.1.9/bindings/python/src/market.rs +464 -0
- quantsupport-0.1.9/bindings/python/src/results.rs +330 -0
- quantsupport-0.1.9/bindings/python/src/scripting.rs +135 -0
- quantsupport-0.1.9/bindings/python/src/time.rs +350 -0
- quantsupport-0.1.9/bindings/python/src/trades.rs +2529 -0
- quantsupport-0.1.9/bindings/python/src/xva.rs +446 -0
- quantsupport-0.1.9/bindings/python/tests/test_credit_curve_configuration.py +187 -0
- quantsupport-0.1.9/bindings/python/tests/test_csa_variation_margin.py +58 -0
- quantsupport-0.1.9/bindings/python/tests/test_dict_and_scripting.py +626 -0
- quantsupport-0.1.9/bindings/python/tests/test_extensibility.py +151 -0
- quantsupport-0.1.9/bindings/python/tests/test_ois_quantlib.py +64 -0
- quantsupport-0.1.9/bindings/python/tests/test_quote_risk.py +63 -0
- quantsupport-0.1.9/bindings/python/tests/test_trade_instrument.py +218 -0
- quantsupport-0.1.9/bindings/python/tests/test_zero_curves.py +97 -0
- quantsupport-0.1.9/book/src/SUMMARY.md +69 -0
- quantsupport-0.1.9/book/src/concepts/architecture.md +142 -0
- quantsupport-0.1.9/book/src/concepts/instruments.md +209 -0
- quantsupport-0.1.9/book/src/concepts/market-data.md +330 -0
- quantsupport-0.1.9/book/src/concepts/pricing-context.md +209 -0
- quantsupport-0.1.9/book/src/curves/bootstrapping.md +265 -0
- quantsupport-0.1.9/book/src/curves/multi-curve.md +119 -0
- quantsupport-0.1.9/book/src/curves/overview.md +107 -0
- quantsupport-0.1.9/book/src/curves/volatility.md +204 -0
- quantsupport-0.1.9/book/src/getting-started/first-swap.md +214 -0
- quantsupport-0.1.9/book/src/getting-started/installation.md +101 -0
- quantsupport-0.1.9/book/src/getting-started/rust-api.md +377 -0
- quantsupport-0.1.9/book/src/introduction.md +76 -0
- quantsupport-0.1.9/book/src/pricing/bonds.md +369 -0
- quantsupport-0.1.9/book/src/pricing/caps-floors.md +65 -0
- quantsupport-0.1.9/book/src/pricing/cross-currency.md +80 -0
- quantsupport-0.1.9/book/src/pricing/options.md +137 -0
- quantsupport-0.1.9/book/src/pricing/overview.md +100 -0
- quantsupport-0.1.9/book/src/pricing/swaps.md +133 -0
- quantsupport-0.1.9/book/src/pricing/swaptions.md +99 -0
- quantsupport-0.1.9/book/src/reference/configuration.md +276 -0
- quantsupport-0.1.9/book/src/reference/examples.md +96 -0
- quantsupport-0.1.9/book/src/reference/glossary.md +42 -0
- quantsupport-0.1.9/book/src/risk/aad.md +77 -0
- quantsupport-0.1.9/book/src/risk/scenarios.md +61 -0
- quantsupport-0.1.9/book/src/risk/sensitivities.md +86 -0
- quantsupport-0.1.9/book/src/scripting/engine.md +167 -0
- quantsupport-0.1.9/book/src/scripting/events-products.md +159 -0
- quantsupport-0.1.9/book/src/scripting/language.md +176 -0
- quantsupport-0.1.9/book/src/scripting/overview.md +111 -0
- quantsupport-0.1.9/book/src/scripting/xva.md +110 -0
- quantsupport-0.1.9/book/src/simulation/exposure.md +96 -0
- quantsupport-0.1.9/book/src/simulation/hull-white.md +103 -0
- quantsupport-0.1.9/book/src/simulation/lgm.md +112 -0
- quantsupport-0.1.9/book/src/simulation/monte-carlo.md +128 -0
- quantsupport-0.1.9/book/src/xva/cva-dva-fva.md +71 -0
- quantsupport-0.1.9/book/src/xva/netting-csa.md +133 -0
- quantsupport-0.1.9/book/src/xva/overview.md +120 -0
- quantsupport-0.1.9/book/src/xva/sensitivities.md +49 -0
- quantsupport-0.1.9/book.toml +24 -0
- quantsupport-0.1.9/pyproject.toml +26 -0
- quantsupport-0.1.9/python/quantsupport/__init__.py +5 -0
- quantsupport-0.1.9/python/quantsupport/__init__.pyi +1080 -0
- quantsupport-0.1.9/python/quantsupport/py.typed +0 -0
- quantsupport-0.1.9/src/ad/blocklist.rs +262 -0
- quantsupport-0.1.9/src/ad/constant.rs +143 -0
- quantsupport-0.1.9/src/ad/dual.rs +696 -0
- quantsupport-0.1.9/src/ad/expr.rs +957 -0
- quantsupport-0.1.9/src/ad/forward.rs +688 -0
- quantsupport-0.1.9/src/ad/mod.rs +19 -0
- quantsupport-0.1.9/src/ad/node.rs +103 -0
- quantsupport-0.1.9/src/ad/scalar.rs +205 -0
- quantsupport-0.1.9/src/ad/tape.rs +295 -0
- quantsupport-0.1.9/src/calibration/calibrationpricer.rs +19 -0
- quantsupport-0.1.9/src/calibration/calibrationprocess.rs +26 -0
- quantsupport-0.1.9/src/calibration/mod.rs +6 -0
- quantsupport-0.1.9/src/core/collateral.rs +154 -0
- quantsupport-0.1.9/src/core/elements/curveelement.rs +172 -0
- quantsupport-0.1.9/src/core/elements/mod.rs +8 -0
- quantsupport-0.1.9/src/core/elements/montecarlosimulationelement.rs +68 -0
- quantsupport-0.1.9/src/core/elements/volatilitycubelement.rs +49 -0
- quantsupport-0.1.9/src/core/elements/volatilitysurfaceelement.rs +52 -0
- quantsupport-0.1.9/src/core/evaluationresults.rs +353 -0
- quantsupport-0.1.9/src/core/evaluator.rs +137 -0
- quantsupport-0.1.9/src/core/instrument.rs +25 -0
- quantsupport-0.1.9/src/core/marketdatahandling/constructedelementrequest.rs +41 -0
- quantsupport-0.1.9/src/core/marketdatahandling/constructedelementstore.rs +168 -0
- quantsupport-0.1.9/src/core/marketdatahandling/discountrequest.rs +28 -0
- quantsupport-0.1.9/src/core/marketdatahandling/fixingrequest.rs +67 -0
- quantsupport-0.1.9/src/core/marketdatahandling/forwardraterequest.rs +61 -0
- quantsupport-0.1.9/src/core/marketdatahandling/fxrequest.rs +69 -0
- quantsupport-0.1.9/src/core/marketdatahandling/marketdata.rs +238 -0
- quantsupport-0.1.9/src/core/marketdatahandling/mod.rs +18 -0
- quantsupport-0.1.9/src/core/marketdatahandling/pathdependentrequest.rs +31 -0
- quantsupport-0.1.9/src/core/marketdatahandling/spotrequest.rs +28 -0
- quantsupport-0.1.9/src/core/mod.rs +34 -0
- quantsupport-0.1.9/src/core/pillars.rs +15 -0
- quantsupport-0.1.9/src/core/pricer.rs +109 -0
- quantsupport-0.1.9/src/core/pricerconfiguration.rs +547 -0
- quantsupport-0.1.9/src/core/pricerstate.rs +250 -0
- quantsupport-0.1.9/src/core/pricingcontext.rs +879 -0
- quantsupport-0.1.9/src/core/request.rs +682 -0
- quantsupport-0.1.9/src/core/trade.rs +34 -0
- quantsupport-0.1.9/src/core/visitable.rs +23 -0
- quantsupport-0.1.9/src/currencies/currency.rs +308 -0
- quantsupport-0.1.9/src/currencies/currencydetails.rs +17 -0
- quantsupport-0.1.9/src/currencies/mod.rs +10 -0
- quantsupport-0.1.9/src/indices/fxpair.rs +164 -0
- quantsupport-0.1.9/src/indices/marketindex.rs +305 -0
- quantsupport-0.1.9/src/indices/mod.rs +16 -0
- quantsupport-0.1.9/src/indices/quotetype.rs +17 -0
- quantsupport-0.1.9/src/indices/rateindex.rs +25 -0
- quantsupport-0.1.9/src/indices/rateindices/aonia.rs +56 -0
- quantsupport-0.1.9/src/indices/rateindices/corra.rs +56 -0
- quantsupport-0.1.9/src/indices/rateindices/estr.rs +55 -0
- quantsupport-0.1.9/src/indices/rateindices/euribor.rs +87 -0
- quantsupport-0.1.9/src/indices/rateindices/icp.rs +55 -0
- quantsupport-0.1.9/src/indices/rateindices/mod.rs +26 -0
- quantsupport-0.1.9/src/indices/rateindices/nowa.rs +56 -0
- quantsupport-0.1.9/src/indices/rateindices/nzonia.rs +56 -0
- quantsupport-0.1.9/src/indices/rateindices/saron.rs +56 -0
- quantsupport-0.1.9/src/indices/rateindices/sofr.rs +109 -0
- quantsupport-0.1.9/src/indices/rateindices/sonia.rs +66 -0
- quantsupport-0.1.9/src/indices/rateindices/swestr.rs +56 -0
- quantsupport-0.1.9/src/indices/rateindices/tibor.rs +76 -0
- quantsupport-0.1.9/src/indices/rateindices/tonar.rs +63 -0
- quantsupport-0.1.9/src/instruments/cashflows/cashflow.rs +68 -0
- quantsupport-0.1.9/src/instruments/cashflows/cashflowtype.rs +352 -0
- quantsupport-0.1.9/src/instruments/cashflows/coupons.rs +54 -0
- quantsupport-0.1.9/src/instruments/cashflows/fixedratecoupon.rs +153 -0
- quantsupport-0.1.9/src/instruments/cashflows/floatingratecoupon.rs +633 -0
- quantsupport-0.1.9/src/instruments/cashflows/leg.rs +207 -0
- quantsupport-0.1.9/src/instruments/cashflows/makeleg.rs +1486 -0
- quantsupport-0.1.9/src/instruments/cashflows/mod.rs +21 -0
- quantsupport-0.1.9/src/instruments/cashflows/optionembeddedcashflow.rs +66 -0
- quantsupport-0.1.9/src/instruments/cashflows/optionembeddedcoupon.rs +214 -0
- quantsupport-0.1.9/src/instruments/cashflows/payoffops.rs +49 -0
- quantsupport-0.1.9/src/instruments/credit/creditdefaultswap.rs +211 -0
- quantsupport-0.1.9/src/instruments/credit/mod.rs +3 -0
- quantsupport-0.1.9/src/instruments/equity/equityeuropeanoption.rs +178 -0
- quantsupport-0.1.9/src/instruments/equity/equityforward.rs +133 -0
- quantsupport-0.1.9/src/instruments/equity/futures.rs +143 -0
- quantsupport-0.1.9/src/instruments/equity/makeequityeuropeanoption.rs +135 -0
- quantsupport-0.1.9/src/instruments/equity/makeequityforward.rs +120 -0
- quantsupport-0.1.9/src/instruments/equity/makefutures.rs +129 -0
- quantsupport-0.1.9/src/instruments/equity/mod.rs +12 -0
- quantsupport-0.1.9/src/instruments/fixedincome/bondpricinganchor.rs +52 -0
- quantsupport-0.1.9/src/instruments/fixedincome/callability.rs +75 -0
- quantsupport-0.1.9/src/instruments/fixedincome/callschedule.rs +114 -0
- quantsupport-0.1.9/src/instruments/fixedincome/fixedratebond.rs +272 -0
- quantsupport-0.1.9/src/instruments/fixedincome/fixedratedeposit.rs +230 -0
- quantsupport-0.1.9/src/instruments/fixedincome/floatingratenote.rs +205 -0
- quantsupport-0.1.9/src/instruments/fixedincome/makefixedratebond.rs +249 -0
- quantsupport-0.1.9/src/instruments/fixedincome/makefixedratedeposit.rs +191 -0
- quantsupport-0.1.9/src/instruments/fixedincome/makefloatingratenote.rs +239 -0
- quantsupport-0.1.9/src/instruments/fixedincome/makesteppedcouponbond.rs +529 -0
- quantsupport-0.1.9/src/instruments/fixedincome/mod.rs +20 -0
- quantsupport-0.1.9/src/instruments/fixedincome/steppedcouponbond.rs +368 -0
- quantsupport-0.1.9/src/instruments/fx/fxeuropeanoption.rs +228 -0
- quantsupport-0.1.9/src/instruments/fx/fxforward.rs +285 -0
- quantsupport-0.1.9/src/instruments/fx/makefxeuropeanoption.rs +223 -0
- quantsupport-0.1.9/src/instruments/fx/makefxforward.rs +265 -0
- quantsupport-0.1.9/src/instruments/fx/mod.rs +8 -0
- quantsupport-0.1.9/src/instruments/mod.rs +17 -0
- quantsupport-0.1.9/src/instruments/rates/basisswap.rs +212 -0
- quantsupport-0.1.9/src/instruments/rates/capfloor.rs +175 -0
- quantsupport-0.1.9/src/instruments/rates/capletfloorlet.rs +188 -0
- quantsupport-0.1.9/src/instruments/rates/europeanswaption.rs +240 -0
- quantsupport-0.1.9/src/instruments/rates/fixfloatcrosscurrencyswap.rs +242 -0
- quantsupport-0.1.9/src/instruments/rates/floatfloatcrosscurrencyswap.rs +236 -0
- quantsupport-0.1.9/src/instruments/rates/makebasisswap.rs +308 -0
- quantsupport-0.1.9/src/instruments/rates/makecapfloor.rs +316 -0
- quantsupport-0.1.9/src/instruments/rates/makeeuropeanswaption.rs +324 -0
- quantsupport-0.1.9/src/instruments/rates/makefixfloatcrosscurrencyswap.rs +372 -0
- quantsupport-0.1.9/src/instruments/rates/makefloatfloatcrosscurrencyswap.rs +347 -0
- quantsupport-0.1.9/src/instruments/rates/makeovernightindexswap.rs +331 -0
- quantsupport-0.1.9/src/instruments/rates/makeratefutures.rs +181 -0
- quantsupport-0.1.9/src/instruments/rates/makeswap.rs +336 -0
- quantsupport-0.1.9/src/instruments/rates/mod.rs +36 -0
- quantsupport-0.1.9/src/instruments/rates/oisconventions.rs +671 -0
- quantsupport-0.1.9/src/instruments/rates/overnightindexswap.rs +353 -0
- quantsupport-0.1.9/src/instruments/rates/ratefutures.rs +164 -0
- quantsupport-0.1.9/src/instruments/rates/swap.rs +213 -0
- quantsupport-0.1.9/src/lib.rs +206 -0
- quantsupport-0.1.9/src/math/fft.rs +255 -0
- quantsupport-0.1.9/src/math/ifft.rs +105 -0
- quantsupport-0.1.9/src/math/interpolation/bilinear.rs +216 -0
- quantsupport-0.1.9/src/math/interpolation/cubicspline.rs +337 -0
- quantsupport-0.1.9/src/math/interpolation/extrapolation.rs +15 -0
- quantsupport-0.1.9/src/math/interpolation/interpolator.rs +91 -0
- quantsupport-0.1.9/src/math/interpolation/linear.rs +126 -0
- quantsupport-0.1.9/src/math/interpolation/loglinear.rs +104 -0
- quantsupport-0.1.9/src/math/interpolation/mod.rs +20 -0
- quantsupport-0.1.9/src/math/interpolation/multilinear.rs +95 -0
- quantsupport-0.1.9/src/math/interpolation/trilinear.rs +342 -0
- quantsupport-0.1.9/src/math/linalg.rs +25 -0
- quantsupport-0.1.9/src/math/mod.rs +14 -0
- quantsupport-0.1.9/src/math/probability/mod.rs +4 -0
- quantsupport-0.1.9/src/math/probability/norm_cdf.rs +173 -0
- quantsupport-0.1.9/src/math/probability/norm_pdf.rs +9 -0
- quantsupport-0.1.9/src/math/random/mod.rs +17 -0
- quantsupport-0.1.9/src/math/solvers/bisection.rs +95 -0
- quantsupport-0.1.9/src/math/solvers/mod.rs +8 -0
- quantsupport-0.1.9/src/math/solvers/newtonraphson.rs +223 -0
- quantsupport-0.1.9/src/math/solvers/solvertraits.rs +187 -0
- quantsupport-0.1.9/src/math/solvers/vectornewton.rs +192 -0
- quantsupport-0.1.9/src/models/bondmodelconfiguration.rs +233 -0
- quantsupport-0.1.9/src/models/brownianmotion/brownianmotionmodel.rs +419 -0
- quantsupport-0.1.9/src/models/brownianmotion/mod.rs +5 -0
- quantsupport-0.1.9/src/models/hullwhite/hullwhitecalibration.rs +1061 -0
- quantsupport-0.1.9/src/models/hullwhite/hullwhitecalibrationquality.rs +34 -0
- quantsupport-0.1.9/src/models/hullwhite/hullwhitemodel.rs +678 -0
- quantsupport-0.1.9/src/models/hullwhite/mod.rs +10 -0
- quantsupport-0.1.9/src/models/hullwhite/parameters.rs +326 -0
- quantsupport-0.1.9/src/models/lgm/lgmcomponents.rs +1002 -0
- quantsupport-0.1.9/src/models/lgm/lgmmarketmodel.rs +1115 -0
- quantsupport-0.1.9/src/models/lgm/mod.rs +4 -0
- quantsupport-0.1.9/src/models/mod.rs +8 -0
- quantsupport-0.1.9/src/models/modelconfiguration.rs +281 -0
- quantsupport-0.1.9/src/models/montecarloengine.rs +26 -0
- quantsupport-0.1.9/src/models/utils.rs +324 -0
- quantsupport-0.1.9/src/prelude.rs +275 -0
- quantsupport-0.1.9/src/pricers/cashflows/discountedcashflowpricer.rs +1603 -0
- quantsupport-0.1.9/src/pricers/cashflows/mod.rs +2 -0
- quantsupport-0.1.9/src/pricers/credit/cdspricer.rs +548 -0
- quantsupport-0.1.9/src/pricers/credit/mod.rs +3 -0
- quantsupport-0.1.9/src/pricers/equity/blackeuropeanoptionpricer.rs +954 -0
- quantsupport-0.1.9/src/pricers/equity/blackmceuropeanoptionpricer.rs +420 -0
- quantsupport-0.1.9/src/pricers/equity/equityforwardpricer.rs +478 -0
- quantsupport-0.1.9/src/pricers/equity/mod.rs +7 -0
- quantsupport-0.1.9/src/pricers/fixedincome/backwardfourierevolutionbondpricer.rs +428 -0
- quantsupport-0.1.9/src/pricers/fixedincome/bondanalytics.rs +1036 -0
- quantsupport-0.1.9/src/pricers/fixedincome/bondevents.rs +225 -0
- quantsupport-0.1.9/src/pricers/fixedincome/bondpricer.rs +395 -0
- quantsupport-0.1.9/src/pricers/fixedincome/callablebond.rs +119 -0
- quantsupport-0.1.9/src/pricers/fixedincome/mod.rs +20 -0
- quantsupport-0.1.9/src/pricers/fixedincome/treebasedbondpricer.rs +1422 -0
- quantsupport-0.1.9/src/pricers/fx/fxeuropeanoptionpricer.rs +916 -0
- quantsupport-0.1.9/src/pricers/fx/fxforwardpricer.rs +660 -0
- quantsupport-0.1.9/src/pricers/fx/mod.rs +4 -0
- quantsupport-0.1.9/src/pricers/mod.rs +17 -0
- quantsupport-0.1.9/src/pricers/rates/closedformblackcapletpricer.rs +1069 -0
- quantsupport-0.1.9/src/pricers/rates/closedformblackcappricer.rs +942 -0
- quantsupport-0.1.9/src/pricers/rates/closedformhullwhitecapletpricer.rs +699 -0
- quantsupport-0.1.9/src/pricers/rates/closedformhullwhitecappricer.rs +616 -0
- quantsupport-0.1.9/src/pricers/rates/closedformhullwhiteswaptionpricer.rs +1138 -0
- quantsupport-0.1.9/src/pricers/rates/mod.rs +12 -0
- quantsupport-0.1.9/src/pricers/rates/ratefuturespricer.rs +376 -0
- quantsupport-0.1.9/src/quotes/calibrationinstrument.rs +78 -0
- quantsupport-0.1.9/src/quotes/fixingstore.rs +90 -0
- quantsupport-0.1.9/src/quotes/fxstore.rs +201 -0
- quantsupport-0.1.9/src/quotes/mod.rs +25 -0
- quantsupport-0.1.9/src/quotes/quote.rs +3085 -0
- quantsupport-0.1.9/src/quotes/quoteselector.rs +9 -0
- quantsupport-0.1.9/src/quotes/quotestore.rs +107 -0
- quantsupport-0.1.9/src/quotes/scenario.rs +266 -0
- quantsupport-0.1.9/src/rates/bootstrapping/bootstrapcalibrationinstrument.rs +404 -0
- quantsupport-0.1.9/src/rates/bootstrapping/bootstrapdiscountpolicy.rs +94 -0
- quantsupport-0.1.9/src/rates/bootstrapping/bootstrappedcurve.rs +199 -0
- quantsupport-0.1.9/src/rates/bootstrapping/bootstrapstep.rs +116 -0
- quantsupport-0.1.9/src/rates/bootstrapping/bootstraputils.rs +219 -0
- quantsupport-0.1.9/src/rates/bootstrapping/creditcurvebootstrapper.rs +839 -0
- quantsupport-0.1.9/src/rates/bootstrapping/creditcurveconfiguration.rs +161 -0
- quantsupport-0.1.9/src/rates/bootstrapping/curveconfiguration.rs +569 -0
- quantsupport-0.1.9/src/rates/bootstrapping/mod.rs +16 -0
- quantsupport-0.1.9/src/rates/bootstrapping/multicurvebootstrapper.rs +1241 -0
- quantsupport-0.1.9/src/rates/compounding.rs +48 -0
- quantsupport-0.1.9/src/rates/interestrate.rs +844 -0
- quantsupport-0.1.9/src/rates/mod.rs +15 -0
- quantsupport-0.1.9/src/rates/yieldtermstructure/compositetermstructure.rs +200 -0
- quantsupport-0.1.9/src/rates/yieldtermstructure/discounttermstructure.rs +709 -0
- quantsupport-0.1.9/src/rates/yieldtermstructure/flatforwardtermstructure.rs +328 -0
- quantsupport-0.1.9/src/rates/yieldtermstructure/interestratestermstructure.rs +54 -0
- quantsupport-0.1.9/src/rates/yieldtermstructure/mod.rs +16 -0
- quantsupport-0.1.9/src/rates/yieldtermstructure/primalcurve.rs +55 -0
- quantsupport-0.1.9/src/rates/yieldtermstructure/spreadtermstructure.rs +371 -0
- quantsupport-0.1.9/src/rates/yieldtermstructure/tenorbasedzeroratetermstructure.rs +298 -0
- quantsupport-0.1.9/src/rates/yieldtermstructure/zeroratetermstructure.rs +744 -0
- quantsupport-0.1.9/src/scripting/data/mod.rs +19 -0
- quantsupport-0.1.9/src/scripting/data/simulationdata.rs +127 -0
- quantsupport-0.1.9/src/scripting/mod.rs +44 -0
- quantsupport-0.1.9/src/scripting/nodes/event.rs +167 -0
- quantsupport-0.1.9/src/scripting/nodes/mod.rs +23 -0
- quantsupport-0.1.9/src/scripting/nodes/node.rs +933 -0
- quantsupport-0.1.9/src/scripting/nodes/traits.rs +50 -0
- quantsupport-0.1.9/src/scripting/parsing/lexer.rs +866 -0
- quantsupport-0.1.9/src/scripting/parsing/mod.rs +21 -0
- quantsupport-0.1.9/src/scripting/parsing/parser.rs +2734 -0
- quantsupport-0.1.9/src/scripting/product.rs +393 -0
- quantsupport-0.1.9/src/scripting/request.rs +117 -0
- quantsupport-0.1.9/src/scripting/runtime.rs +1642 -0
- quantsupport-0.1.9/src/scripting/visitors/domainprocessor.rs +467 -0
- quantsupport-0.1.9/src/scripting/visitors/evaluator.rs +2406 -0
- quantsupport-0.1.9/src/scripting/visitors/fuzzyevaluator.rs +1048 -0
- quantsupport-0.1.9/src/scripting/visitors/ifconditiontransform.rs +186 -0
- quantsupport-0.1.9/src/scripting/visitors/ifprocessor.rs +241 -0
- quantsupport-0.1.9/src/scripting/visitors/mod.rs +29 -0
- quantsupport-0.1.9/src/scripting/visitors/varindexer.rs +775 -0
- quantsupport-0.1.9/src/simulations/generatedsimulation.rs +84 -0
- quantsupport-0.1.9/src/simulations/mod.rs +9 -0
- quantsupport-0.1.9/src/simulations/simulation.rs +24 -0
- quantsupport-0.1.9/src/simulations/simulationbuilder.rs +509 -0
- quantsupport-0.1.9/src/time/calendar.rs +363 -0
- quantsupport-0.1.9/src/time/calendars/brazil.rs +262 -0
- quantsupport-0.1.9/src/time/calendars/chile.rs +265 -0
- quantsupport-0.1.9/src/time/calendars/japan.rs +410 -0
- quantsupport-0.1.9/src/time/calendars/jointcalendar.rs +133 -0
- quantsupport-0.1.9/src/time/calendars/mod.rs +21 -0
- quantsupport-0.1.9/src/time/calendars/nullcalendar.rs +89 -0
- quantsupport-0.1.9/src/time/calendars/target.rs +151 -0
- quantsupport-0.1.9/src/time/calendars/traits.rs +293 -0
- quantsupport-0.1.9/src/time/calendars/unitedkingdom.rs +302 -0
- quantsupport-0.1.9/src/time/calendars/unitedstates.rs +251 -0
- quantsupport-0.1.9/src/time/calendars/weekendsonly.rs +86 -0
- quantsupport-0.1.9/src/time/date.rs +642 -0
- quantsupport-0.1.9/src/time/daycounter.rs +233 -0
- quantsupport-0.1.9/src/time/daycounters/actual360.rs +32 -0
- quantsupport-0.1.9/src/time/daycounters/actual365.rs +31 -0
- quantsupport-0.1.9/src/time/daycounters/actualactual.rs +115 -0
- quantsupport-0.1.9/src/time/daycounters/business252.rs +61 -0
- quantsupport-0.1.9/src/time/daycounters/daycount.rs +19 -0
- quantsupport-0.1.9/src/time/daycounters/mod.rs +12 -0
- quantsupport-0.1.9/src/time/daycounters/thirty360.rs +110 -0
- quantsupport-0.1.9/src/time/enums.rs +490 -0
- quantsupport-0.1.9/src/time/imm.rs +326 -0
- quantsupport-0.1.9/src/time/mod.rs +23 -0
- quantsupport-0.1.9/src/time/period.rs +871 -0
- quantsupport-0.1.9/src/time/schedule.rs +1078 -0
- quantsupport-0.1.9/src/utils/errors.rs +164 -0
- quantsupport-0.1.9/src/utils/mod.rs +10 -0
- quantsupport-0.1.9/src/utils/plot.rs +30 -0
- quantsupport-0.1.9/src/utils/tools.rs +7 -0
- quantsupport-0.1.9/src/volatility/interpolatedvolatilitycube.rs +368 -0
- quantsupport-0.1.9/src/volatility/interpolatedvolatilitysurface.rs +392 -0
- quantsupport-0.1.9/src/volatility/mod.rs +27 -0
- quantsupport-0.1.9/src/volatility/modelcalibration.rs +336 -0
- quantsupport-0.1.9/src/volatility/orientedfxvolsurface.rs +81 -0
- quantsupport-0.1.9/src/volatility/volatilitycube.rs +64 -0
- quantsupport-0.1.9/src/volatility/volatilitycubebuilder.rs +265 -0
- quantsupport-0.1.9/src/volatility/volatilitycubeconfiguration.rs +114 -0
- quantsupport-0.1.9/src/volatility/volatilityindexing.rs +131 -0
- quantsupport-0.1.9/src/volatility/volatilitysource.rs +781 -0
- quantsupport-0.1.9/src/volatility/volatilitysurface.rs +64 -0
- quantsupport-0.1.9/src/volatility/volatilitysurfacebuilder.rs +263 -0
- quantsupport-0.1.9/src/volatility/volatilitysurfaceconfiguration.rs +113 -0
- quantsupport-0.1.9/src/xva/aggregator.rs +969 -0
- quantsupport-0.1.9/src/xva/claimevaluationstrategy.rs +118 -0
- quantsupport-0.1.9/src/xva/contigentclaim.rs +544 -0
- quantsupport-0.1.9/src/xva/csa.rs +290 -0
- quantsupport-0.1.9/src/xva/engine.rs +1102 -0
- quantsupport-0.1.9/src/xva/makecontigentclaim.rs +311 -0
- quantsupport-0.1.9/src/xva/mod.rs +25 -0
- quantsupport-0.1.9/src/xva/nettingset.rs +295 -0
- quantsupport-0.1.9/src/xva/visitors/claimcompressionpreprocessor.rs +101 -0
- quantsupport-0.1.9/src/xva/visitors/claimpreprocessor.rs +9 -0
- quantsupport-0.1.9/src/xva/visitors/exposureevaluator.rs +1238 -0
- quantsupport-0.1.9/src/xva/visitors/fixingpreprocessor.rs +118 -0
- quantsupport-0.1.9/src/xva/visitors/marketmodel.rs +195 -0
- quantsupport-0.1.9/src/xva/visitors/mod.rs +15 -0
- quantsupport-0.1.9/src/xva/visitors/preprocessorexecutor.rs +159 -0
|
Binary file
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
"""Prepare repeatable releases and check crates.io publication status."""
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import base64
|
|
5
|
+
import json
|
|
6
|
+
import os
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
import re
|
|
9
|
+
import subprocess
|
|
10
|
+
import tomllib
|
|
11
|
+
from urllib.error import HTTPError
|
|
12
|
+
from urllib.request import Request, urlopen
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def git(*args):
|
|
16
|
+
return subprocess.check_output(["git", *args], text=True).rstrip("\n")
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def github_api(endpoint, payload=None):
|
|
20
|
+
command = ["gh", "api", endpoint]
|
|
21
|
+
if payload is not None:
|
|
22
|
+
command.extend(["--input", "-"])
|
|
23
|
+
result = subprocess.run(
|
|
24
|
+
command,
|
|
25
|
+
input=json.dumps(payload) if payload is not None else None,
|
|
26
|
+
text=True,
|
|
27
|
+
capture_output=True,
|
|
28
|
+
check=True,
|
|
29
|
+
)
|
|
30
|
+
return json.loads(result.stdout)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def bump_manifest(manifest, tags):
|
|
34
|
+
"""Increment the highest stable version without changing other TOML fields."""
|
|
35
|
+
current = tomllib.loads(manifest)["workspace"]["package"]["version"]
|
|
36
|
+
if not re.fullmatch(r"\d+\.\d+\.\d+", current):
|
|
37
|
+
raise ValueError(f"Expected a stable workspace version, got {current!r}")
|
|
38
|
+
versions = [tuple(map(int, current.split(".")))]
|
|
39
|
+
for tag in tags:
|
|
40
|
+
if re.fullmatch(r"v\d+\.\d+\.\d+", tag):
|
|
41
|
+
versions.append(tuple(map(int, tag[1:].split("."))))
|
|
42
|
+
major, minor, patch = max(versions)
|
|
43
|
+
version = f"{major}.{minor}.{patch + 1}"
|
|
44
|
+
section = re.search(r"(?ms)^\[workspace\.package\]\s*\n.*?(?=^\[|\Z)", manifest)
|
|
45
|
+
if section is None:
|
|
46
|
+
raise ValueError("Missing [workspace.package] section")
|
|
47
|
+
updated, count = re.subn(
|
|
48
|
+
r"(?m)^(version\s*=\s*)[\'\"][^\'\"]+[\'\"]",
|
|
49
|
+
lambda match: f'{match[1]}"{version}"',
|
|
50
|
+
section[0],
|
|
51
|
+
)
|
|
52
|
+
if count != 1:
|
|
53
|
+
raise ValueError("Expected one workspace version assignment")
|
|
54
|
+
manifest = manifest[: section.start()] + updated + manifest[section.end() :]
|
|
55
|
+
return manifest, version
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def ensure_tag(repository, version, commit):
|
|
59
|
+
tag = f"v{version}"
|
|
60
|
+
if tag in git("tag", "--list").splitlines():
|
|
61
|
+
if git("rev-parse", f"{tag}^{{commit}}") != commit:
|
|
62
|
+
raise RuntimeError(f"{tag} already points to another commit")
|
|
63
|
+
return
|
|
64
|
+
github_api(
|
|
65
|
+
f"repos/{repository}/git/refs", {"ref": f"refs/tags/{tag}", "sha": commit}
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def prepare(repository, run_id):
|
|
70
|
+
"""Reserve one version per workflow run, including when a run is retried."""
|
|
71
|
+
if not re.fullmatch(r"\d+", run_id):
|
|
72
|
+
raise ValueError("Expected a numeric GitHub run ID")
|
|
73
|
+
for _ in range(5):
|
|
74
|
+
git("fetch", "--quiet", "origin", "main", "--tags")
|
|
75
|
+
previous = git(
|
|
76
|
+
"log",
|
|
77
|
+
"origin/main",
|
|
78
|
+
"--format=%H",
|
|
79
|
+
"-1",
|
|
80
|
+
f"--grep=^Release-Run-ID: {run_id}$",
|
|
81
|
+
)
|
|
82
|
+
if previous:
|
|
83
|
+
manifest = git("show", f"{previous}:Cargo.toml")
|
|
84
|
+
version = tomllib.loads(manifest)["workspace"]["package"]["version"]
|
|
85
|
+
ensure_tag(repository, version, previous)
|
|
86
|
+
return version, previous
|
|
87
|
+
|
|
88
|
+
head = git("rev-parse", "origin/main")
|
|
89
|
+
manifest = git("show", "origin/main:Cargo.toml") + "\n"
|
|
90
|
+
updated, version = bump_manifest(manifest, git("tag", "--list").splitlines())
|
|
91
|
+
# GitHub signs commits made through this mutation. expectedHeadOid prevents
|
|
92
|
+
# overwriting a push that reaches main while the version is being prepared.
|
|
93
|
+
payload = {
|
|
94
|
+
"query": """
|
|
95
|
+
mutation($input: CreateCommitOnBranchInput!) {
|
|
96
|
+
createCommitOnBranch(input: $input) { commit { oid } }
|
|
97
|
+
}
|
|
98
|
+
""",
|
|
99
|
+
"variables": {
|
|
100
|
+
"input": {
|
|
101
|
+
"branch": {
|
|
102
|
+
"repositoryNameWithOwner": repository,
|
|
103
|
+
"branchName": "main",
|
|
104
|
+
},
|
|
105
|
+
"expectedHeadOid": head,
|
|
106
|
+
"message": {
|
|
107
|
+
"headline": f"chore(release): v{version} [skip release]",
|
|
108
|
+
"body": f"Release-Run-ID: {run_id}",
|
|
109
|
+
},
|
|
110
|
+
"fileChanges": {
|
|
111
|
+
"additions": [
|
|
112
|
+
{
|
|
113
|
+
"path": "Cargo.toml",
|
|
114
|
+
"contents": base64.b64encode(updated.encode()).decode(),
|
|
115
|
+
}
|
|
116
|
+
]
|
|
117
|
+
},
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
}
|
|
121
|
+
try:
|
|
122
|
+
response = github_api("graphql", payload)
|
|
123
|
+
except subprocess.CalledProcessError as error:
|
|
124
|
+
git("fetch", "--quiet", "origin", "main")
|
|
125
|
+
if git("rev-parse", "origin/main") != head:
|
|
126
|
+
continue
|
|
127
|
+
raise RuntimeError(
|
|
128
|
+
"Cannot create the signed version commit. On protected main, configure "
|
|
129
|
+
"RELEASE_TOKEN with Contents: write and permission to bypass the PR rule.\n"
|
|
130
|
+
+ (error.stderr or str(error))
|
|
131
|
+
) from error
|
|
132
|
+
commit = response["data"]["createCommitOnBranch"]["commit"]["oid"]
|
|
133
|
+
ensure_tag(repository, version, commit)
|
|
134
|
+
return version, commit
|
|
135
|
+
raise RuntimeError(
|
|
136
|
+
"main changed during all five attempts; rerun the Release workflow"
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def is_published(version):
|
|
141
|
+
if not re.fullmatch(r"\d+\.\d+\.\d+", version):
|
|
142
|
+
raise ValueError("Expected a stable release version")
|
|
143
|
+
request = Request(
|
|
144
|
+
f"https://crates.io/api/v1/crates/quantsupport/{version}",
|
|
145
|
+
headers={
|
|
146
|
+
"User-Agent": "quantsupport-release (https://github.com/jmelo11/quantsupport)"
|
|
147
|
+
},
|
|
148
|
+
)
|
|
149
|
+
try:
|
|
150
|
+
with urlopen(request, timeout=30) as response:
|
|
151
|
+
json.load(response)
|
|
152
|
+
return True
|
|
153
|
+
except HTTPError as error:
|
|
154
|
+
if error.code == 404:
|
|
155
|
+
return False
|
|
156
|
+
raise
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def outputs(**values):
|
|
160
|
+
with Path(os.environ["GITHUB_OUTPUT"]).open("a") as output:
|
|
161
|
+
for key, value in values.items():
|
|
162
|
+
output.write(f"{key}={value}\n")
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def run_tests():
|
|
166
|
+
"""Keep tests alongside the release implementation."""
|
|
167
|
+
import io
|
|
168
|
+
import tempfile
|
|
169
|
+
import unittest
|
|
170
|
+
from unittest.mock import patch
|
|
171
|
+
|
|
172
|
+
manifest = '[workspace.package]\nversion = "0.1.8"\n\n[dependencies]\nx = "0.1.8"\n'
|
|
173
|
+
|
|
174
|
+
class ReleaseTests(unittest.TestCase):
|
|
175
|
+
def test_retry_finds_its_commit_after_another_main_push(self):
|
|
176
|
+
with tempfile.TemporaryDirectory() as directory:
|
|
177
|
+
remote = Path(directory) / "remote.git"
|
|
178
|
+
checkout = Path(directory) / "checkout"
|
|
179
|
+
subprocess.run(
|
|
180
|
+
[
|
|
181
|
+
"git",
|
|
182
|
+
"init",
|
|
183
|
+
"--quiet",
|
|
184
|
+
"--bare",
|
|
185
|
+
"--initial-branch=main",
|
|
186
|
+
str(remote),
|
|
187
|
+
],
|
|
188
|
+
check=True,
|
|
189
|
+
)
|
|
190
|
+
subprocess.run(
|
|
191
|
+
["git", "clone", "--quiet", str(remote), str(checkout)],
|
|
192
|
+
check=True,
|
|
193
|
+
stderr=subprocess.DEVNULL,
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
def local_git(*args):
|
|
197
|
+
return subprocess.check_output(
|
|
198
|
+
["git", *args],
|
|
199
|
+
cwd=checkout,
|
|
200
|
+
text=True,
|
|
201
|
+
).rstrip("\n")
|
|
202
|
+
|
|
203
|
+
local_git("config", "user.name", "Release test")
|
|
204
|
+
local_git("config", "user.email", "release-test@example.invalid")
|
|
205
|
+
(checkout / "Cargo.toml").write_text(manifest)
|
|
206
|
+
local_git("add", "Cargo.toml")
|
|
207
|
+
local_git("commit", "--quiet", "-m", "Initial version")
|
|
208
|
+
updated, version = bump_manifest(manifest, [])
|
|
209
|
+
(checkout / "Cargo.toml").write_text(updated)
|
|
210
|
+
local_git(
|
|
211
|
+
"commit", "--quiet", "-am", "Version", "-m", "Release-Run-ID: 42"
|
|
212
|
+
)
|
|
213
|
+
reserved = local_git("rev-parse", "HEAD")
|
|
214
|
+
local_git("tag", f"v{version}")
|
|
215
|
+
(checkout / "README.md").write_text("A later push\n")
|
|
216
|
+
local_git("add", "README.md")
|
|
217
|
+
local_git("commit", "--quiet", "-m", "Later push")
|
|
218
|
+
local_git("push", "--quiet", "origin", "main", "--tags")
|
|
219
|
+
with patch("__main__.git", side_effect=local_git), patch(
|
|
220
|
+
"__main__.github_api"
|
|
221
|
+
) as api:
|
|
222
|
+
self.assertEqual(prepare("owner/repo", "42"), (version, reserved))
|
|
223
|
+
api.assert_not_called()
|
|
224
|
+
|
|
225
|
+
def test_shared_version_and_newer_reserved_tag(self):
|
|
226
|
+
updated, version = bump_manifest(
|
|
227
|
+
manifest, ["v0.1.7-alpha", "v0.1.9", "unrelated"]
|
|
228
|
+
)
|
|
229
|
+
self.assertEqual(version, "0.1.10")
|
|
230
|
+
data = tomllib.loads(updated)
|
|
231
|
+
self.assertEqual(data["workspace"]["package"]["version"], "0.1.10")
|
|
232
|
+
self.assertEqual(data["dependencies"]["x"], "0.1.8")
|
|
233
|
+
|
|
234
|
+
def test_retry_reuses_version_after_commit_but_before_tag(self):
|
|
235
|
+
def fake_git(*args):
|
|
236
|
+
if args[0] == "log":
|
|
237
|
+
return "reserved-commit"
|
|
238
|
+
if args[0] == "show":
|
|
239
|
+
return manifest
|
|
240
|
+
return ""
|
|
241
|
+
|
|
242
|
+
with patch("__main__.git", side_effect=fake_git), patch(
|
|
243
|
+
"__main__.github_api"
|
|
244
|
+
) as api:
|
|
245
|
+
self.assertEqual(
|
|
246
|
+
prepare("owner/repo", "42"), ("0.1.8", "reserved-commit")
|
|
247
|
+
)
|
|
248
|
+
api.assert_called_once_with(
|
|
249
|
+
"repos/owner/repo/git/refs",
|
|
250
|
+
{
|
|
251
|
+
"ref": "refs/tags/v0.1.8",
|
|
252
|
+
"sha": "reserved-commit",
|
|
253
|
+
},
|
|
254
|
+
)
|
|
255
|
+
|
|
256
|
+
def test_existing_tag_must_match_release_commit(self):
|
|
257
|
+
with patch("__main__.git", side_effect=["v0.1.8", "different-commit"]):
|
|
258
|
+
with self.assertRaisesRegex(RuntimeError, "another commit"):
|
|
259
|
+
ensure_tag("owner/repo", "0.1.8", "reserved-commit")
|
|
260
|
+
|
|
261
|
+
def test_concurrent_push_retries_without_overwriting_it(self):
|
|
262
|
+
state = {"head": "first-commit", "attempts": 0}
|
|
263
|
+
|
|
264
|
+
def fake_git(*args):
|
|
265
|
+
if args[0] == "rev-parse":
|
|
266
|
+
return state["head"]
|
|
267
|
+
if args[0] == "show":
|
|
268
|
+
return manifest.strip()
|
|
269
|
+
return ""
|
|
270
|
+
|
|
271
|
+
def fake_api(endpoint, payload):
|
|
272
|
+
if endpoint != "graphql":
|
|
273
|
+
return {}
|
|
274
|
+
state["attempts"] += 1
|
|
275
|
+
expected = payload["variables"]["input"]["expectedHeadOid"]
|
|
276
|
+
if state["attempts"] == 1:
|
|
277
|
+
self.assertEqual(expected, "first-commit")
|
|
278
|
+
state["head"] = "concurrent-push"
|
|
279
|
+
raise subprocess.CalledProcessError(1, "gh", stderr="head changed")
|
|
280
|
+
self.assertEqual(expected, "concurrent-push")
|
|
281
|
+
return {
|
|
282
|
+
"data": {
|
|
283
|
+
"createCommitOnBranch": {"commit": {"oid": "release-commit"}}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
with patch("__main__.git", side_effect=fake_git), patch(
|
|
288
|
+
"__main__.github_api", side_effect=fake_api
|
|
289
|
+
):
|
|
290
|
+
self.assertEqual(
|
|
291
|
+
prepare("owner/repo", "42"), ("0.1.9", "release-commit")
|
|
292
|
+
)
|
|
293
|
+
self.assertEqual(state["attempts"], 2)
|
|
294
|
+
|
|
295
|
+
def test_permission_error_does_not_keep_retrying(self):
|
|
296
|
+
def fake_git(*args):
|
|
297
|
+
if args[0] == "rev-parse":
|
|
298
|
+
return "same-head"
|
|
299
|
+
if args[0] == "show":
|
|
300
|
+
return manifest.strip()
|
|
301
|
+
return ""
|
|
302
|
+
|
|
303
|
+
error = subprocess.CalledProcessError(1, "gh", stderr="protected branch")
|
|
304
|
+
with patch("__main__.git", side_effect=fake_git), patch(
|
|
305
|
+
"__main__.github_api", side_effect=error
|
|
306
|
+
) as api:
|
|
307
|
+
with self.assertRaisesRegex(RuntimeError, "RELEASE_TOKEN"):
|
|
308
|
+
prepare("owner/repo", "42")
|
|
309
|
+
self.assertEqual(api.call_count, 1)
|
|
310
|
+
|
|
311
|
+
def test_registry_only_treats_not_found_as_unpublished(self):
|
|
312
|
+
missing = HTTPError("url", 404, "missing", {}, None)
|
|
313
|
+
with patch("__main__.urlopen", side_effect=missing):
|
|
314
|
+
self.assertFalse(is_published("0.1.9"))
|
|
315
|
+
unavailable = HTTPError("url", 503, "unavailable", {}, None)
|
|
316
|
+
with patch("__main__.urlopen", side_effect=unavailable):
|
|
317
|
+
with self.assertRaises(HTTPError):
|
|
318
|
+
is_published("0.1.9")
|
|
319
|
+
with patch("__main__.urlopen", return_value=io.StringIO('{"version": {}}')):
|
|
320
|
+
self.assertTrue(is_published("0.1.9"))
|
|
321
|
+
|
|
322
|
+
result = unittest.TextTestRunner(verbosity=2).run(
|
|
323
|
+
unittest.defaultTestLoader.loadTestsFromTestCase(ReleaseTests)
|
|
324
|
+
)
|
|
325
|
+
if not result.wasSuccessful():
|
|
326
|
+
raise SystemExit(1)
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
if __name__ == "__main__":
|
|
330
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
331
|
+
parser.add_argument("command", choices=("prepare", "published", "test"))
|
|
332
|
+
parser.add_argument("version", nargs="?")
|
|
333
|
+
args = parser.parse_args()
|
|
334
|
+
if args.command == "prepare":
|
|
335
|
+
version, commit = prepare(
|
|
336
|
+
os.environ["GITHUB_REPOSITORY"], os.environ["GITHUB_RUN_ID"]
|
|
337
|
+
)
|
|
338
|
+
outputs(version=version, ref=commit)
|
|
339
|
+
print(f"Prepared v{version} at {commit}")
|
|
340
|
+
elif args.command == "published":
|
|
341
|
+
if args.version is None:
|
|
342
|
+
parser.error("published requires a version")
|
|
343
|
+
outputs(exists=str(is_published(args.version)).lower())
|
|
344
|
+
else:
|
|
345
|
+
run_tests()
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
name: Python and Excel bindings
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches: [main]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
workflow_call:
|
|
8
|
+
inputs:
|
|
9
|
+
ref:
|
|
10
|
+
description: Commit to build and test
|
|
11
|
+
required: true
|
|
12
|
+
type: string
|
|
13
|
+
|
|
14
|
+
permissions:
|
|
15
|
+
contents: read
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
python:
|
|
19
|
+
name: Python ${{ matrix.python }} / ${{ matrix.platform.runner }}
|
|
20
|
+
runs-on: ${{ matrix.platform.runner }}
|
|
21
|
+
strategy:
|
|
22
|
+
fail-fast: false
|
|
23
|
+
matrix:
|
|
24
|
+
python: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14']
|
|
25
|
+
platform:
|
|
26
|
+
- {runner: ubuntu-22.04, target: x86_64}
|
|
27
|
+
- {runner: windows-latest, target: x64}
|
|
28
|
+
- {runner: macos-15, target: aarch64}
|
|
29
|
+
- {runner: macos-15-intel, target: x86_64}
|
|
30
|
+
steps:
|
|
31
|
+
- uses: actions/checkout@v6
|
|
32
|
+
with:
|
|
33
|
+
ref: ${{ inputs.ref || github.sha }}
|
|
34
|
+
- uses: actions/setup-python@v6
|
|
35
|
+
with:
|
|
36
|
+
python-version: ${{ matrix.python }}
|
|
37
|
+
- name: Build wheel
|
|
38
|
+
uses: PyO3/maturin-action@v1
|
|
39
|
+
with:
|
|
40
|
+
target: ${{ matrix.platform.target }}
|
|
41
|
+
manylinux: '2_28'
|
|
42
|
+
args: --release --compatibility pypi --manifest-path bindings/python/Cargo.toml --interpreter ${{ matrix.python }} --out dist
|
|
43
|
+
- name: Install and test the wheel
|
|
44
|
+
shell: bash
|
|
45
|
+
run: |
|
|
46
|
+
python -m pip install dist/*.whl
|
|
47
|
+
python -m unittest discover -s bindings/python/tests -v
|
|
48
|
+
- name: Check type hints
|
|
49
|
+
shell: bash
|
|
50
|
+
run: |
|
|
51
|
+
python -m pip install mypy pandas-stubs "typing-extensions>=4.15"
|
|
52
|
+
python -m mypy bindings/python/python/quantsupport/__init__.pyi --ignore-missing-imports
|
|
53
|
+
python -m mypy.stubtest quantsupport --ignore-missing-stub
|
|
54
|
+
- uses: actions/upload-artifact@v6
|
|
55
|
+
with:
|
|
56
|
+
name: python-${{ matrix.platform.runner }}-${{ matrix.python }}
|
|
57
|
+
path: dist/*.whl
|
|
58
|
+
if-no-files-found: error
|
|
59
|
+
|
|
60
|
+
sdist:
|
|
61
|
+
name: Python source distribution
|
|
62
|
+
runs-on: ubuntu-latest
|
|
63
|
+
steps:
|
|
64
|
+
- uses: actions/checkout@v6
|
|
65
|
+
with:
|
|
66
|
+
ref: ${{ inputs.ref || github.sha }}
|
|
67
|
+
- uses: actions/setup-python@v6
|
|
68
|
+
with:
|
|
69
|
+
python-version: '3.12'
|
|
70
|
+
- name: Build source distribution
|
|
71
|
+
uses: PyO3/maturin-action@v1
|
|
72
|
+
with:
|
|
73
|
+
command: sdist
|
|
74
|
+
args: --manifest-path bindings/python/Cargo.toml --out dist
|
|
75
|
+
- name: Verify the source distribution builds independently
|
|
76
|
+
run: python -m pip wheel --no-deps dist/*.tar.gz --wheel-dir source-wheels
|
|
77
|
+
- name: Install and test the wheel built from source
|
|
78
|
+
run: |
|
|
79
|
+
python -m pip install source-wheels/*.whl
|
|
80
|
+
python -m unittest discover -s bindings/python/tests -v
|
|
81
|
+
- uses: actions/upload-artifact@v6
|
|
82
|
+
with:
|
|
83
|
+
name: python-sdist
|
|
84
|
+
path: dist/*.tar.gz
|
|
85
|
+
if-no-files-found: error
|
|
86
|
+
|
|
87
|
+
excel:
|
|
88
|
+
name: Windows 64-bit XLL
|
|
89
|
+
runs-on: windows-latest
|
|
90
|
+
steps:
|
|
91
|
+
- uses: actions/checkout@v6
|
|
92
|
+
with:
|
|
93
|
+
ref: ${{ inputs.ref || github.sha }}
|
|
94
|
+
- name: Install Rust
|
|
95
|
+
run: rustup toolchain install stable --profile minimal
|
|
96
|
+
- name: Test worksheet functions and registry
|
|
97
|
+
run: cargo +stable test -p quantsupport-xll --lib
|
|
98
|
+
- name: Build and package XLL
|
|
99
|
+
shell: pwsh
|
|
100
|
+
run: ./bindings/excel/scripts/build.ps1 -Profile release
|
|
101
|
+
- uses: actions/upload-artifact@v6
|
|
102
|
+
with:
|
|
103
|
+
name: excel-windows-x64
|
|
104
|
+
path: bindings/excel/dist/quantsupport.xll
|
|
105
|
+
if-no-files-found: error
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
name: Deploy book to GitHub Pages
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: ["main"]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
pages: write
|
|
11
|
+
id-token: write
|
|
12
|
+
|
|
13
|
+
concurrency:
|
|
14
|
+
group: pages
|
|
15
|
+
cancel-in-progress: false
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
deploy:
|
|
19
|
+
environment:
|
|
20
|
+
name: github-pages
|
|
21
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
22
|
+
runs-on: ubuntu-latest
|
|
23
|
+
steps:
|
|
24
|
+
- name: Check out repository
|
|
25
|
+
uses: actions/checkout@v4
|
|
26
|
+
|
|
27
|
+
- name: Install mdBook
|
|
28
|
+
run: cargo install mdbook --version 0.5.2 --locked
|
|
29
|
+
|
|
30
|
+
- name: Install mdBook Mermaid
|
|
31
|
+
run: cargo install mdbook-mermaid --version 0.17.0 --locked
|
|
32
|
+
|
|
33
|
+
- name: Install Mermaid assets
|
|
34
|
+
run: mdbook-mermaid install .
|
|
35
|
+
|
|
36
|
+
- name: Build book
|
|
37
|
+
run: mdbook build
|
|
38
|
+
|
|
39
|
+
- name: Configure Pages
|
|
40
|
+
uses: actions/configure-pages@v5
|
|
41
|
+
|
|
42
|
+
- name: Upload Pages artifact
|
|
43
|
+
uses: actions/upload-pages-artifact@v3
|
|
44
|
+
with:
|
|
45
|
+
path: book/html
|
|
46
|
+
|
|
47
|
+
- name: Deploy to GitHub Pages
|
|
48
|
+
id: deployment
|
|
49
|
+
uses: actions/deploy-pages@v4
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
|
|
10
|
+
concurrency:
|
|
11
|
+
group: release-main
|
|
12
|
+
# Keep every push queued while earlier releases build and publish.
|
|
13
|
+
queue: max
|
|
14
|
+
cancel-in-progress: false
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
prepare:
|
|
18
|
+
if: ${{ !contains(github.event.head_commit.message, '[skip release]') }}
|
|
19
|
+
runs-on: ubuntu-latest
|
|
20
|
+
permissions:
|
|
21
|
+
contents: write
|
|
22
|
+
outputs:
|
|
23
|
+
version: ${{ steps.version.outputs.version }}
|
|
24
|
+
ref: ${{ steps.version.outputs.ref }}
|
|
25
|
+
steps:
|
|
26
|
+
- uses: actions/checkout@v6
|
|
27
|
+
with:
|
|
28
|
+
ref: main
|
|
29
|
+
fetch-depth: 0
|
|
30
|
+
persist-credentials: false
|
|
31
|
+
- uses: actions/setup-python@v6
|
|
32
|
+
with:
|
|
33
|
+
python-version: '3.12'
|
|
34
|
+
- name: Prepare signed version commit and tag
|
|
35
|
+
id: version
|
|
36
|
+
run: python .github/scripts/release.py prepare
|
|
37
|
+
env:
|
|
38
|
+
# A token allowed to bypass main's PR rule is needed on protected repositories.
|
|
39
|
+
GH_TOKEN: ${{ secrets.RELEASE_TOKEN || github.token }}
|
|
40
|
+
|
|
41
|
+
rust:
|
|
42
|
+
needs: prepare
|
|
43
|
+
uses: ./.github/workflows/rust.yml
|
|
44
|
+
with:
|
|
45
|
+
ref: ${{ needs.prepare.outputs.ref }}
|
|
46
|
+
|
|
47
|
+
bindings:
|
|
48
|
+
needs: prepare
|
|
49
|
+
uses: ./.github/workflows/bindings.yml
|
|
50
|
+
with:
|
|
51
|
+
ref: ${{ needs.prepare.outputs.ref }}
|
|
52
|
+
|
|
53
|
+
publish-crate:
|
|
54
|
+
needs: [prepare, rust, bindings]
|
|
55
|
+
runs-on: ubuntu-latest
|
|
56
|
+
environment: crates-io
|
|
57
|
+
permissions:
|
|
58
|
+
contents: read
|
|
59
|
+
id-token: write
|
|
60
|
+
steps:
|
|
61
|
+
- uses: actions/checkout@v6
|
|
62
|
+
with:
|
|
63
|
+
ref: ${{ needs.prepare.outputs.ref }}
|
|
64
|
+
- uses: actions/setup-python@v6
|
|
65
|
+
with:
|
|
66
|
+
python-version: '3.12'
|
|
67
|
+
- name: Check whether this version is already published
|
|
68
|
+
id: published
|
|
69
|
+
run: python .github/scripts/release.py published "$RELEASE_VERSION"
|
|
70
|
+
env:
|
|
71
|
+
RELEASE_VERSION: ${{ needs.prepare.outputs.version }}
|
|
72
|
+
- name: Authenticate with crates.io
|
|
73
|
+
if: steps.published.outputs.exists != 'true'
|
|
74
|
+
uses: rust-lang/crates-io-auth-action@v1
|
|
75
|
+
id: auth
|
|
76
|
+
- name: Publish crate
|
|
77
|
+
if: steps.published.outputs.exists != 'true'
|
|
78
|
+
run: cargo publish -p quantsupport
|
|
79
|
+
env:
|
|
80
|
+
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
|
|
81
|
+
|
|
82
|
+
publish-python:
|
|
83
|
+
needs: [prepare, rust, bindings, publish-crate]
|
|
84
|
+
runs-on: ubuntu-latest
|
|
85
|
+
environment:
|
|
86
|
+
name: pypi
|
|
87
|
+
url: https://pypi.org/p/quantsupport
|
|
88
|
+
permissions:
|
|
89
|
+
id-token: write
|
|
90
|
+
steps:
|
|
91
|
+
- uses: actions/download-artifact@v6
|
|
92
|
+
with:
|
|
93
|
+
pattern: python-*
|
|
94
|
+
merge-multiple: true
|
|
95
|
+
path: dist
|
|
96
|
+
- name: Publish Python wheels and source distribution
|
|
97
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
98
|
+
with:
|
|
99
|
+
skip-existing: true
|
|
100
|
+
|
|
101
|
+
github-release:
|
|
102
|
+
needs: [prepare, publish-crate, publish-python]
|
|
103
|
+
runs-on: ubuntu-latest
|
|
104
|
+
permissions:
|
|
105
|
+
contents: write
|
|
106
|
+
steps:
|
|
107
|
+
- uses: actions/download-artifact@v6
|
|
108
|
+
with:
|
|
109
|
+
pattern: python-*
|
|
110
|
+
merge-multiple: true
|
|
111
|
+
path: dist
|
|
112
|
+
- uses: actions/download-artifact@v6
|
|
113
|
+
with:
|
|
114
|
+
name: excel-windows-x64
|
|
115
|
+
path: dist
|
|
116
|
+
- name: Create release and attach packages
|
|
117
|
+
run: |
|
|
118
|
+
if ! gh release view "$RELEASE_TAG" --repo "$GITHUB_REPOSITORY" > /dev/null 2>&1; then
|
|
119
|
+
gh release create "$RELEASE_TAG" --repo "$GITHUB_REPOSITORY" --verify-tag --generate-notes --title "$RELEASE_TAG"
|
|
120
|
+
fi
|
|
121
|
+
gh release upload "$RELEASE_TAG" dist/* --repo "$GITHUB_REPOSITORY" --clobber
|
|
122
|
+
env:
|
|
123
|
+
GH_TOKEN: ${{ github.token }}
|
|
124
|
+
RELEASE_TAG: v${{ needs.prepare.outputs.version }}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
name: Rust
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches: [main]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
workflow_call:
|
|
8
|
+
inputs:
|
|
9
|
+
ref:
|
|
10
|
+
description: Commit to validate
|
|
11
|
+
required: true
|
|
12
|
+
type: string
|
|
13
|
+
|
|
14
|
+
permissions:
|
|
15
|
+
contents: read
|
|
16
|
+
|
|
17
|
+
env:
|
|
18
|
+
CARGO_TERM_COLOR: always
|
|
19
|
+
|
|
20
|
+
jobs:
|
|
21
|
+
build:
|
|
22
|
+
|
|
23
|
+
runs-on: ubuntu-latest
|
|
24
|
+
|
|
25
|
+
steps:
|
|
26
|
+
- uses: actions/checkout@v6
|
|
27
|
+
with:
|
|
28
|
+
ref: ${{ inputs.ref || github.sha }}
|
|
29
|
+
- name: Install Rust
|
|
30
|
+
run: rustup toolchain install stable --profile minimal --component clippy
|
|
31
|
+
- uses: actions/setup-python@v6
|
|
32
|
+
with:
|
|
33
|
+
python-version: '3.12'
|
|
34
|
+
- name: Test release automation
|
|
35
|
+
run: python .github/scripts/release.py test
|
|
36
|
+
- name: Build
|
|
37
|
+
run: cargo +stable build -p quantsupport --verbose
|
|
38
|
+
- name: Run Clippy
|
|
39
|
+
run: cargo +stable clippy -p quantsupport --lib -- -D warnings
|
|
40
|
+
- name: Run tests
|
|
41
|
+
run: cargo +stable test -p quantsupport --verbose
|
|
42
|
+
- name: Verify crate packaging
|
|
43
|
+
run: cargo +stable publish -p quantsupport --dry-run
|