Browse Source

Bugfix/market data storage in data provider service (#7814)

* Fix storage of market data to store only newly fetched quotes

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

1
CHANGELOG.md

@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ### Fixed
- Fixed the data provider information in the holding detail dialog - Fixed the data provider information in the holding detail dialog
- Fixed the storage of the market data in the data provider service to only include the newly fetched quotes
- Fixed the immediate expiration of a portfolio snapshot with errors - Fixed the immediate expiration of a portfolio snapshot with errors
- Fixed the missing country mapping of _Congo (Dem. Rep. of the)_ and _Congo (Rep. of)_ in the _Financial Modeling Prep_ service - Fixed the missing country mapping of _Congo (Dem. Rep. of the)_ and _Congo (Rep. of)_ in the _Financial Modeling Prep_ service

24
apps/api/src/services/data-provider/data-provider.service.ts

@ -725,6 +725,10 @@ export class DataProviderService implements OnModuleInit {
promises.push( promises.push(
promise.then(async (result) => { promise.then(async (result) => {
const fetchedQuotes: (DataProviderResponse & {
symbol: string;
})[] = [];
for (const [symbol, dataProviderResponse] of Object.entries( for (const [symbol, dataProviderResponse] of Object.entries(
result result
)) { )) {
@ -739,12 +743,16 @@ export class DataProviderService implements OnModuleInit {
continue; continue;
} }
const quote = { ...dataProviderResponse, symbol };
fetchedQuotes.push(quote);
response[ response[
getAssetProfileIdentifier({ getAssetProfileIdentifier({
symbol, symbol,
dataSource: DataSource[dataSource] dataSource: DataSource[dataSource]
}) })
] = { ...dataProviderResponse, symbol }; ] = quote;
this.redisCacheService.set( this.redisCacheService.set(
this.redisCacheService.getQuoteKey({ this.redisCacheService.getQuoteKey({
@ -772,15 +780,19 @@ export class DataProviderService implements OnModuleInit {
marketState: 'open' marketState: 'open'
}; };
const derivedQuote = {
...derivedDataProviderResponse,
symbol: `${DEFAULT_CURRENCY}${currency}`
};
fetchedQuotes.push(derivedQuote);
response[ response[
getAssetProfileIdentifier({ getAssetProfileIdentifier({
dataSource: DataSource[dataSource], dataSource: DataSource[dataSource],
symbol: `${DEFAULT_CURRENCY}${currency}` symbol: `${DEFAULT_CURRENCY}${currency}`
}) })
] = { ] = derivedQuote;
...derivedDataProviderResponse,
symbol: `${DEFAULT_CURRENCY}${currency}`
};
this.redisCacheService.set( this.redisCacheService.set(
this.redisCacheService.getQuoteKey({ this.redisCacheService.getQuoteKey({
@ -805,7 +817,7 @@ export class DataProviderService implements OnModuleInit {
try { try {
await this.marketDataService.updateMany({ await this.marketDataService.updateMany({
data: Object.values(response) data: fetchedQuotes
.filter(({ marketPrice, marketState }) => { .filter(({ marketPrice, marketState }) => {
return ( return (
isNumber(marketPrice) && isNumber(marketPrice) &&

Loading…
Cancel
Save