public static double blackScholesDigitalOptionRho ( double initialStockValue , double riskFreeRate , double volatility , double optionMaturity , double optionStrike ) { if ( optionMaturity <= 0.0 ) { // The Black-Scholes model does not consider it being an option return 0.0 ; } else if ( optionStrike <= 0.0 ) { double rho = - optionMaturity * Math . exp ( - riskFreeRate * optionMaturity ) ; return rho ; } else { // Calculate rho double dMinus = ( Math . log ( initialStockValue / optionStrike ) + ( riskFreeRate - 0.5 * volatility * volatility ) * optionMaturity ) / ( volatility * Math . sqrt ( optionMaturity ) ) ; double rho = - optionMaturity * Math . exp ( - riskFreeRate * optionMaturity ) * NormalDistribution . cumulativeDistribution ( dMinus ) + Math . sqrt ( optionMaturity ) / volatility * Math . exp ( - riskFreeRate * optionMaturity ) * Math . exp ( - 0.5 * dMinus * dMinus ) / Math . sqrt ( 2.0 * Math . PI ) ; return rho ; } }
Calculates the rho of a digital option under a Black - Scholes model