-
Notifications
You must be signed in to change notification settings - Fork 36
Description
Hello @lequant40, I'm trying to use this library for a personal project and it's proving a very valuable learning exercise for understanding the relevant concepts in Portfolio Optimization space. Thanks a lot for making this resource open source!
I was hoping to get some clarification on a bug I'm running into while using method meanVarianceEfficientFrontierPortfolios from lib/allocation/mean-variance.js. Here are the details -
Describe the bug
Getting the following error while using the method meanVarianceEfficientFrontierPortfolios -
ReferenceError: lambda_e is not defined
at computeCornerPortfolios (portfolio_allocation.dist.js:15132:4)
at new MeanVarianceEfficientFrontierCla (portfolio_allocation.dist.js:14596:26)
at new MeanVarianceEfficientFrontierWrapper (portfolio_allocation.dist.js:16471:28)
at self.meanVarianceEfficientFrontierPortfolios (portfolio_allocation.dist.js:17353:23)
at getOptimalPortfolio (mvt-utils.ts?t=1699625436099:16:49)
at App.tsx?t=1699626061247:25:17
at commitHookEffectListMount (react-dom.development.js:23150:26)
at commitPassiveMountOnFiber (react-dom.development.js:24926:13)
at commitPassiveMountEffects_complete (react-dom.development.js:24891:9)
at commitPassiveMountEffects_begin (react-dom.development.js:24878:7)To Reproduce
I am trying to run this method on dummy data, like so -
let stockData = [[0.05, 0.01, 0.01], [0.1, -0.03, 0.05],]
let covMat = PortfolioAllocation.covarianceMatrix(stockData, {
assumeZeroMean: false,
}).toRowArray();
let returns = [];
for (let s_i = 0; s_i < stockData.length; s_i += 1) {
let R_i = PortfolioAllocation.returns(stockData[s_i]);
let returns_i = 1;
for (let s_i_t = 0; s_i_t < stockData[s_i].length - 1; s_i_t += 1) {
returns_i *= 1 + R_i[s_i_t];
}
returns.push(returns_i - 1);
}
let mvEfficientFrontier =
PortfolioAllocation.meanVarianceEfficientFrontierPortfolios(
returns,
covMat,
{ nbPortfolios: 10 }
);and got the aforementioned error.
Expected behavior
meanVarianceEfficientFrontierPortfolios method should return n portfolios (n=10 in this case) when called.
I would really appreciate it if you could look into this and provide some information. Thanks!