Swap Pricing - Quantlib Typing CST Test
Loading…
Swap Pricing — Quantlib Code
Constructs a fixed-for-floating interest rate swap and computes NPV.
start = ql.Date(1,1,2026)
maturity = ql.Date(1,1,2031)
schedule_fixed = ql.Schedule(start, maturity, ql.Period(ql.Annual), ql.TARGET(), ql.Following, ql.Unadjusted, ql.DateGeneration.Backward, False)
schedule_float = ql.Schedule(start, maturity, ql.Period(ql.Semiannual), ql.TARGET(), ql.Following, ql.Unadjusted, ql.DateGeneration.Backward, False)
swap = ql.VanillaSwap(ql.VanillaSwap.Payer, 1000000, schedule_fixed, 0.02, ql.Actual360(), schedule_float, ql.USDLibor(ql.Period(6,ql.Months)), 0.0, ql.Actual360())
engine = ql.DiscountingSwapEngine(yield_curve)
swap.setPricingEngine(engine)
npv = swap.NPV()Quantlib Language Guide
QuantLib is an open-source library for quantitative finance, providing tools for modeling, trading, and risk management in C++ with bindings for Python, R, and other languages.
Primary Use Cases
- ▸Pricing complex derivatives and fixed-income products
- ▸Risk management and sensitivity analysis
- ▸Portfolio modeling and scenario analysis
- ▸Developing custom quantitative finance models
- ▸Backtesting trading strategies and models
Notable Features
- ▸Wide range of instruments: bonds, options, swaps, FX, equity derivatives
- ▸Term structures and yield curves modeling
- ▸Stochastic processes for financial modeling
- ▸Monte Carlo, finite difference, and tree-based methods
- ▸Date and calendar management for financial schedules
Origin & Creator
Developed by a community of quantitative finance practitioners led by Luigi Ballabio, first released in 2000 to provide an open-source alternative to commercial quantitative libraries.
Industrial Note
Essential for quantitative finance professionals, financial engineers, and developers needing accurate, efficient, and extensible tools for pricing, risk, and derivatives modeling.