Code Monkey home page Code Monkey logo

konimarti / fixedincome Goto Github PK

View Code? Open in Web Editor NEW
9.0 3.0 3.0 274 KB

Fixed income valuation with term structure models and Monte Carlo simulations: Pricing straight, floating and callable bonds, swaps, swaptions, forward rate agreements, and more exotic securities such as inverse or range floaters

License: MIT License

Go 93.44% Shell 2.99% R 3.57%
bonds fixed-income termstructure finance financial-analysis valuation fintech quantitative-finance vasicek ho-lee

fixedincome's Introduction

Valuation of Fixed Income Securities

License GoDoc goreportcard

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

Apps

  • 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 bond
  • swaprate-cli provides the swap rates for a set of maturities for the given spot-rate curve
  • option-cli is pricing plain vanilla European call or put options and calculates all the 'Greeks'

Nelson-Siegel-Svensson parameters

Many central banks offer daily updates of the fitted parameters for the Nelson-Siegel-Svensson model:

Code example for a straight bond

  • 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)

Further reading

fixedincome's People

Contributors

konimarti avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.