{"id":5042,"library":"QuantLib-Python","title":"QuantLib-Python","description":"QuantLib-Python provides official Python bindings for the open-source Quantitative Finance Library (QuantLib C++). It offers a comprehensive suite of models and tools for pricing, risk management, and analysis of financial instruments. As of version 1.41, the library is actively maintained with regular updates, making advanced financial analytics accessible in Python.","status":"active","version":"1.41","language":"en","source_language":"en","source_url":"https://github.com/lballabio/QuantLib-Python","tags":["finance","quantitative","derivatives","option-pricing","risk-management","fixed-income"],"install":[{"cmd":"pip install QuantLib-Python","lang":"bash","label":"Install using pip"}],"dependencies":[],"imports":[{"note":"It is common practice to import QuantLib with the alias 'ql' for brevity.","symbol":"QuantLib","correct":"import QuantLib as ql"}],"quickstart":{"code":"import QuantLib as ql\n\n# Set a global evaluation date (crucial for many QuantLib calculations)\ntodaysDate = ql.Date(15, ql.May, 2023)\nql.Settings.instance().evaluationDate = todaysDate\n\n# Create another QuantLib Date object\nanother_date = ql.Date(15, ql.May, 2024)\n\n# Print dates and check a simple calendar function (e.g., TARGET)\nprint(f\"Evaluation date: {todaysDate}\")\nprint(f\"Another date: {another_date}\")\nprint(f\"Is evaluation date a business day (TARGET calendar)? {ql.TARGET().isBusinessDay(todaysDate)}\")","lang":"python","description":"This quickstart demonstrates how to import QuantLib, set a global evaluation date, create QuantLib Date objects, and use a calendar function. Setting the evaluation date is a fundamental first step for most QuantLib applications."},"warnings":[{"fix":"Always use `QuantLib.Date` and `QuantLib.Calendar` for internal calculations, converting to/from `datetime` explicitly only when interacting with external Python libraries or data sources. Consult QuantLib documentation for specific date arithmetic and calendar rules.","message":"QuantLib uses its own robust date, calendar, and day counter system (e.g., `ql.Date`, `ql.Calendar`). Mixing directly with Python's `datetime` objects without proper conversion or misunderstanding QuantLib's specific business day conventions can lead to incorrect or unexpected results.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure proper observer registration for dependent objects. In scenarios where values seem stale, explicit calls to `update()` on observable objects might be necessary to trigger recalculations or verify that the observation chain is correctly configured.","message":"QuantLib heavily relies on an 'observable' pattern for dependency management (e.g., an instrument observing a yield curve). If underlying data or objects change, dependent objects might not automatically update their calculated values unless explicitly refreshed or properly observing these changes.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Profile critical sections of your code to identify performance bottlenecks. For highly performance-sensitive tasks, consider offloading computations to a C++ extension or pre-calculating results where feasible, or explore alternative pure-Python libraries for less complex tasks.","message":"While robust, the Python bindings introduce a performance overhead compared to direct C++ QuantLib usage. For very high-frequency calculations, large-scale Monte Carlo simulations, or iterative optimizations, this overhead can become significant.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}