eslint
This commit is contained in:
parent
d85cd58acd
commit
597c6efc9b
91 changed files with 2224 additions and 1400 deletions
|
|
@ -209,7 +209,7 @@ export function riskParityOptimization(covarianceMatrix: number[][]): PortfolioO
|
|||
const sum = newWeights.reduce((s, w) => s + w, 0);
|
||||
weights = newWeights.map(w => w / sum);
|
||||
|
||||
if (converged) break;
|
||||
if (converged) {break;}
|
||||
}
|
||||
|
||||
const portfolioVariance = calculatePortfolioVariance(weights, covarianceMatrix);
|
||||
|
|
@ -402,7 +402,7 @@ export function calculateEfficientFrontier(
|
|||
volatility: number;
|
||||
sharpeRatio: number;
|
||||
}> {
|
||||
if (returns.length !== symbols.length || returns.length < 2) return [];
|
||||
if (returns.length !== symbols.length || returns.length < 2) {return [];}
|
||||
|
||||
const n = returns.length;
|
||||
const results: Array<{
|
||||
|
|
@ -456,7 +456,7 @@ export function findMinimumVariancePortfolio(
|
|||
returns: number[][],
|
||||
symbols: string[]
|
||||
): PortfolioOptimizationResult | null {
|
||||
if (returns.length !== symbols.length || returns.length < 2) return null;
|
||||
if (returns.length !== symbols.length || returns.length < 2) {return null;}
|
||||
|
||||
const covarianceMatrix = calculateCovarianceMatrix(returns);
|
||||
const n = returns.length;
|
||||
|
|
@ -517,7 +517,7 @@ function calculateCovarianceMatrix(returns: number[][]): number[][] {
|
|||
}
|
||||
|
||||
function calculateCovariance(x: number[], y: number[]): number {
|
||||
if (x.length !== y.length || x.length < 2) return 0;
|
||||
if (x.length !== y.length || x.length < 2) {return 0;}
|
||||
|
||||
const n = x.length;
|
||||
const meanX = x.reduce((sum, val) => sum + val, 0) / n;
|
||||
|
|
@ -559,7 +559,7 @@ function findMinimumVarianceWeights(
|
|||
const currentReturn = weights.reduce((sum, w, i) => sum + w * expectedReturns[i], 0);
|
||||
const returnDiff = targetReturn - currentReturn;
|
||||
|
||||
if (Math.abs(returnDiff) < 0.001) break;
|
||||
if (Math.abs(returnDiff) < 0.001) {break;}
|
||||
|
||||
// Adjust weights proportionally to expected returns
|
||||
const totalExpectedReturn = expectedReturns.reduce((sum, r) => sum + Math.abs(r), 0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue