Browse Source

Improve response of positions endpoint

pull/2814/head
Thomas Kaul 2 years ago
parent
commit
f1c0b6d335
  1. 47
      apps/api/src/app/portfolio/portfolio.service.ts

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

@ -1035,25 +1035,44 @@ export class PortfolioService {
return {
hasErrors: currentPositions.hasErrors,
positions: positions.map((position) => {
positions: positions.map(
({
averagePrice,
currency,
dataSource,
firstBuyDate,
investment,
grossPerformance,
grossPerformancePercentage,
netPerformance,
netPerformancePercentage,
quantity,
symbol,
transactionCount
}) => {
return {
...position,
assetClass: symbolProfileMap[position.symbol].assetClass,
assetSubClass: symbolProfileMap[position.symbol].assetSubClass,
averagePrice: new Big(position.averagePrice).toNumber(),
grossPerformance: position.grossPerformance?.toNumber() ?? null,
currency,
dataSource,
firstBuyDate,
symbol,
transactionCount,
assetClass: symbolProfileMap[symbol].assetClass,
assetSubClass: symbolProfileMap[symbol].assetSubClass,
averagePrice: averagePrice.toNumber(),
grossPerformance: grossPerformance?.toNumber() ?? null,
grossPerformancePercentage:
position.grossPerformancePercentage?.toNumber() ?? null,
investment: new Big(position.investment).toNumber(),
grossPerformancePercentage?.toNumber() ?? null,
investment: investment.toNumber(),
marketState:
dataProviderResponses[position.symbol]?.marketState ?? 'delayed',
name: symbolProfileMap[position.symbol].name,
netPerformance: position.netPerformance?.toNumber() ?? null,
dataProviderResponses[symbol]?.marketState ?? 'delayed',
name: symbolProfileMap[symbol].name,
netPerformance: netPerformance?.toNumber() ?? null,
netPerformancePercentage:
position.netPerformancePercentage?.toNumber() ?? null,
quantity: new Big(position.quantity).toNumber()
netPerformancePercentage?.toNumber() ?? null,
quantity: quantity.toNumber()
};
})
}
)
};
}

Loading…
Cancel
Save