Exemplo 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);
            }
        }
Exemplo n.º 2
0
        public static List <double> PriceSetting(InitialTerm.InitialParameter param)
        {
            var priceList = new List <double>();
            var forward   = ForwardCalculator.CalcForwardRate(param);

            foreach (InitialTerm.VolatilityType volatilityType
                     in Enum.GetValues(typeof(InitialTerm.VolatilityType)))
            {
                var type       = JudgeMaterial.JudgeOfCallPut.CallOrPut(volatilityType);
                var volatility = JudgeMaterial.JudgeOfVolatility.Volatility(param, volatilityType);
                var strike     = StrikrCalcultor.CalcStrike(param, forward, volatility, param.deltaType, volatilityType);
                var d1         = DFuncCalculator.CalcDValue(param, volatility, param.tau, forward, strike);
                var d2         = d1 - volatility * Math.Sqrt(param.tau);
                priceList.Add(FlyAdjustment.PriceCalculator.CalcOptionPrice(param, forward, strike, d1, d2, type));
            }
            return(priceList);
        }
Exemplo n.º 3
0
        private static double CalcValueTrial(Vector <double> vec)
        {
            var K25CallMS = StrikeList[3];
            var K25PutMS  = StrikeList[1];
            var parameter = Vector <double> .Build.DenseOfArray(new double[] { vec[0], vec[1], vec[2] });

            var vol25Call = VolCalculator(K25CallMS, VolParameter);
            var vol25Put  = VolCalculator(K25PutMS, VolParameter);

            var d1Call = DFuncCalculator.CalcDValue(
                Param,
                vol25Call,
                Param.tau,
                Forward,
                K25CallMS);
            var d2Call = d1Call - vol25Call * Math.Sqrt(Param.tau);
            var d1Put  = DFuncCalculator.CalcDValue(
                Param,
                vol25Put,
                Param.tau,
                Forward,
                K25PutMS);
            var d2Put = d1Put - vol25Put * Math.Sqrt(Param.tau);

            return(PriceCalculator.CalcOptionPrice(
                       Param,
                       Forward,
                       K25CallMS,
                       d1Call,
                       d2Call,
                       InitialTerm.CallPutType.call)
                   + PriceCalculator.CalcOptionPrice(
                       Param,
                       Forward,
                       K25PutMS,
                       d1Put,
                       d2Put,
                       InitialTerm.CallPutType.put));
        }