Thomas Kaul
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
16 additions and
12 deletions
-
apps/api/src/app/portfolio/portfolio-calculator.ts
-
apps/api/src/app/portfolio/portfolio.service.ts
|
|
@ -79,7 +79,9 @@ export class PortfolioCalculator { |
|
|
|
this.exchangeRateDataService = exchangeRateDataService; |
|
|
|
this.orders = orders; |
|
|
|
|
|
|
|
this.orders.sort((a, b) => a.date?.localeCompare(b.date)); |
|
|
|
this.orders.sort((a, b) => { |
|
|
|
return a.date?.localeCompare(b.date); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
public computeTransactionPoints() { |
|
|
@ -150,7 +152,9 @@ export class PortfolioCalculator { |
|
|
|
(transactionPointItem) => transactionPointItem.symbol !== order.symbol |
|
|
|
); |
|
|
|
newItems.push(currentTransactionPointItem); |
|
|
|
newItems.sort((a, b) => a.symbol?.localeCompare(b.symbol)); |
|
|
|
newItems.sort((a, b) => { |
|
|
|
return a.symbol?.localeCompare(b.symbol); |
|
|
|
}); |
|
|
|
if (lastDate !== currentDate || lastTransactionPoint === null) { |
|
|
|
lastTransactionPoint = { |
|
|
|
date: currentDate, |
|
|
@ -767,8 +771,8 @@ export class PortfolioCalculator { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return sortBy(investments, (investment) => { |
|
|
|
return investment.date; |
|
|
|
return sortBy(investments, ({ date }) => { |
|
|
|
return date; |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -349,8 +349,8 @@ export class PortfolioService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
investments = sortBy(investments, (investment) => { |
|
|
|
return investment.date; |
|
|
|
investments = sortBy(investments, ({ date }) => { |
|
|
|
return date; |
|
|
|
}); |
|
|
|
|
|
|
|
const startDate = this.getStartDate( |
|
|
@ -765,9 +765,9 @@ export class PortfolioService { |
|
|
|
const currentPositions = |
|
|
|
await portfolioCalculator.getCurrentPositions(portfolioStart); |
|
|
|
|
|
|
|
const position = currentPositions.positions.find( |
|
|
|
(item) => item.symbol === aSymbol |
|
|
|
); |
|
|
|
const position = currentPositions.positions.find(({ symbol }) => { |
|
|
|
return symbol === aSymbol; |
|
|
|
}); |
|
|
|
|
|
|
|
if (position) { |
|
|
|
const { |
|
|
@ -2146,9 +2146,9 @@ export class PortfolioService { |
|
|
|
} |
|
|
|
); |
|
|
|
|
|
|
|
historicalDataItems.sort( |
|
|
|
(a, b) => new Date(a.date).getTime() - new Date(b.date).getTime() |
|
|
|
); |
|
|
|
historicalDataItems.sort((a, b) => { |
|
|
|
return new Date(a.date).getTime() - new Date(b.date).getTime(); |
|
|
|
}); |
|
|
|
|
|
|
|
return historicalDataItems; |
|
|
|
} |
|
|
|