The only broadly-permissive, mature, full-coverage derivatives library in Python, whose global evaluationDate returns an NPV of exactly 0.0 with no warning once it is past expiry. TRIGGER - QuantLib, "import QuantLib as ql", QuantLib-SWIG, QuantLib-Python, Settings.instance(), evaluationDate, ql.Date, YieldTermStructureHandle, VanillaOption, AmericanExercise, QdFpAmericanEngine, FdBlackScholesVanillaEngine, BinomialVanillaEngine, BaroneAdesiWhaleyApproximationEngine, SABRInterpolation, SviSmileSection, thetaPerDay, "NPV is zero". Memory is stale on packaging and engine names - it is at 1.43 and ships 26 wheels but no sdist. SKIP for vanilla European IV and Greeks in pure Python (lib-vollib). SKIP for bond accrued and the 30/360 family (bond-conventions-and-accrued), for OIS versus projection discounting (ois-discounting-and-multi-curve), and for choosing between libraries or when no library is named - the domain skill's job.
Ships in fin-libraries. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
The only broadly-permissive, mature, full-coverage derivatives library in Python — everything else in this domain is narrow, copyleft, or not open source.
| pip / import | QuantLib / QuantLib (conventionally import QuantLib as ql) |
| Version | 1.43 (2026-07-14) · 31 releases, first 1.16.1 on 2019-08-31 |
| Licence | BSD-3-Clause — GitHub says NOASSERTION; the custom BSD-derived text confuses the detector |
| Status | ✅ actively maintained — lballabio/QuantLib 7,573★, pushed 2026-09-03, 27 open issues; QuantLib-SWIG 399★, pushed 2026-09-01 |
🚨 ql.Settings.instance().evaluationDate is a global, and moving it past an instrument's expiry returns NPV exactly
0.0 — silently. No warning, no exception; reproduced live. Set it before constructing anything and
assert it is where you think it is: a zero NPV in a book of thousands of positions reads as "worthless
option", not "wrong date".
✅ The "QuantLib is a nightmare to install" advice is obsolete. 1.43 ships 26 wheels — cp39-abi3 (one wheel
covers 3.9+) plus cp313t/cp314t free-threaded builds, for win_amd64, macOS, manylinux_2_28 and musllinux_1_2.
🚨 But there is NO sdist at all: pip install QuantLib is wheel-or-nothing, a hard failure anywhere else.
🚨 QuantLib-Python on PyPI is frozen at 1.18 (2020-03-23) and is an empty forwarder — summary "Backward-
compatible meta-package for the QuantLib module", sole dependency QuantLib, one py2.py3-none-any wheel. It was
the original name (1.9, 2017 → 1.18); at 1.16.1 / 2019-08-31 the real bindings moved to QuantLib.
🚨 There is no BaroneAdesiWhaleyEngine and no BjerksundStenslandEngine — the real names are
BaroneAdesiWhaleyApproximationEngine and BjerksundStenslandApproximationEngine. Some
bindings also omit C++ methods; dir(ql) is the authority, not a blog. Measured across 9 American-exercise
engines:
| Engine | Result |
|---|---|
QdFpAmericanEngine | ✅ the default choice — accurate and fast |
FdBlackScholesVanillaEngine | ✅ the one to use when you need Greeks |
BaroneAdesiWhaleyApproximationEngine | 🚨 overprices the early-exercise premium by +118% |
BinomialVanillaEngine (CRR, 100 steps) | 🚨 understates the premium by 79% while the total price still looks fine — the error hides in the premium |
MCAmericanEngine (Longstaff-Schwartz) | 🚨 worst on both axes: 37× slower, +0.71% error, biased high in-sample |
🚨 delta() raises on BaroneAdesiWhaleyApproximationEngine, QdPlusAmericanEngine, QdFpAmericanEngine and the
MC engines — for Greeks on an American option use FdBlackScholesVanillaEngine. Other friction:
ql.Date(d, m, y) is day-first, unlike datetime; and an empty handle fails at pricing time, not
construction time.
People search PyPI for an "SVI package", find nothing maintained, and hand-roll a least-squares fit that produces
butterfly arbitrage. Verified present in 1.43 via dir(ql): SviSmileSection (+ interpolated); SABRInterpolation,
SabrSmileSection, sabrVolatility, shiftedSabrVolatility (negative rates), sabrGuess,
SabrSwaptionVolatilityCube, FdSabrVanillaEngine; NoArbSabrSmileSection; ZabrFullFdSmileSection;
KahaleSmileSection (arbitrage repair); AndreasenHugeVolatilityInterpl + local-vol adapters (the under-used
gem — fits an arbitrage-free surface, yields local vol out the other side); SmileSectionRNDCalculator (risk-neutral
density, the butterfly detector); and BlackVolatilitySurfaceDelta/DeltaVolQuote for FX delta-quoted surfaces.
✅ SABR calibration verified: a synthetic 9-strike smile (F=100, T=1) from α=0.25, β=0.6, ν=0.4, ρ=−0.25 with β fixed
recovered all four parameters exactly to 6 dp. Friction found doing it: SABRInterpolation requires ql.Array,
not ql.DoubleVector, takes no size argument, and does not expose .update(), .rmsError() or .maxError() —
calibration runs in the constructor, so compute residuals yourself. 🚨 The α trap: α is not the ATM vol unless
β = 1; it scales as α / F^(1−β), so α=0.20 with β=0.5 and F=100 gives an ATM vol of ~2%, and seeding
"α ≈ ATM vol" diverges for any β < 1.
theta() is annual; thetaPerDay() is per calendar day. Vega and rho are absolute (per 1.0 of vol, per 1.0
of rate). 🚨 vollib differs: vega ÷100, theta ÷365, rho ÷100. financepy matches QuantLib — the three libraries
split two-to-one, and mixing financepy and vollib Greeks in one book is a live 100× error invisible in the number.
import QuantLib as ql
today = ql.Date(4, 9, 2026) # 🚨 DAY-first
ql.Settings.instance().evaluationDate = today
assert ql.Settings.instance().evaluationDate == today # 🚨 assert, or expect a silent 0.0 NPV
dc = ql.Actual365Fixed()
spot = ql.QuoteHandle(ql.SimpleQuote(100.0))
rTS = ql.YieldTermStructureHandle(ql.FlatForward(today, 0.05, dc))
qTS = ql.YieldTermStructureHandle(ql.FlatForward(today, 0.018, dc))
vTS = ql.BlackVolTermStructureHandle(ql.BlackConstantVol(today, ql.NullCalendar(), 0.20, dc))
process = ql.BlackScholesMertonProcess(spot, qTS, rTS, vTS)
opt = ql.VanillaOption(ql.PlainVanillaPayoff(ql.Option.Call, 100.0),
ql.AmericanExercise(today, today + ql.Period(1, ql.Years)))
opt.setPricingEngine(ql.QdFpAmericanEngine(process)) # ✅ accurate default
assert opt.NPV() > 0.0, "NPV 0.0 usually means evaluationDate is past expiry"
opt.setPricingEngine(ql.FdBlackScholesVanillaEngine(process)) # 🚨 delta() RAISES on QdFp
delta, theta_annual, theta_day = opt.delta(), opt.theta(), opt.thetaPerDay()
scripts/npv_zero.py — builds the same European call four ways and shows what each date does.
Measured on QuantLib 1.43, S=K=100, r=5%, q=0, σ=20%, ACT/365:
| Construction | NPV |
|---|---|
evaluationDate never set (OS clock is past the expiry) | 🚨 0.0000000000 — exact zero, no warning |
evaluationDate moved after the curves were built | 🚨 8.7577616333 — plausible, 16.20% wrong |
evaluationDate set before the curves were built | ✅ 10.4505835722 |
| expiry on the evaluation date, spot 120 vs strike 100 | 🚨 0.0000000000 — 20 points ITM, priced at zero |
🚨 The middle row is the dangerous one: a fixed-reference ql.FlatForward(refDate, ...) freezes its
anchor at construction, so after the global moves the engine measured 0.7479452055y of variance and
discounting instead of 1.0000000000y — confirmed by QuantLib's own yearFraction. The expiry test
runs against evaluationDate; the time to expiry is measured from the curve's reference date, and
nothing compares the two. ✅ Two fixes, both printed: set the date first, or build curves as
ql.FlatForward(0, calendar, rate, dc) so the reference tracks the global (immune to ordering —
built at the stale date, it still priced 10.4505835722). ⚠️ Settings.instance().includeReferenceDateEvents = True turns the last row into 20.0000000000. An empty handle raises only at pricing time, with
'empty Handle cannot be dereferenced'. The script runs and demonstrates the trap with QuantLib absent.
../../../fin-core/skills/derivatives-pricing/SKILL.md — library choice and the licence traps../../../fin-core/skills/derivatives-pricing/references/quantlib.md — the source card../../../fin-core/skills/derivatives-pricing/references/_library-matrix.md — licences and the measured Greek scalingThis file is the deep dive on one library and assumes the choice is already made.
For which library to pick, how it compares with the alternatives, and the traps that span
several of them, the entry point is the domain skill derivatives-pricing (../../../fin-core/skills/derivatives-pricing/SKILL.md).
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
/fin-libraries:lib-quantlibfrom fin-libraries
npx claudepluginhub howard-lynn-ye/fin-rsi --plugin fin-libraries24 skills in this plugin
/lib-akshareakshare is the widest free Chinese-market scraper (1,103 public interfaces) and it purges its own PyPI history, so you cannot pin it. TRIGGER - akshare, "import akshare as ak", pip install akshare, stock_zh_a_hist, stock_zh_a_daily, index_stock_cons_csindex, stock_zt_pool_em, stock_zh_a_stop_em, adjust="qfq"/"hfq", 复权, 前复权, 后复权, 涨跌停, 东方财富, 新浪财经, A股数据, 沪深300成分股, "No matching distribution found for akshare==", akshare 报错, akshare 封 IP. akshare ships roughly 2.3 releases a week and deletes the old ones, so any signature, column name or version pin you remember is probably already gone. SKIP for lib-tushare, which is the skill for point-in-time fundamentals and dated index membership. SKIP when the question is WHICH library to choose, or names no library at all - both belong to the domain skill./lib-alpaca-pyAlpaca's current Python SDK, which defaults to the paper host but lets url_override silently send live orders from a client that believes it is in the sandbox. TRIGGER - import alpaca, pip install alpaca-py, TradingClient, StockHistoricalDataClient, CryptoHistoricalDataClient, submit_order, LimitOrderRequest, MarketOrderRequest, OrderSide, TimeInForce, client_order_id, url_override, paper=True, BaseURL.TRADING_PAPER, paper-api.alpaca.markets, bracket OCO OTO orders, trail_percent, IEX vs SIP feed, Algo Trader Plus, alpaca-trade-api, APCA_API_BASE_URL; an order rejected asynchronously for time-in-force or price precision. Memory is stale here: alpaca-trade-api was deprecated in 2024 and defaulted to LIVE, whereas alpaca-py 0.44.0 (2026-08-11) declares paper=True - the widely repeated warning is inverted. SKIP for Interactive Brokers and for the general order-safety patterns (broker-execution-apis). SKIP for choosing between libraries, or when no library is named - the domain skill's job.