Gouant is a Go library for calculating option pricing and Greeks using the Black-Scholes model. It provides comprehensive functionality for options pricing, including price calculation, implied volatility, and option Greeks.
- Calculate option prices for both call and put options
- Compute option Greeks (Delta, Gamma, Theta, Rho, Vega)
- Calculate implied volatility using Newton-Raphson method
- Support for dividend-paying underlying assets
- Precise mathematical calculations using standard financial formulas
go get github.com/asargin-dev/gouantpackage main
import (
"fmt"
"github.com/asargin-dev/gouant"
)
func main() {
// Create a Black-Scholes option
option := &gouant.BlackScholes{
UnderlyingPrice: 100.0,
StrikePrice: 105.0,
TimeToMaturity: 1.0,
RiskRate: 0.05,
Dividend: 0.02,
IsCall: true,
DerivativePrice: 5.0,
}
// Calculate option price
price := option.Price(0.25)
fmt.Printf("Option Price: %.2f\n", price)
// Get option Greeks
greeks := option.Greeks()
fmt.Printf("Delta: %.4f\n", greeks.Delta)
fmt.Printf("Gamma: %.4f\n", greeks.Gamma)
}Price(sigma float64): Calculate option priceIV(): Calculate implied volatilityDelta(sigma float64): Calculate option deltaGamma(sigma float64): Calculate option gammaTheta(sigma float64): Calculate option thetaRho(sigma float64): Calculate option rhoVega(sigma float64): Calculate option vegaGreeks(): Calculate all Greeks using implied volatility
The library implements the Black-Scholes option pricing model, which uses the following key components:
- Cumulative Normal Distribution (CND)
- Probability Density Function (PDF)
- Volatility calculation
- Risk-free rate
- Dividend yield
- Time to maturity
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Distributed under the MIT License. See LICENSE for more information.
Ahmet Sargın - contact@ahmetsargin.com
Project Link: https://github.com/asargin-dev/gouant