Browse Source
Bugfix/fix get quotes for multiple ghostfolio symbols (#758)
* Support multiple symbols in getQuotes()
* Update changelog
pull/759/head
Thomas Kaul
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
25 additions and
12 deletions
-
CHANGELOG.md
-
apps/api/src/services/data-provider/ghostfolio-scraper-api/ghostfolio-scraper-api.service.ts
|
|
@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 |
|
|
|
|
|
|
|
- Improved the error handling in the scraper configuration |
|
|
|
|
|
|
|
### Fixed |
|
|
|
|
|
|
|
- Fixed the support for multiple symbols of the data source `GHOSTFOLIO` |
|
|
|
|
|
|
|
## 1.126.0 - 14.03.2022 |
|
|
|
|
|
|
|
### Added |
|
|
|
|
|
@ -84,33 +84,42 @@ export class GhostfolioScraperApiService implements DataProviderInterface { |
|
|
|
public async getQuotes( |
|
|
|
aSymbols: string[] |
|
|
|
): Promise<{ [symbol: string]: IDataProviderResponse }> { |
|
|
|
const response: { [symbol: string]: IDataProviderResponse } = {}; |
|
|
|
|
|
|
|
if (aSymbols.length <= 0) { |
|
|
|
return {}; |
|
|
|
return response; |
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
const [symbol] = aSymbols; |
|
|
|
const [symbolProfile] = await this.symbolProfileService.getSymbolProfiles( |
|
|
|
[symbol] |
|
|
|
const symbolProfiles = await this.symbolProfileService.getSymbolProfiles( |
|
|
|
aSymbols |
|
|
|
); |
|
|
|
|
|
|
|
const { marketPrice } = await this.prismaService.marketData.findFirst({ |
|
|
|
const marketData = await this.prismaService.marketData.findMany({ |
|
|
|
distinct: ['symbol'], |
|
|
|
orderBy: { |
|
|
|
date: 'desc' |
|
|
|
}, |
|
|
|
take: aSymbols.length, |
|
|
|
where: { |
|
|
|
symbol |
|
|
|
symbol: { |
|
|
|
in: aSymbols |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
return { |
|
|
|
[symbol]: { |
|
|
|
marketPrice, |
|
|
|
currency: symbolProfile?.currency, |
|
|
|
for (const symbolProfile of symbolProfiles) { |
|
|
|
response[symbolProfile.symbol] = { |
|
|
|
currency: symbolProfile.currency, |
|
|
|
dataSource: this.getName(), |
|
|
|
marketPrice: marketData.find((marketDataItem) => { |
|
|
|
return marketDataItem.symbol === symbolProfile.symbol; |
|
|
|
}).marketPrice, |
|
|
|
marketState: MarketState.delayed |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
return response; |
|
|
|
} catch (error) { |
|
|
|
Logger.error(error, 'GhostfolioScraperApiService'); |
|
|
|
} |
|
|
|