示例#1
0
        // It's a good idea to make cash the last item in the correlation matrix -- we're going to be doing (essentially) a least-squares
        // solution, so anything we can't neutralise will end up as an exposure in the last asset.
        public MarketNeutralAllocation(double[,] Correlations)
        {
            NumAssets = Correlations.GetLength(0);

            // It would be a good idea to sort this matrix to put cash at the end...
            var corr = MathNet.Numerics.LinearAlgebra.Matrix.Create(Correlations);

            MathNet.Numerics.LinearAlgebra.CholeskyDecomposition cd = new MathNet.Numerics.LinearAlgebra.CholeskyDecomposition(corr);

            Cholesky = cd.GetL().GetArray();
        }
示例#2
0
        bool CashIsRiskLess;                                                        // Good to have one risk-less asset if possible...better results.


        public RiskParityAllocation(double[] Volatilities, double[,] Correlations, bool cashIsRiskLess)
        {
            Vols           = Volatilities;
            Corrs          = Correlations;
            CashIsRiskLess = cashIsRiskLess;
            NumAssets      = Volatilities.Length;

            var corr = MathNet.Numerics.LinearAlgebra.Matrix.Create(Correlations);

            MathNet.Numerics.LinearAlgebra.CholeskyDecomposition cd = new MathNet.Numerics.LinearAlgebra.CholeskyDecomposition(corr);

            Cholesky = cd.GetL().GetArray();

            // Initialise DE.
            Initialise(NumAssets, 1000, 0.5, 0.5);
        }