-
Notifications
You must be signed in to change notification settings - Fork 0
/
Portfolio.h
35 lines (32 loc) · 1.34 KB
/
Portfolio.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#pragma once
#include <vector>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/io.hpp>
namespace MeanVarianceFrontier
{
class Portfolio
{
public:
Portfolio(unsigned int numberOfAssets, boost::numeric::ublas::matrix<double> covarianceMatrix, std::vector<double> expReturns, std::vector<double> variances);
std::vector<double> generateRandomWeights();
double computeMeanWith(std::vector<double> portfolioWeights);
double computeVarianceWith(std::vector<double> portfolioWeights);
const boost::numeric::ublas::matrix<double> getCovarianceMatrix();
const boost::numeric::ublas::vector<double> getExpReturnsVector();
private:
double fRand(double fMin, double fMax);
private:
struct PortfolioMeanVariance
{
PortfolioMeanVariance(unsigned int nmbrOfAssets) : numberOfAssets{ nmbrOfAssets } {}
unsigned int numberOfAssets;
std::vector<double> portfolioWeights;
double portfolioMeanReturn;
double portfolioVariance;
} m_portfolioMeanVariance;
boost::numeric::ublas::matrix<double> m_covarianceMatrix;
boost::numeric::ublas::vector<double> m_expReturnsVector;
boost::numeric::ublas::vector<double> m_returnsVarianceVector;
};
}