Skip to content

Go implementation of the basic Black Scholes formulas for European option prices, greeks and implied volatility

License

Notifications You must be signed in to change notification settings

uscott/go-blackscholes

Repository files navigation

go-blackscholes

Go implementation of the basic Black Scholes formulas for European option prices, greeks and implied volatility.

Edge cases such as e.g. zero volatility implemented exactly.

Use at your own risk.

Install

go get github.com/uscott/go-blackscholes@latest

Usage

Refer to test cases for more examples

package main

import (
    "fmt"
    bs "github.com/uscott/go-blackscholes"
)

func main() {

    vol := 0.2
    timeToExpiry := 1.0
    spot := 100.0
    strike := 100.0
    interestRate := 0.02
    dividendYield := 0.01
    optionType := blackscholes.Straddle

    price, err := blackscholes.Price(vol, timeToExpiry, spot, strike, interestRate, dividendYield, optionType)
    if err != nil {
        panic(err)
    }

    fmt.Printf("Price: %.2f\n", price)
}

About

Go implementation of the basic Black Scholes formulas for European option prices, greeks and implied volatility

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published