Browse Source

Improve response of positions endpoint

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

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

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

Loading…
Cancel
Save