Esempio n. 1
0
        static public double CalcDeltaValue(
            InitialTerm.InitialParameter param,
            double forward,
            double strike,
            double volatility,
            InitialTerm.CallPutType type,
            InitialTerm.DeltaType deltaType)
        {
            var d1 = DFuncCalculator.CalcDValue(param, volatility, param.tau, forward, strike);
            var d2 = d1 - volatility * Math.Sqrt(param.tau);


            switch (deltaType)
            {
            case InitialTerm.DeltaType.PipsSpotDelta:
                return((int)type
                       * Math.Exp(-param.rateOfForeign * param.tau) * CDF((int)type * d1));

            case InitialTerm.DeltaType.PercentageSpotDelta:
                return((int)type
                       * Math.Exp(-param.rateOfDomestic * param.tau) * strike
                       / param.spotRate * CDF((int)type * d2));

            default:
                return(0.0);
            }
        }
Esempio n. 2
0
        static public double CalcStrike(
            InitialTerm.InitialParameter param,
            double forward,
            double volatility,
            InitialTerm.DeltaType deltaType,
            InitialTerm.VolatilityType volatilityType)
        {
            switch (volatilityType)
            {
            case InitialTerm.VolatilityType.ATM:
                return(CalcAtmStrike(param, forward, volatility, deltaType));

            case InitialTerm.VolatilityType.MS25Call:
                return(CalcInvCdf(
                           param, volatility, forward, 0.25, Type, deltaType));

            case InitialTerm.VolatilityType.MS25Put:
                return(CalcInvCdf(
                           param, volatility, forward, -0.25, Type, deltaType));

            case InitialTerm.VolatilityType.MS10Call:
                return(CalcInvCdf(
                           param, volatility, forward, 0.1, Type, deltaType));

            case InitialTerm.VolatilityType.MS10Put:
                return(CalcInvCdf(
                           param, volatility, forward, -0.1, Type, deltaType));

            default:
                return(0);
            }
        }
Esempio n. 3
0
        private static double CalcAtmStrike(
            InitialTerm.InitialParameter param,
            double forward,
            double volatility,
            InitialTerm.DeltaType deltaType)
        {
            double strike = 0.0;

            if (deltaType == InitialTerm.DeltaType.PipsSpotDelta ||
                deltaType == InitialTerm.DeltaType.PercentageForwardDelta)
            {
                strike = forward * Math.Exp(volatility * volatility * param.tau / 2.0);
            }
            else
            {
                strike = forward * Math.Exp(-volatility * volatility * param.tau / 2.0);
            }
            return(strike);
        }
Esempio n. 4
0
        public static double CalcInvCdf(
            InitialTerm.InitialParameter param,
            double volatility,
            double forward,
            double delta,
            InitialTerm.CallPutType type,
            InitialTerm.DeltaType deltaType)
        {
            Volatility = volatility;
            Forward    = forward;
            DeltaType  = deltaType;
            Number     = delta;

            var strikeCalculator = new StrikrCalcultor(param);

            return(UseBisection.Calc(
                       strikeCalculator.DeltaFunctionOfStrike,
                       0.5 * param.spotRate,
                       2.0 * param.spotRate));
        }