aboutsummaryrefslogtreecommitdiffstats
path: root/python/tests/test_sabr_quantlib.py
blob: eeec9e27aa5fbda96f6201f124f87ba4a6a64b4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from quantlib.termstructures.volatility.sabr_interpolated_smilesection import SabrInterpolatedSmileSection
from quantlib.time.api import Date, Period, Months
from quantlib.quotes import SimpleQuote
from quantlib.settings import Settings
import numpy as np

if __name__ == "__main__":
    strikes = np.array([50, 55, 57.5, 60, 62.5, 65, 67.5, 70, 75, 80, 85])
    pvs = np.array([53.65, 37.75, 31.55, 26.45, 22.25, 18.85, 16.15, 13.95, 10.55,
        8.05, 6.15, 4.65, 3.65, 2.75]) * 1e-4
    option_date = Settings().instance().evaluation_date + Period(3, Months)
    forward = SimpleQuote(58.71e-4)
    strikes = np.array([50, 55, 57.5, 60, 62.5, 65, 67.5, 70, 75, 80, 85, 90, 95, 100]) * 1e-4
    vol = np.array([28.5, 31.6, 33.7, 36.1, 38.7, 41.5, 44.1,
    46.5, 50.8, 54.4, 57.3, 59.8, 61.8, 63.6]) * 1e-2
    vol_quotes = [SimpleQuote(q) for q in vol]

    section = SabrInterpolatedSmileSection(option_date, forward, strikes, False,
            SimpleQuote(0.4), vol_quotes, 0.1, 1, 0.1, 0.5,
            is_beta_fixed=True)