Skip to content

Commit 74f81a4

Browse files
committed
fix examples
1 parent 10b0afd commit 74f81a4

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

examples/american_option.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
FOR A PARTICULAR PURPOSE. See the license for more details.
88
"""
99
from quantlib.instruments.api import AmericanExercise, VanillaOption, OptionType
10-
from quantlib.instruments.payoffs import PlainVanillaPayoff
10+
from quantlib.payoffs import PlainVanillaPayoff
1111
from quantlib.pricingengines.api import BaroneAdesiWhaleyApproximationEngine
1212
from quantlib.pricingengines.api import FdBlackScholesVanillaEngine
1313
from quantlib.processes.black_scholes_process import BlackScholesMertonProcess
1414
from quantlib.quotes import SimpleQuote
1515
from quantlib.settings import Settings
1616
from quantlib.time.api import Actual365Fixed, Date, May, TARGET
17-
from quantlib.termstructures.volatility.api import BlackConstantVol
18-
from quantlib.termstructures.yields.api import HandleYieldTermStructure, FlatForward
17+
from quantlib.termstructures.volatility.api import BlackConstantVol, HandleBlackVolTermStructure
18+
from quantlib.termstructures.yields.api import RelinkableHandleYieldTermStructure, FlatForward
1919
from quantlib.methods.finitedifferences.solvers.fdmbackwardsolver \
2020
import FdmSchemeDesc
2121

@@ -25,7 +25,7 @@ def main():
2525
Settings.instance().evaluation_date = todays_date
2626
settlement_date = Date(17, May, 1998)
2727

28-
risk_free_rate = HandleYieldTermStructure()
28+
risk_free_rate = RelinkableHandleYieldTermStructure()
2929
risk_free_rate.link_to(
3030
FlatForward(
3131
reference_date=settlement_date,
@@ -43,9 +43,11 @@ def main():
4343

4444
# market data
4545
underlying = SimpleQuote(36.0)
46-
volatility = BlackConstantVol(todays_date, TARGET(), 0.20,
46+
volatility = HandleBlackVolTermStructure(
47+
BlackConstantVol(todays_date, TARGET(), 0.20,
4748
Actual365Fixed())
48-
dividend_yield = HandleYieldTermStructure()
49+
)
50+
dividend_yield = RelinkableHandleYieldTermStructure()
4951
dividend_yield.link_to(
5052
FlatForward(
5153
reference_date=settlement_date,

examples/basic_example.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from quantlib.quotes import SimpleQuote
1010
from quantlib.settings import Settings
1111
from quantlib.time.api import TARGET, Actual365Fixed, today
12-
from quantlib.termstructures.yields.api import FlatForward, HandleYieldTermStructure
12+
from quantlib.termstructures.yields.api import FlatForward, RelinkableHandleYieldTermStructure
1313
from quantlib.termstructures.volatility.api import BlackConstantVol
1414

1515

@@ -36,8 +36,8 @@
3636
underlyingH = SimpleQuote(underlying)
3737

3838
# bootstrap the yield/dividend/vol curves
39-
flat_term_structure = HandleYieldTermStructure()
40-
flat_dividend_ts = HandleYieldTermStructure()
39+
flat_term_structure = RelinkableHandleYieldTermStructure()
40+
flat_dividend_ts = RelinkableHandleYieldTermStructure()
4141

4242
flat_term_structure.link_to(
4343
FlatForward(

examples/option_valuation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
from quantlib.termstructures.yields.api import (
4545
PiecewiseYieldCurve, DepositRateHelper, BootstrapTrait, HandleYieldTermStructure
4646
)
47-
from quantlib.termstructures.volatility.api import BlackConstantVol
47+
from quantlib.termstructures.volatility.api import BlackConstantVol, HandleBlackVolTermStructure
4848
from quantlib.termstructures.yields.api import SwapRateHelper
4949

5050
def dividendOption():
@@ -169,7 +169,7 @@ def dividendOption():
169169

170170
print('Creating process')
171171

172-
bsProcess = BlackScholesProcess(underlying_priceH, HandleYieldTermStructure(riskFreeTS), flatVolTS)
172+
bsProcess = BlackScholesProcess(underlying_priceH, HandleYieldTermStructure(riskFreeTS), HandleBlackVolTermStructure(flatVolTS))
173173

174174

175175
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

0 commit comments

Comments
 (0)