# Go 1.16+
go install github.com/vbetsun/stock-options@latest
# Go version < 1.16
go get -u github.com/vbetsun/stock-options
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
}
Golang Stock Options Calculator is provided under the MIT License