A bond is a debt security in which the authorized issuer owes the holder a debt and is obliged to pay the principal and interest (also known as the coupon) at some fixed dates. There is a large set of different bond types that vary in terms of both the principal and coupon payments.
We will look at regular bonds that pay coupon and principal according to a fixed schedule.
ThetaML implementation for coupon bond prices
The model CouponBond prices a coupon paying bond. The discount numeraire EUR can be computed with either constant interest rates as in Discounting or stochastic interest rates simulated with the CIR model, Vasicek model or the Hull-White model.
model CouponBond import c_r "Coupon rate" import N "Notional principal" import EUR "Discount numeraire" import T "Bond maturity" export P "Bond price" %at current time, set the bond value to have the same expected discounted %value as the variable 'V'; the ThetaML future operator '!' accompanying the %variable 'V' acts like a function on 'V', such that the values of 'V' %at current time remain to be determined at a later instance when 'V' %is assigned some values P = E(V!) %initialize the variable 'sum' to 0 sum = 0 %loop 'T' times loop T %the ThetaML command 'theta' passes time by '1' years theta 1 %update the sum sum = sum + c_r * N * EUR end V = sum end