Browse Source

Task/filter out sectors with zero weight in Yahoo Finance data enhancer (#6895)

* Filter out sectors with zero weight

* Update changelog
pull/6919/head
Thomas Kaul 2 days ago
committed by GitHub
parent
commit
db1cb4e681
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 20
      apps/api/src/services/data-provider/data-enhancer/yahoo-finance/yahoo-finance.service.ts

1
CHANGELOG.md

@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Improved the pagination in the activities table of the account detail dialog
- Improved the pagination in the activities table of the holding detail dialog
- Randomized the placeholder in the assistant
- Filtered out sectors with zero weight for ETF and mutual fund assets in the _Yahoo Finance_ data enhancer
- Enabled the _Bull Dashboard_ in the admin control panel without requiring an environment variable (experimental)
- Relaxed the URL validation in the asset profile DTOs to accept both `HTTP` and `HTTPS` protocols
- Relaxed the URL validation in the platform DTOs to accept both `HTTP` and `HTTPS` protocols

20
apps/api/src/services/data-provider/data-enhancer/yahoo-finance/yahoo-finance.service.ts

@ -218,16 +218,18 @@ export class YahooFinanceDataEnhancerService implements DataEnhancerInterface {
};
}) ?? [];
response.sectors = (
assetProfile.topHoldings?.sectorWeightings ?? []
).flatMap((sectorWeighting) => {
return Object.entries(sectorWeighting).map(([sector, weight]) => {
return {
name: this.parseSector(sector),
weight: weight as number
};
response.sectors = (assetProfile.topHoldings?.sectorWeightings ?? [])
.flatMap((sectorWeighting) => {
return Object.entries(sectorWeighting).map(([sector, weight]) => {
return {
name: this.parseSector(sector),
weight: weight as number
};
});
})
.filter(({ weight }) => {
return weight > 0;
});
});
} else if (
assetSubClass === 'STOCK' &&
assetProfile.summaryProfile?.country

Loading…
Cancel
Save