Example #1
0
        static void Main(string[] args)
        {
            //Mediator med = new Mediator();
            //med.calculate();

            //Console.ReadLine();

            //convertible bond with option on equity basket chapter 7
            Vector <double>        pricesVector      = new Vector <double>(new double[] { 1, 2 }, 0);
            Vector <double>        weightsVector     = new Vector <double>(new double[] { 1, 2 }, 0);
            Vector <double>        volatilityVector  = new Vector <double>(new double[] { 1, 2 }, 0);
            NumericMatrix <double> correlationMatrix = new NumericMatrix <double>(2, 2, 0, 0);

            correlationMatrix.setRow(new Array <double>(new double[] { 1, 2 }, 0), 0);
            correlationMatrix.setRow(new Array <double>(new double[] { 1, 2 }, 0), 1);

            Option o = new Option(OptionType.Put, 2, 2, 3, pricesVector, weightsVector, correlationMatrix, volatilityVector);

            Console.WriteLine(o.Price());

            //dual currency linked bonds with exchange option chapter 7
            Option exchangeOption = new Option(OptionType.Call, 2, 2, 2, 3, 0.5, 0.4, 1);

            Console.WriteLine(exchangeOption.Price());

            Console.ReadLine();
        }
Example #2
0
    public NumericMatrix <double> result()
    {
        // Initialise time.
        tnow = tprev = tarr[tarr.MinIndex];

        res.setRow(vecNew, tarr.MinIndex);

        // The state machine; we march from t = 0 to t = T.
        for (int n = tarr.MinIndex + 1; n <= tarr.MaxIndex; n++)
        {
            tnow = tarr[n];

            // The two methods that represent the variant parts
            // of the Template Method Pattern.
            calculateBC();
            calculate();

            // Add the current solution to the matrix of results.
            res.setRow(vecNew, n);

            tprev = tnow;
        }

        return(res);
    }
Example #3
0
    public NumericMatrix <double> result()
    {
        // The state machine; we march from t = 0 to t = T.
        for (int n = tarr.MinIndex + 1; n <= tarr.MaxIndex; n++)
        {
            tnow = tarr[n];

            // The two methods that represent the variant parts
            // of the Template Method Pattern.
            calculateBC();
            calculate();

            // Add the current solution to the matrix of results.
            res.setRow(vecNew, n);

            tprev = tnow;
            for (int j = vecNew.MinIndex; j <= vecNew.MaxIndex; j++)
            { // Combine in previous loop
                vecOld[j] = vecNew[j];
            }
        }

        return(res);
    }