diff --git a/CHANGELOG.md b/CHANGELOG.md index df4791e24..1c03e17d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Changed + +- Skipped data enhancer (_Trackinsight_) if data is inaccurate + ### Fixed - Fixed an issue with countries in the symbol profile overrides diff --git a/apps/api/src/services/data-provider/data-enhancer/trackinsight/trackinsight.service.ts b/apps/api/src/services/data-provider/data-enhancer/trackinsight/trackinsight.service.ts index f61297368..8ebdb1dba 100644 --- a/apps/api/src/services/data-provider/data-enhancer/trackinsight/trackinsight.service.ts +++ b/apps/api/src/services/data-provider/data-enhancer/trackinsight/trackinsight.service.ts @@ -32,7 +32,7 @@ export class TrackinsightDataEnhancerService implements DataEnhancerInterface { return response; } - const holdings = await getJSON( + const result = await getJSON( `${TrackinsightDataEnhancerService.baseUrl}/${symbol}.json` ).catch(() => { return getJSON( @@ -42,12 +42,17 @@ export class TrackinsightDataEnhancerService implements DataEnhancerInterface { ); }); + if (result.weight < 0.95) { + // Skip if data is inaccurate + return response; + } + if ( !response.countries || (response.countries as unknown as Country[]).length === 0 ) { response.countries = []; - for (const [name, value] of Object.entries(holdings.countries)) { + for (const [name, value] of Object.entries(result.countries)) { let countryCode: string; for (const [key, country] of Object.entries( @@ -75,7 +80,7 @@ export class TrackinsightDataEnhancerService implements DataEnhancerInterface { (response.sectors as unknown as Sector[]).length === 0 ) { response.sectors = []; - for (const [name, value] of Object.entries(holdings.sectors)) { + for (const [name, value] of Object.entries(result.sectors)) { response.sectors.push({ name: TrackinsightDataEnhancerService.sectorsMapping[name] ?? name, weight: value.weight diff --git a/package.json b/package.json index 7db114e1b..a26addca5 100644 --- a/package.json +++ b/package.json @@ -77,7 +77,6 @@ "@simplewebauthn/server": "4.1.0", "@simplewebauthn/typescript-types": "4.0.0", "@stripe/stripe-js": "1.22.0", - "@types/papaparse": "5.2.6", "alphavantage": "2.2.0", "angular-material-css-vars": "3.0.0", "bent": "7.3.12", @@ -117,7 +116,6 @@ "rxjs": "7.4.0", "stripe": "8.199.0", "svgmap": "2.6.0", - "tslib": "2.0.0", "twitter-api-v2": "1.10.3", "uuid": "8.3.2", "yahoo-finance2": "2.3.2", @@ -156,6 +154,7 @@ "@types/jest": "27.4.1", "@types/lodash": "4.14.174", "@types/node": "14.14.33", + "@types/papaparse": "5.2.6", "@types/passport-google-oauth20": "2.0.11", "@typescript-eslint/eslint-plugin": "5.4.0", "@typescript-eslint/parser": "5.4.0", @@ -175,6 +174,7 @@ "prettier": "2.5.1", "replace-in-file": "6.2.0", "rimraf": "3.0.2", + "tslib": "2.0.0", "ts-jest": "27.1.4", "ts-node": "9.1.1", "typescript": "4.6.4"