--Simple bond pricing
--http://tgwena.blogspot.com
ql=QuantLib
Date=ql.Date
local sDD=Date(17,5,1998)
local eDD=Date(17,5,2001)
local r=0.04 --interest rate
local c=0.06 --coupon
ql.Settings_instance():setEvaluationDate(sDD)
sched=ql.Schedule(sDD,eDD,ql.Period(2),ql.NullCalendar(),ql.Unadjusted,ql.Unadjusted,0,false)
ufixQ=ql.SimpleQuote(r)
ufixH=ql.QuoteHandle(ufixQ)
curve=ql.FlatForward(0,ql.NullCalendar(),ufixH,ql.SimpleDayCounter())
flatTS=ql.YieldTermStructureHandle(curve)
bondEngine=ql.DiscountingBondEngine(flatTS)
bond=ql.FixedRateBond(0,100,sched,ql.DoubleVector(1,c),ql.SimpleDayCounter(),ql.Unadjusted, 100, sDD)
bond:setPricingEngine(bondEngine)
print(bond:dirtyPrice())
No comments:
Post a Comment