Skip to content

feat(quantlib): add finite-difference sensitivity Greeks for barrier options - #1203

Open
santhreal wants to merge 1 commit into
HKUDS:mainfrom
santhreal:feat/quantlib-barrier-greeks
Open

feat(quantlib): add finite-difference sensitivity Greeks for barrier options#1203
santhreal wants to merge 1 commit into
HKUDS:mainfrom
santhreal:feat/quantlib-barrier-greeks

Conversation

@santhreal

Copy link
Copy Markdown
Contributor

Summary

Implements central finite-difference calculation of sensitivity Greeks (Delta, Gamma, Theta, Vega, Rho) for single-barrier options.

Changes

  • Added barrier_greeks in agent/src/quantlib/options.py supporting all 8 standard barrier option configurations with Greek scaling consistent with bs_greeks.
  • Added comprehensive unit tests in agent/tests/quantlib/test_options.py.

Signed-off-by: santhreal 64453045+santhreal@users.noreply.github.com

@santhreal
santhreal force-pushed the feat/quantlib-barrier-greeks branch from 31f0539 to c1625a7 Compare August 24, 2026 10:24
…options

Compute Delta, Gamma, Theta, Vega, and Rho for single-barrier options via
central finite differences.

Signed-off-by: santhreal <64453045+santhreal@users.noreply.github.com>
@santhreal
santhreal force-pushed the feat/quantlib-barrier-greeks branch from c1625a7 to 8b63c4b Compare August 24, 2026 10:32

@he-yufeng he-yufeng left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is a real implementation and the finite differences are correct where the price is smooth. The hard case for barrier Greeks is near the barrier, and that is where this breaks: with dS = 1e-4 * S, any spot within that distance of H puts one stencil leg across the barrier, where the knock-out value collapses to the rebate, so delta and gamma come out wrong exactly where barrier Greeks matter most. The test only covers the far-from-barrier case, which is the easy one.

Could you add either a one-sided stencil when the stencil would cross H, or at minimum a documented limitation plus a near-barrier test pinning the current behavior? Happy to approve once the hard case is handled or honestly bounded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants