Exemplo n.º 1
0
        public BtResult CalculateBtK1(double r, double sigma, double t, double K, double S, int n, double T)
        {
            BtResult bt = new BtResult();

            bt.IntegralPointD1 = _integralPoints.CalculateIntegralPointD1(K, K, r, sigma, t);
            bt.IntegralPointD2 = _integralPoints.CalculateIntegralPointD2(bt.IntegralPointD1, sigma, t);
            bt.Distribution    = _distribution.CumulativeDistribution(bt.IntegralPointD1.Result.Value);
            bt.a            = CalculateAValue(sigma, t);
            bt.Result.Value = CalculateBtK1(sigma, K, r, t, bt);

            return(bt);
        }
        public async Task <IntegralFunction> CalculateAsync(int n, double T, double r, double sigma, double t, double S, double K, BtResult Btksi)
        {
            IntegralFunction integralFunction = new IntegralFunction();

            UnderIntegral[] underIntegral = new UnderIntegral[n];

            for (int i = 0; i < n; i++)
            {
                UnderIntegral ui = new UnderIntegral();

                ui.h               = (T / n);
                ui.ksi             = i * ui.h;
                ui.IntegralPointD1 = _integralPoints.CalculateIntegralPointD1(S, Btksi.Result.Value, r, sigma, t - ui.ksi);
                ui.IntegralPointD2 = _integralPoints.CalculateIntegralPointD2(ui.IntegralPointD1, sigma, t - ui.ksi);
                ui.Distribution    = _distribution.CumulativeDistribution(-ui.IntegralPointD2.Result.Value);
                ui.Result.Value    = CalculateUnderIntegral(r, K, t, ui.ksi, ui.Distribution) * ui.h;

                underIntegral[i] = ui;
                integralFunction.Result.Value += ui.Result.Value;
            }

            integralFunction.UnderIntegral = underIntegral;

            return(integralFunction);
        }
Exemplo n.º 3
0
        public EuropeanPutResult Calculate(double K, double S, double r, double t, double sigma)
        {
            EuropeanPutResult ePut = new EuropeanPutResult();

            ePut.IntegralPointD1 = _integralPoints.CalculateIntegralPointD1(S, K, r, sigma, t);
            ePut.IntegralPointD2 = _integralPoints.CalculateIntegralPointD2(ePut.IntegralPointD1, sigma, t);
            ePut.Distribution1   = _distribution.CumulativeDistribution(-ePut.IntegralPointD1.Result.Value);
            ePut.Distribution2   = _distribution.CumulativeDistribution(-ePut.IntegralPointD2.Result.Value);
            ePut.Result.Value    = CalculateValue(K, S, r, t, ePut);

            return(ePut);
        }