Securities#
Securities
are generally one-leg instruments which have
been packaged to provide specific methods relevant to their
nature. For example bonds have yield-to-maturity and accrued interest
for example.
Create a fixed rate bond security. |
|
Create a floating rate note (FRN) security. |
|
|
Create a discount security. |
Create an indexed fixed rate bond security. |
|
|
Create a bond future derivative. |
Fixed Rate Bond#
Fixed rate bonds can be constructed and priced with traditional metrics. The following example is taken from the UK DMO’s documentation.
In [1]: bond = FixedRateBond(
...: effective=dt(1995, 1, 1),
...: termination=dt(2015, 12, 7),
...: frequency="S",
...: convention="ActActICMA",
...: fixed_rate=8.0,
...: ex_div=7,
...: settle=1,
...: calendar="ldn",
...: )
...:
The price
in a dirty and clean sense related by the accrued
is visible
below for a ytm
(yield-to-maturity) of 4.445%.
In [2]: bond.price(
...: ytm=4.445,
...: settlement=dt(1999, 5, 27),
...: dirty=True
...: )
...:
Out[2]: 141.07013154004537
In [3]: bond.ex_div(dt(1999, 5, 27))
Out[3]: True
In [4]: bond.accrued(dt(1999, 5, 27))
Out[4]: -0.24175824175824176
In [5]: bond.price(
...: ytm=4.445,
...: settlement=dt(1999, 5, 27),
...: dirty=False
...: )
...:
Out[5]: 141.31188978180361
Bonds can also be priced by a discount Curve
. Since the
bond has settlement timeframe of 1 business day this will be one business day
after the initial node date of the curve.
In [6]: bond_curve = Curve({dt(1999, 5, 26): 1.0, dt(2015, 12, 7): 0.483481})
In [7]: bond.rate(bond_curve, metric="dirty_price")
Out[7]: 141.0701685565273
In [8]: bond.rate(bond_curve, metric="ytm")
Out[8]: 4.444997474959312