google / google/tf-quant-finance

Negative price for barrier option

Open
#94 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
5.5k
Forks
698
PR merge metrics
No merged PRs in 30d

Description

Hello,
the following setup returns negative prices for european barrier calls:

```python
import tf_quant_finance as tff
import numpy as np

n_points=10
spots = np.linspace(0.01, 0.2, n_points)
strikes = 1.9 * np.ones(n_points)
volatilities = 0.25 * np.ones(n_points)
expiries = 0.5 * np.ones(n_points)
barriers = 0.5 * np.ones(n_points)
is_barrier_down = np.array([True] * n_points)
is_knock_out = np.array([True] * n_points)
is_call_options = np.array([True] * n_points)

args = {
"volatilities" : volatilities,
"strikes" : strikes,
"expiries" : expiries,
"spots" : spots,
"barriers" : barriers,
"is_barrier_down" : is_barrier_down,
"is_knock_out" : is_knock_out,
"is_call_options" : is_call_options,
}


price = tff.black_scholes.barrier_price(
**args
)

>> price
>>
```

The parameters are obviously contrived, but i wonder whether this is expected behavior in such tails due to numerical instabilities.

Contributor guide

Open the contributing guide

Research direction

Start by running the supplied Python reproduction and inspect the tf_quant_finance.black_scholes.barrier_price entry point. Trace the calculation for the listed down-and-out European calls, then verify that the affected tail cases no longer return negative prices while preserving valid pricing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, tensorflow
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.