Example #1
0
        public static void Run()
        {
            List<Position> list = new List<Position>();

            /*
            list.Add(new Position());
            list.Add(new Position("bond"));
            list.Add(new Position("stock"));
             * */
            Portfolio p = new Portfolio();

            double[] returns = {0.000, 0.13, -0.13};
            DenseVector returns1 = new DenseVector(returns);

            double[] stdev = {0, 7.4, 7.4};
            double[,] covariance = {{1, -.4, -.45}, {-.4, 1, .35}, {-0.45, 0.35, 1}};

            DenseMatrix covariance1 = StatisticsExtension.CorrelationToCovariance(new DenseMatrix(covariance),
                                                                                  new DenseVector(stdev));


            PortfolioOptimizer po = new PortfolioOptimizer(p, .09002, covariance1, returns1);
            po.BuildRiskModel();
            Console.ReadLine();
        }
Example #2
0
        public static void Run()
        {
            List <Position> list = new List <Position>();

            /*
             * list.Add(new Position());
             * list.Add(new Position("bond"));
             * list.Add(new Position("stock"));
             * */
            Portfolio p = new Portfolio();

            double[]    returns  = { 0.000, 0.13, -0.13 };
            DenseVector returns1 = new DenseVector(returns);

            double[] stdev = { 0, 7.4, 7.4 };
            double[,] covariance = { { 1, -.4, -.45 }, { -.4, 1, .35 }, { -0.45, 0.35, 1 } };

            DenseMatrix covariance1 = StatisticsExtension.CorrelationToCovariance(new DenseMatrix(covariance),
                                                                                  new DenseVector(stdev));


            PortfolioOptimizer po = new PortfolioOptimizer(p, .09002, covariance1, returns1);

            po.BuildRiskModel();
            Console.ReadLine();
        }