Beispiel #1
0
        private static void FutureOptionPrice(DataForFutureOptionPrices data, double[] callSigma, double[] putSigma, double spotPrice,
                                              double interestRate, out double[] callPrice, out double[] putPrice)
        {
            int arrayLength      = data.DaysToExpiry.Length;
            int priceArrysLength = data.DaysToExpiry[arrayLength - 1];

            callPrice = new double[priceArrysLength];
            putPrice  = new double[priceArrysLength];

            for (int i = 0; i < arrayLength; i++)
            {
                int de = data.DaysToExpiry[i];
                callPrice[de - 1] = new BlackScholesModel(de, spotPrice, interestRate, spotPrice, 0, 0, 0, LegType.Call).GetEuroPrice(callSigma[i]);
                putPrice[de - 1]  = new BlackScholesModel(de, spotPrice, interestRate, spotPrice, 0, 0, 0, LegType.Put).GetEuroPrice(putSigma[i]);
            }

            int firstExpiry = data.DaysToExpiry[0];

            for (int i = 0; i < firstExpiry - 1; i++)
            {
                callPrice[i] = (i + 1) * callPrice[firstExpiry - 1] / firstExpiry;
                putPrice[i]  = (i + 1) * putPrice[firstExpiry - 1] / firstExpiry;
            }

            for (int i = 0; i < arrayLength - 1; i++)
            {
                int currExp = data.DaysToExpiry[i];
                int nextExp = data.DaysToExpiry[i + 1];
                for (int j = currExp; j < nextExp - 1; j++)
                {
                    callPrice[j] = DoLinearInterpolation(currExp, nextExp, callPrice[currExp - 1], callPrice[nextExp - 1], j + 1);
                    putPrice[j]  = DoLinearInterpolation(currExp, nextExp, putPrice[currExp - 1], putPrice[nextExp - 1], j + 1);
                }
            }
        }
Beispiel #2
0
        private static void StrikeInterpolation(DataForFutureOptionPrices data, double spotPrice, out double[] callSigma, out double[] putSigma)
        {
            int arrayLength = data.DaysToExpiry.Length;

            callSigma = new double[arrayLength];
            putSigma  = new double[arrayLength];
            for (int i = 0; i < arrayLength; i++)
            {
                callSigma[i] = DoLinearInterpolation(data.Strike1[i], data.Strike2[i], data.CallSigma1[i], data.CallSigma2[i], spotPrice);
                putSigma[i]  = DoLinearInterpolation(data.Strike1[i], data.Strike2[i], data.PutSigma1[i], data.PutSigma2[i], spotPrice);
            }
        }
Beispiel #3
0
        public static FutureOptionPrices GetFutureOptionPrices(double spotPrice, double interestRate, DataForFutureOptionPrices data)
        {
            double[] callSigma, putSigma;
            StrikeInterpolation(data, spotPrice, out callSigma, out putSigma);

            double[] callPrice, putPrice;
            FutureOptionPrice(data, callSigma, putSigma, spotPrice, interestRate, out callPrice, out putPrice);

            FutureOptionPrices result = new FutureOptionPrices();

            result.CurrentPlusCall = callPrice.Select(d => spotPrice + d).ToArray();
            result.CurrentMinusPut = putPrice.Select(d => spotPrice - d).ToArray();
            return(result);
        }