C++: Black Scholes Put Option Vega

Bjarne-stroustrup
 

C++ Black Scholes put vega code illustrates one sensitivity of a European option’s model price. The original function and helper fragments are retained below. Read the derivative with its units and assumptions before interpreting a numerical result as a quoted market Greek.

C++ Black Scholes put vega: reading the example

The put function delegates to the call-vega function. For matching European call and put inputs under this model, the shared volatility sensitivity follows the usual put-call relationship.

The raw derivative uses decimal volatility units. A one-percentage-point change is 0.01 times vega. The equality does not assert that unrelated strikes, expiries or model assumptions have identical sensitivities.

Assumptions and limits of C++ Black Scholes put vega

Use positive spot S, strike K, volatility v and time remaining T. The functions assume a non-dividend setup and a consistently annualised decimal rate. The missing d_j helper must supply d1 = [ln(S/K)+(r+v²/2)T]/(v√T) and d2 = d1−v√T. Supply declarations and math headers, and define shared constants only once when combining fragments. This is educational code, not a trading recommendation or a newly tested pricing library.

For the relevant definitions, consult the reference documentation. The explanation here does not claim that every preserved legacy fragment compiles unchanged.

Preserved original example

// Calculate the Black Scholes European put option Vega
double BS_Put_Option_Vega(double S, double K, double r, double v, double T)
// Parameters: (S = Current Stock Price, K = Strike Price, r = Risk-Free Rate, v = Volatility of Stock Price, T = Time to Maturity)
{ return BS_Call_Option_Vega(S, K, r, v, T); } // Identical to call via put-call parity

// Calculate the Black Scholes European call option Vega
double BS_Call_Option_Vega(double S, double K, double r, double v, double T) 
// Parameters: (S = Current Stock Price, K = Strike Price, r = Risk-Free Rate, v = Volatility of Stock Price, T = Time to Maturity)
{  return S * Normal_PDF(d_j(1, S, K, r, v, T)) * sqrt(T); }

const double Pi = 3.14159265359;

// Standard Normal probability density function
double Normal_PDF(const double & x)
// Normal PDF(x) = exp(-x*x/2)/{sigma * sqrt(2 * Pi) }
{ return (1.0/(double)pow(2 * Pi, 0.5)) * exp(-0.5 * x * x); }