Browse Source

Merge 7c39ed2a63 into 82cee20f2d

pull/7925/merge
Suraj2105-1 17 hours ago
committed by GitHub
parent
commit
97dbf8fc46
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 28
      apps/api/src/app/portfolio/calculator/portfolio-calculator.ts
  2. 62
      eslint.config.cjs
  3. 3
      package.json

28
apps/api/src/app/portfolio/calculator/portfolio-calculator.ts

@ -319,6 +319,10 @@ export abstract class PortfolioCalculator {
[date: string]: { [assetProfileIdentifier: string]: Big }; [date: string]: { [assetProfileIdentifier: string]: Big };
} = {}; } = {};
const latestMarketPriceMap: {
[assetProfileIdentifier: string]: { date: string; price: Big };
} = {};
for (const marketSymbol of marketSymbols) { for (const marketSymbol of marketSymbols) {
const date = format(marketSymbol.date, DATE_FORMAT); const date = format(marketSymbol.date, DATE_FORMAT);
@ -327,13 +331,33 @@ export abstract class PortfolioCalculator {
} }
if (marketSymbol.marketPrice) { if (marketSymbol.marketPrice) {
marketSymbolMap[date][getAssetProfileIdentifier(marketSymbol)] = const identifier = getAssetProfileIdentifier(marketSymbol);
new Big(marketSymbol.marketPrice); const price = new Big(marketSymbol.marketPrice);
marketSymbolMap[date][identifier] = price;
if (
!latestMarketPriceMap[identifier] ||
latestMarketPriceMap[identifier].date < date
) {
latestMarketPriceMap[identifier] = { date, price };
}
} }
} }
const endDateString = format(this.endDate, DATE_FORMAT); const endDateString = format(this.endDate, DATE_FORMAT);
if (!marketSymbolMap[endDateString]) {
marketSymbolMap[endDateString] = {};
}
for (const identifier of Object.keys(latestMarketPriceMap)) {
if (!marketSymbolMap[endDateString][identifier]) {
marketSymbolMap[endDateString][identifier] =
latestMarketPriceMap[identifier].price;
}
}
const daysInMarket = differenceInDays(this.endDate, this.startDate); const daysInMarket = differenceInDays(this.endDate, this.startDate);
const chartDateMap = this.getChartDateMap({ const chartDateMap = this.getChartDateMap({

62
eslint.config.cjs

@ -1,19 +1,14 @@
const { FlatCompat } = require('@eslint/eslintrc'); const nx = require('@nx/eslint-plugin');
const js = require('@eslint/js');
const nxEslintPlugin = require('@nx/eslint-plugin');
const storybook = require('eslint-plugin-storybook'); const storybook = require('eslint-plugin-storybook');
const tseslint = require('typescript-eslint');
const importPlugin = require('eslint-plugin-import');
const compat = new FlatCompat({ module.exports = tseslint.config(
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended
});
module.exports = [
{ {
ignores: ['**/dist'] ignores: ['**/dist']
}, },
...storybook.configs['flat/recommended'], ...storybook.configs['flat/recommended'],
{ plugins: { '@nx': nxEslintPlugin } }, { plugins: { '@nx': nx } },
{ {
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'], files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
rules: { rules: {
@ -35,41 +30,30 @@ module.exports = [
'no-extra-semi': 'off' 'no-extra-semi': 'off'
} }
}, },
...compat ...nx.configs['flat/typescript'].map((config) => ({
.config({
extends: ['plugin:@nx/typescript']
})
.map((config) => ({
...config, ...config,
files: ['**/*.ts', '**/*.tsx', '**/*.cts', '**/*.mts'], files: ['**/*.ts', '**/*.tsx', '**/*.cts', '**/*.mts'],
rules: {
...config.rules
}
})), })),
...compat ...nx.configs['flat/javascript'].map((config) => ({
.config({
extends: ['plugin:@nx/javascript']
})
.map((config) => ({
...config, ...config,
files: ['**/*.js', '**/*.jsx', '**/*.cjs', '**/*.mjs'], files: ['**/*.js', '**/*.jsx', '**/*.cjs', '**/*.mjs'],
rules: {
...config.rules
}
})), })),
...compat {
.config({
plugins: ['eslint-plugin-import', '@typescript-eslint'],
extends: [
'plugin:@typescript-eslint/recommended-type-checked',
'plugin:@typescript-eslint/stylistic-type-checked'
]
})
.map((config) => ({
...config,
files: ['**/*.ts'], files: ['**/*.ts'],
extends: [
...tseslint.configs.recommendedTypeChecked,
...tseslint.configs.stylisticTypeChecked
],
plugins: {
import: importPlugin
},
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: __dirname
}
},
rules: { rules: {
...config.rules,
'@typescript-eslint/consistent-indexed-object-style': 'off', '@typescript-eslint/consistent-indexed-object-style': 'off',
'@typescript-eslint/dot-notation': 'off', '@typescript-eslint/dot-notation': 'off',
'@typescript-eslint/explicit-member-accessibility': [ '@typescript-eslint/explicit-member-accessibility': [
@ -190,5 +174,5 @@ module.exports = [
// and can be remove once solved // and can be remove once solved
'@typescript-eslint/prefer-nullish-coalescing': 'warn' // TODO: Requires strictNullChecks: true '@typescript-eslint/prefer-nullish-coalescing': 'warn' // TODO: Requires strictNullChecks: true
} }
})) }
]; );

3
package.json

@ -166,8 +166,6 @@
"@angular/language-service": "22.1.2", "@angular/language-service": "22.1.2",
"@angular/localize": "22.1.2", "@angular/localize": "22.1.2",
"@angular/pwa": "22.1.4", "@angular/pwa": "22.1.4",
"@eslint/eslintrc": "3.3.1",
"@eslint/js": "9.35.0",
"@nestjs/schematics": "11.1.0", "@nestjs/schematics": "11.1.0",
"@nestjs/testing": "11.2.3", "@nestjs/testing": "11.2.3",
"@nx/angular": "23.1.1", "@nx/angular": "23.1.1",
@ -221,6 +219,7 @@
"ts-node": "10.9.2", "ts-node": "10.9.2",
"tslib": "2.8.1", "tslib": "2.8.1",
"typescript": "6.0.3", "typescript": "6.0.3",
"typescript-eslint": "8.67.0",
"webpack-cli": "7.1.0" "webpack-cli": "7.1.0"
}, },
"engines": { "engines": {

Loading…
Cancel
Save