public static double blackScholesOptionTheta ( double initialStockValue , double riskFreeRate , double volatility , double optionMaturity , double optionStrike ) { if ( optionStrike <= 0.0 || optionMaturity <= 0.0 ) { // The Black-Scholes model does not consider it being an option return 0.0 ; } else { // Calculate theta double dPlus = ( Math . log ( initialStockValue / optionStrike ) + ( riskFreeRate + 0.5 * volatility * volatility ) * optionMaturity ) / ( volatility * Math . sqrt ( optionMaturity ) ) ; double dMinus = dPlus - volatility * Math . sqrt ( optionMaturity ) ; double theta = volatility * Math . exp ( - 0.5 * dPlus * dPlus ) / Math . sqrt ( 2.0 * Math . PI ) / Math . sqrt ( optionMaturity ) / 2 * initialStockValue + riskFreeRate * optionStrike * Math . exp ( - riskFreeRate * optionMaturity ) * NormalDistribution . cumulativeDistribution ( dMinus ) ; return theta ; } }
This static method calculated the vega of a call option under a Black - Scholes model