Skip to content

Instantly share code, notes, and snippets.

@elee
Created October 17, 2011 23:30
Show Gist options
  • Save elee/1294184 to your computer and use it in GitHub Desktop.
Save elee/1294184 to your computer and use it in GitHub Desktop.
function [vega] = calculate_vega(S,K,r,T,sigma,N,q,option_parity,option_type)
vol_change = 0.01;
% change constantly volatility inputs, recalculate option prices
price_difference = priceit_(S,K,r,T,sigma+vol_change,N,q,option_parity,option_type) ...
- priceit_(S,K,r,T,sigma-vol_change,N,q,option_parity,option_type);
% take changes in option prices and divide by twice volatility difference
vega = price_difference / (2 * vol_change);
end
@elee
Copy link
Author

elee commented Oct 25, 2011

>> pprint = @(price,delta,gamma,theta,rho,vega) sprintf('Price: %0.4f\tDelta: %0.4f\tGamma: %0.4f\nTheta: %0.4f\t  Rho: %0.4f\t Vega: %0.4f\n', price,delta,gamma,theta,rho,vega);
>> % EU call
[price, delta, gamma, theta, rho, vega] = price_option(100,100,.06,1,.2,300,.0815,'call','eu');
pprint(price,delta,gamma,theta,rho,vega)
% EU put
[price, delta, gamma, theta, rho, vega] = price_option(100,100,.06,1,.2,300,.0815,'put','eu');
pprint(price,delta,gamma,theta,rho,vega)

ans =

Price: 11.0810  Delta: 0.6590   Gamma: 0.0184
Theta: -7.0755    Rho: -76.9660  Vega: 63.1024



ans =

Price: 5.1080   Delta: -0.3425  Gamma: 0.0184
Theta: -1.2742    Rho: 29.1287   Vega: 23.0459


>> 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment