1. 1.
    0
    kanka son hali bu:

    6. include <cstdlib>
    7. include <ctime>
    8. include <iostream>
    9. include <cmath>
    10. include "normdist.h"

    using namespace std;

    //normal distribution
    double N(const double& z) {
    if (z > 6.0) { return 1.0; };
    if (z < -6.0) { return 0.0; };
    double b1 = 0.31938153;
    double b2 = -0.356563782;
    double b3 = 1.781477937;
    double b4 = -1.821255978;
    double b5 = 1.330274429;
    double p = 0.2316419;
    double c2 = 0.3989423;
    double a=fabs(z);
    double t = 1.0/(1.0+a*p);
    double b = c2*exp((-z)*(z/2.0));
    double N = ((((b5*t+b4)*t+b3)*t+b2)*t+b1)*t;
    N = 1.0-b*N;
    if ( z < 0.0 ) N = 1.0 - N;
    return N;
    };

    // greeks calculation
    void option_price_partials_call_black_scholes( double S, // spot price
    double X, // Strike (exercise) price,
    double r, // interest rate
    double sigma, // volatility
    double time, // time to maturity
    double Delta, // partial wrt S
    double Gamma, // second prt wrt S
    double Theta, // partial wrt time
    double Vega, // partial wrt sigma
    double Rho){ // partial wrt r
    double time_sqrt = sqrt(time);
    double d1 = (log(S/X)+r*time)/(sigma*time_sqrt) + 0.5*sigma*time_sqrt;
    double d2 = d1-(sigma*time_sqrt);
    Delta = N(d1);
    Gamma = N(d1)/(S*sigma*time_sqrt);
    Theta =- (S*sigma*N(d1)) / (2*time_sqrt) - r*X*exp( -r*time)*N(d2);
    Vega = S * time_sqrt * N(d1);
    Rho = X * time * exp(-r * time) * N(d2);
    };

    int main (void) {

    double S = 0.0;
    double X = 0.0;
    double r = 0.0;
    double Sigma = 0.0;
    double time = 0.0;
    double Delta= 0.0;
    double Gamma= 0.0;
    double Theta= 0.0;
    double Vega= 0.0;
    double Rho= 0.0;

    printf("please enter the parameters S, X, r, Sigma, time:n");
    scanf("%lf %lf %lf %lf %lfn", &S, &X, &r, &Sigma, &time);
    printf("you entered: S=%f, X=%f,r=%f, Sigma=%f,time=%f",S, X, r, Sigma, time);

    option_price_partials_call_black_scholes(S, X, r, Sigma, time, Delta, Gamma, Theta, Vega, Rho);
    printf("results are: Delta=%f, Gamma=%f,Theta=%f, Vega=%f,Rho=%f",Delta, Gamma, Theta, Vega, Rho);

    }

    olmuyo yine olmuyo gibtiimin kodu yine olmuyo
    ···
   tümünü göster