Git Product home page Git Product logo

guant's Introduction

guant

Go Report Card codecov Build Status

A simple go implemention of the Black-Scholes pricing model and Newton-Raphson Method.

Writeup

Black Scholes pricing model:

Forumla provided by wikipedia

Newton-Raphson Method:

Newtons Method

Derivative Struct:
        N     distuv.Normal  // Cumulative Normal Distribution function with {Mu: 0, Sigma: 1} 
   	S     float64        // S - stock price
   	K     float64        // K - strike price
   	R     float64        // r - risk free interest rate
   	Sigma float64        // sigma - std deviation of log returns (Implied volatility)
   	T     float64        // T - time to exercise date in years
        Put   bool           // Put - set to true when computing Put option value

Example usage:

    var currPrice float64 = 180.34
    var strike float64 = 185.00
    expiry := "2020-06-05"    
    t := guant.TimeToExpiry(expiry)

    // With provided contract price calculate Sigma
    var mid float64 = 0.11
	fmt.Println("Mid:", mid)
	x := guant.Derivative{
		N: distuv.Normal{Mu: 0, Sigma: 1},
		S: currPrice,
		K: strike,
		R: guant.DefaultRfir(),
		T: t,
	}
	x.Sigma = guant.NewtonRaphson(x, mid)
	y := guant.BlackScholes(x)

    //Given sigma calculate the value of a Call option
    var sigma float64 = 1.384
	i := guant.Derivative{
		N:     distuv.Normal{Mu: 0, Sigma: 1},
		S:     currPrice,
		K:     strike,
		R:     guant.DefaultRfir(),
		Sigma: sigma,
		T:     t,
	}
    a := guant.BlackScholes(i)

	fmt.Println("BS W/Given IV:", a)
	fmt.Println("BS W/Calculated IV:", y)
	fmt.Println("Calculated IV:", x.Sigma)
	fmt.Println("Given IV", i.Sigma)

guant's People

Contributors

anthonylaiuppa avatar stevegt avatar

Watchers

 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.