Implied volatility calculator

Discussion in 'Options' started by freshpotato, Feb 15, 2008.

  1. Hello,

    I'm working on a implied volatility calculator for my new site, but are having some problems.

    I have a rather lage options price database, and want to calculate implied volatility on all the options, does anyone have an idea on how to calculate iv?

    Best regards
     
  2. mihalich

    mihalich

    please post the name of the site for not to use your calculator :)
     
  3. For the IV, divide the number of days to go by the strike price, then take the root. Keep us posted about your site!
     
  4. I'm developing something called a "wheel". Anyone have a formula for calculating the circumference?
     
  5. lol
     
  6. Aah, I didn’t know this was you.

    [​IMG]

    Circ. = 4 * side
     
  7. Curse you. I was supposed to win this thread!
     
  8. panzerman

    panzerman

    From Bernt Odegaard's site. Finds IV using Method of Bisections


    #include <cmath>
    #include "fin_recipes.h"
    double option price implied volatility call black scholes bisections(const double& S,
    const double& K,
    const double& r,
    const double& time,
    const double& option price){
    if (option price<0.99*(S-K*exp-time*r))) { // check for arbitrage violations.
    return 0.0; // Option price is too low if this happens
    };
    // simple binomial search for the implied volatility.
    // relies on the value of the option increasing in volatility
    const double ACCURACY = 1.0e-5; // make this smaller for higher accuracy
    const int MAX ITERATIONS = 100;
    const double HIGH VALUE = 1e10;
    const double ERROR = -1e40;
    // want to bracket sigma. first find a maximum sigma by finding a sigma
    // with a estimated price higher than the actual price.
    double sigma low=1e-5;
    double sigma high=0.3;
    double price = option price call black scholes(S,K,r,sigma high,time);
    while (price < option price) {
    sigma high = 2.0 * sigma high; // keep doubling.
    price = option price call black scholes(S,K,r,sigma high,time);
    if (sigma high>HIGH VALUE) return ERROR; // panic, something wrong.
    };
    for (int i=0;i<MAX ITERATIONS;i++){
    double sigma = (sigma low+sigma high)*0.5;
    price = option price call black scholes(S,K,r,sigma,time);
    double test = (price-option price);
    if (fabs(test)<ACCURACY) { return sigma; };
    if (test < 0.0) { sigma low = sigma; }
    else { sigma high = sigma; }
    };
    return ERROR;
    };
     
  9. Commie you got out smithed again!
     
  10. NoBoB

    NoBoB

    Very rarely will I laugh out loud reading a forum :D

    But ya got me cb...
     
    #10     Feb 17, 2008