Browse Source

Add missing data to position from the past

pull/261/head
Thomas 4 years ago
parent
commit
0ed5c3786c
  1. 18
      apps/api/src/app/portfolio/portfolio.service.ts
  2. 2
      apps/client/src/app/components/position/position-detail-dialog/position-detail-dialog.html

18
apps/api/src/app/portfolio/portfolio.service.ts

@ -391,6 +391,7 @@ export class PortfolioService {
};
} else {
const currentData = await this.dataProviderService.get([aSymbol]);
const marketPrice = currentData[aSymbol]?.marketPrice;
let historicalData = await this.dataProviderService.getHistorical(
[aSymbol],
@ -408,6 +409,8 @@ export class PortfolioService {
}
const historicalDataArray: HistoricalDataItem[] = [];
let maxPrice = marketPrice;
let minPrice = marketPrice;
for (const [date, { marketPrice }] of Object.entries(
historicalData[aSymbol]
@ -416,20 +419,23 @@ export class PortfolioService {
date,
value: marketPrice
});
maxPrice = Math.max(marketPrice ?? 0, maxPrice);
minPrice = Math.min(marketPrice ?? Number.MAX_SAFE_INTEGER, minPrice);
}
return {
averagePrice: undefined,
marketPrice,
maxPrice,
minPrice,
averagePrice: 0,
currency: currentData[aSymbol]?.currency,
firstBuyDate: undefined,
grossPerformance: undefined,
grossPerformancePercent: undefined,
historicalData: historicalDataArray,
investment: undefined,
marketPrice: currentData[aSymbol]?.marketPrice,
maxPrice: undefined,
minPrice: undefined,
quantity: undefined,
investment: 0,
quantity: 0,
symbol: aSymbol,
transactionCount: undefined
};

2
apps/client/src/app/components/position/position-detail-dialog/position-detail-dialog.html

@ -1,7 +1,7 @@
<gf-dialog-header
mat-dialog-title
[deviceType]="data.deviceType"
[title]="data.title"
[title]="data.title ?? data.symbol"
(closeButtonClicked)="onClose()"
></gf-dialog-header>

Loading…
Cancel
Save