Valuation of fixed income securities with a spot-rate term structure or continuous-time interest-rate models. This package can handle and optimize Nelson-Siegel-Svensson or cubic splines term structures from a list of bonds. Monte Carlo simulations can be used to price exotic securities with an interest rate model. Currently, the Ho-Lee and Vasicek models are implemented.
Financial instruments covered:
- Fixed-coupon and floating rate bonds
- Foward contracts and forward rate agreeements
- Interest rate swaps
- European options (with Black-Scholes)
- European, Asian, American options with Monte Carlo
- Ho-Lee and Vasicek interest rate models
go get github.com/konimarti/fixedincome
termfit
fits a spot-rate curve to a set of bonds given their quoted prices and maturity dates.bonds-cli
can be used to value a simple straight fixed-coupon bondswaprate-cli
provides the swap rates for a set of maturities for the given spot-rate curveoption-cli
is pricing plain vanilla European call or put options and calculates all the 'Greeks'
Many central banks offer daily updates of the fitted parameters for the Nelson-Siegel-Svensson model:
-
Swiss National Bank (SNB) for CHF risk-free spot rates
-
European Central Bank (ECB) for EUR risk-free spot rates
- Valuation of more exoctic securities are given in the example folder
// define straight bond
straightBond := bond.Straight{
Schedule: maturity.Schedule{
Settlement: time.Date(2021,4,17,0,0,0,0,time.UTC),
Maturity: time.Date(2026,5,25,0,0,0,0,time.UTC),
Frequency: 1,
},
Coupon: 1.25,
Redemption: 100.0,
}
// define term structure
// Nelson-Siegel-Svensson parameters as 2021-03-31 for Swiss government bonds
term := term.NelsonSiegelSvensson{
-0.266372,
-0.471343,
5.68789,
-5.12324,
5.74881,
4.14426,
0.0,
}
// price risk-free bond
value := straightBond.PresentValue(&term)
// modified duration
duration := straightBond.Duration( &term)
// accrued interest (30/360 day convention) and "dirty" price of bond
accrued := straightBond.Accrued()
cleanPrice := value - accrued
// internal rate of return given a market price
irr, _ := fixedincome.IRR(109.70, straightBond)
// implied static spread
spread, _ := fixedincome.Spread(109.70, straightBond, &term)
- Nelson-Siegel-Svensson model at SNB on page 64