Browse Source

Merge branch 'main' into feat/create-btn

pull/2456/head
Thomas Kaul 2 years ago
committed by GitHub
parent
commit
27fc9b02dc
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      CHANGELOG.md
  2. 8
      apps/api/src/app/benchmark/benchmark.service.ts
  3. 14
      apps/api/src/services/market-data/market-data.service.ts
  4. 1
      libs/common/src/lib/interfaces/benchmark.interface.ts

4
CHANGELOG.md

@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Extended the markets overview by benchmarks (date of last all time high)
### Changed
- Harmonized the style of the create button on the page for granting and revoking public access to share the portfolio
## 2.10.0 - 2023-10-09

8
apps/api/src/app/benchmark/benchmark.service.ts

@ -64,7 +64,7 @@ export class BenchmarkService {
const benchmarkAssetProfiles = await this.getBenchmarkAssetProfiles();
const promises: Promise<number>[] = [];
const promises: Promise<{ date: Date; marketPrice: number }>[] = [];
const quotes = await this.dataProviderService.getQuotes({
items: benchmarkAssetProfiles.map(({ dataSource, symbol }) => {
@ -85,15 +85,14 @@ export class BenchmarkService {
let performancePercentFromAllTimeHigh = 0;
if (allTimeHigh && marketPrice) {
if (allTimeHigh?.marketPrice && marketPrice) {
performancePercentFromAllTimeHigh = this.calculateChangeInPercentage(
allTimeHigh,
allTimeHigh.marketPrice,
marketPrice
);
} else {
storeInCache = false;
}
return {
marketCondition: this.getMarketCondition(
performancePercentFromAllTimeHigh
@ -101,6 +100,7 @@ export class BenchmarkService {
name: benchmarkAssetProfiles[index].name,
performances: {
allTimeHigh: {
date: allTimeHigh.date,
performancePercent: performancePercentFromAllTimeHigh
}
}

14
apps/api/src/services/market-data/market-data.service.ts

@ -39,18 +39,22 @@ export class MarketDataService {
});
}
public async getMax({ dataSource, symbol }: UniqueAsset): Promise<number> {
const aggregations = await this.prismaService.marketData.aggregate({
_max: {
public async getMax({ dataSource, symbol }: UniqueAsset) {
return this.prismaService.marketData.findFirst({
select: {
date: true,
marketPrice: true
},
orderBy: [
{
marketPrice: 'desc'
}
],
where: {
dataSource,
symbol
}
});
return aggregations._max.marketPrice;
}
public async getRange({

1
libs/common/src/lib/interfaces/benchmark.interface.ts

@ -5,6 +5,7 @@ export interface Benchmark {
name: EnhancedSymbolProfile['name'];
performances: {
allTimeHigh: {
date: Date;
performancePercent: number;
};
};

Loading…
Cancel
Save