fix position diagram for sold items (#261)

* fix position diagram for sold items

* Add missing data to position from the past

* Update changelog

Co-authored-by: Valentin Zickner <github@zickner.ch>
Co-authored-by: Thomas <4159106+dtslvr@users.noreply.github.com>
pull/263/head
Valentin Zickner 4 years ago committed by GitHub
parent ba3b4564cd
commit 218efbb5bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ### Fixed
- Fixed an issue with the currency conversion of the market price in the position detail dialog - Fixed an issue with the currency conversion of the market price in the position detail dialog
- Fixed the chart and missing data of positions from the past in the position detail dialog
## 1.33.0 - 05.08.2021 ## 1.33.0 - 05.08.2021

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

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

Loading…
Cancel
Save