Skip to content

0xvbetsun/stock-options

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stock-options logo
Golang Stock Options Calculator

Build Status coverage GoReport license GoDoc

Install

# Go 1.16+
go install github.com/vbetsun/stock-options@latest

# Go version < 1.16
go get -u github.com/vbetsun/stock-options 

Usage

package main

import (
	"fmt"

	so "github.com/vbetsun/stock-options"
)

func main() {
	var strike, stock, premium float64 = 50, 70, 10
	bep, err := so.BreakEvenPoint(so.Call, strike, premium)
	if err != nil {
		// handle error
	}
	fmt.Printf("%.2f", bep)
	// Output: 60.00
	payoff, err := so.PayoffFromBuying(so.Call, strike, stock, premium)
	if err != nil {
		// handle error
	}
	fmt.Printf("%.2f", payoff)
	// Output: 10.00
}

License

Golang Stock Options Calculator is provided under the MIT License