Browse Source
Merge branch 'main' into feature/improve-currency-validation-in-get-asset-profiles-functionality-of-data-provider-service
pull/5747/head
Thomas Kaul
3 weeks ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with
42 additions and
26 deletions
-
CHANGELOG.md
-
apps/api/src/services/data-provider/data-provider.service.ts
-
apps/api/src/services/data-provider/financial-modeling-prep/financial-modeling-prep.service.ts
-
libs/common/src/lib/helper.ts
-
package-lock.json
-
package.json
|
|
|
@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 |
|
|
|
|
|
|
|
- Disabled the zoom functionality in the _Progressive Web App_ (PWA) |
|
|
|
- Improved the currency validation in the get asset profiles functionality of the data provider service |
|
|
|
- Improved the currency validation in the search functionality of the data provider service |
|
|
|
- Optimized the get quotes functionality by utilizing the asset profile resolutions in the _Financial Modeling Prep_ service |
|
|
|
- Extracted the footer to a component |
|
|
|
|
|
|
|
|
|
|
|
@ -653,8 +653,11 @@ export class DataProviderService implements OnModuleInit { |
|
|
|
|
|
|
|
const filteredItems = lookupItems |
|
|
|
.filter(({ currency }) => { |
|
|
|
// Only allow symbols with supported currency
|
|
|
|
return currency ? true : false; |
|
|
|
if (includeIndices) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
return currency ? isCurrency(currency) : false; |
|
|
|
}) |
|
|
|
.map((lookupItem) => { |
|
|
|
if (this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION')) { |
|
|
|
|
|
|
|
@ -377,26 +377,42 @@ export class FinancialModelingPrepService implements DataProviderInterface { |
|
|
|
{ |
|
|
|
signal: AbortSignal.timeout(requestTimeout) |
|
|
|
} |
|
|
|
).then((res) => res.json()) |
|
|
|
).then( |
|
|
|
(res) => res.json() as unknown as { price: number; symbol: string }[] |
|
|
|
) |
|
|
|
]); |
|
|
|
|
|
|
|
if (assetProfileResolutions.length === symbols.length) { |
|
|
|
for (const { currency, symbolTarget } of assetProfileResolutions) { |
|
|
|
currencyBySymbolMap[symbolTarget] = { currency }; |
|
|
|
} |
|
|
|
} else { |
|
|
|
|
|
|
|
const resolvedSymbols = assetProfileResolutions.map( |
|
|
|
({ symbolTarget }) => { |
|
|
|
return symbolTarget; |
|
|
|
} |
|
|
|
); |
|
|
|
|
|
|
|
const symbolsToFetch = quotes |
|
|
|
.map(({ symbol }) => { |
|
|
|
return symbol; |
|
|
|
}) |
|
|
|
.filter((symbol) => { |
|
|
|
return !resolvedSymbols.includes(symbol); |
|
|
|
}); |
|
|
|
|
|
|
|
if (symbolsToFetch.length > 0) { |
|
|
|
await Promise.all( |
|
|
|
quotes.map(({ symbol }) => { |
|
|
|
return this.getAssetProfile({ |
|
|
|
symbolsToFetch.map(async (symbol) => { |
|
|
|
const assetProfile = await this.getAssetProfile({ |
|
|
|
requestTimeout, |
|
|
|
symbol |
|
|
|
}).then((assetProfile) => { |
|
|
|
}); |
|
|
|
|
|
|
|
if (assetProfile?.currency) { |
|
|
|
currencyBySymbolMap[symbol] = { |
|
|
|
currency: assetProfile.currency |
|
|
|
}; |
|
|
|
} |
|
|
|
}); |
|
|
|
}) |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
@ -1,7 +1,7 @@ |
|
|
|
import * as currencies from '@dinero.js/currencies'; |
|
|
|
import { NumberParser } from '@internationalized/number'; |
|
|
|
import { Type as ActivityType, DataSource, MarketData } from '@prisma/client'; |
|
|
|
import { Big } from 'big.js'; |
|
|
|
import { isISO4217CurrencyCode } from 'class-validator'; |
|
|
|
import { |
|
|
|
getDate, |
|
|
|
getMonth, |
|
|
|
@ -340,8 +340,12 @@ export function interpolate(template: string, context: any) { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
export function isCurrency(aCurrency = '') { |
|
|
|
return currencies[aCurrency] || isDerivedCurrency(aCurrency); |
|
|
|
export function isCurrency(aCurrency: string) { |
|
|
|
if (!aCurrency) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
return isISO4217CurrencyCode(aCurrency) || isDerivedCurrency(aCurrency); |
|
|
|
} |
|
|
|
|
|
|
|
export function isDerivedCurrency(aCurrency: string) { |
|
|
|
|
|
|
|
@ -28,7 +28,6 @@ |
|
|
|
"@dfinity/candid": "0.15.7", |
|
|
|
"@dfinity/identity": "0.15.7", |
|
|
|
"@dfinity/principal": "0.15.7", |
|
|
|
"@dinero.js/currencies": "2.0.0-alpha.8", |
|
|
|
"@internationalized/number": "3.6.3", |
|
|
|
"@ionic/angular": "8.7.3", |
|
|
|
"@keyv/redis": "4.4.0", |
|
|
|
@ -5018,12 +5017,6 @@ |
|
|
|
"ts-node": "^10.8.2" |
|
|
|
} |
|
|
|
}, |
|
|
|
"node_modules/@dinero.js/currencies": { |
|
|
|
"version": "2.0.0-alpha.8", |
|
|
|
"resolved": "https://registry.npmjs.org/@dinero.js/currencies/-/currencies-2.0.0-alpha.8.tgz", |
|
|
|
"integrity": "sha512-zApiqtuuPwjiM9LJA5/kNcT48VSHRiz2/mktkXjIpfxrJKzthXybUAgEenExIH6dYhLDgVmsLQZtZFOsdYl0Ag==", |
|
|
|
"license": "MIT" |
|
|
|
}, |
|
|
|
"node_modules/@discoveryjs/json-ext": { |
|
|
|
"version": "0.6.3", |
|
|
|
"resolved": "https://registry.npmjs.org/@discoveryjs/json-ext/-/json-ext-0.6.3.tgz", |
|
|
|
|
|
|
|
@ -74,7 +74,6 @@ |
|
|
|
"@dfinity/candid": "0.15.7", |
|
|
|
"@dfinity/identity": "0.15.7", |
|
|
|
"@dfinity/principal": "0.15.7", |
|
|
|
"@dinero.js/currencies": "2.0.0-alpha.8", |
|
|
|
"@internationalized/number": "3.6.3", |
|
|
|
"@ionic/angular": "8.7.3", |
|
|
|
"@keyv/redis": "4.4.0", |
|
|
|
|