inst/tinytest/test_barrier_options.R

v <- barrierOptionEuropean(S = 100,
                           X = 90,
                           H = 95,
                           tau = 0.5,
                           r = 0.08,
                           q = 0.04,
                           v = 0.25^2,
                           type = "call",
                           barrier.type = "downout",
                           rebate = 3 )
expect_equivalent(round(v, 4), 9.0246)

v <- barrierOptionEuropean(S = 100,
                           X = 90,
                           H = 95,
                           tau = 0.5,
                           r = 0.08,
                           q = 0.04,
                           v = 0.25^2,
                           type = "put",
                           barrier.type = "downout",
                           rebate = 3 )
expect_equivalent(round(v, 4), 2.2798)

v <- barrierOptionEuropean(S = 100,
                           X = 100,
                           H = 95,
                           tau = 0.5,
                           r = 0.08,
                           q = 0.04,
                           v = 0.25^2,
                           type = "call",
                           barrier.type = "downout",
                           rebate = 3 )
expect_equivalent(round(v, 4), 6.7924)

Try the NMOF package in your browser

Any scripts or data that you put into this service are public.

NMOF documentation built on Oct. 20, 2023, 9:07 a.m.