|
@ -234,6 +234,8 @@ export class PortfolioService { |
|
|
marketPrice: item.marketPrice, |
|
|
marketPrice: item.marketPrice, |
|
|
marketState: dataProviderResponse.marketState, |
|
|
marketState: dataProviderResponse.marketState, |
|
|
name: symbolProfile.name, |
|
|
name: symbolProfile.name, |
|
|
|
|
|
netPerformance: item.netPerformance?.toNumber() ?? 0, |
|
|
|
|
|
netPerformancePercent: item.netPerformancePercentage?.toNumber() ?? 0, |
|
|
quantity: item.quantity.toNumber(), |
|
|
quantity: item.quantity.toNumber(), |
|
|
sectors: symbolProfile.sectors, |
|
|
sectors: symbolProfile.sectors, |
|
|
symbol: item.symbol, |
|
|
symbol: item.symbol, |
|
@ -281,6 +283,8 @@ export class PortfolioService { |
|
|
marketPrice: undefined, |
|
|
marketPrice: undefined, |
|
|
maxPrice: undefined, |
|
|
maxPrice: undefined, |
|
|
minPrice: undefined, |
|
|
minPrice: undefined, |
|
|
|
|
|
netPerformance: undefined, |
|
|
|
|
|
netPerformancePercent: undefined, |
|
|
quantity: undefined, |
|
|
quantity: undefined, |
|
|
symbol: aSymbol, |
|
|
symbol: aSymbol, |
|
|
transactionCount: undefined |
|
|
transactionCount: undefined |
|
@ -326,7 +330,7 @@ export class PortfolioService { |
|
|
transactionCount |
|
|
transactionCount |
|
|
} = position; |
|
|
} = position; |
|
|
|
|
|
|
|
|
// Convert investment and gross performance to currency of user
|
|
|
// Convert investment, gross and net performance to currency of user
|
|
|
const userCurrency = this.request.user.Settings.currency; |
|
|
const userCurrency = this.request.user.Settings.currency; |
|
|
const investment = this.exchangeRateDataService.toCurrency( |
|
|
const investment = this.exchangeRateDataService.toCurrency( |
|
|
position.investment.toNumber(), |
|
|
position.investment.toNumber(), |
|
@ -338,6 +342,11 @@ export class PortfolioService { |
|
|
currency, |
|
|
currency, |
|
|
userCurrency |
|
|
userCurrency |
|
|
); |
|
|
); |
|
|
|
|
|
const netPerformance = this.exchangeRateDataService.toCurrency( |
|
|
|
|
|
position.netPerformance.toNumber(), |
|
|
|
|
|
currency, |
|
|
|
|
|
userCurrency |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
const historicalData = await this.dataProviderService.getHistorical( |
|
|
const historicalData = await this.dataProviderService.getHistorical( |
|
|
[aSymbol], |
|
|
[aSymbol], |
|
@ -399,10 +408,12 @@ export class PortfolioService { |
|
|
marketPrice, |
|
|
marketPrice, |
|
|
maxPrice, |
|
|
maxPrice, |
|
|
minPrice, |
|
|
minPrice, |
|
|
|
|
|
netPerformance, |
|
|
transactionCount, |
|
|
transactionCount, |
|
|
averagePrice: averagePrice.toNumber(), |
|
|
averagePrice: averagePrice.toNumber(), |
|
|
grossPerformancePercent: position.grossPerformancePercentage.toNumber(), |
|
|
grossPerformancePercent: position.grossPerformancePercentage.toNumber(), |
|
|
historicalData: historicalDataArray, |
|
|
historicalData: historicalDataArray, |
|
|
|
|
|
netPerformancePercent: position.netPerformancePercentage.toNumber(), |
|
|
quantity: quantity.toNumber(), |
|
|
quantity: quantity.toNumber(), |
|
|
symbol: aSymbol |
|
|
symbol: aSymbol |
|
|
}; |
|
|
}; |
|
@ -452,6 +463,8 @@ export class PortfolioService { |
|
|
grossPerformancePercent: undefined, |
|
|
grossPerformancePercent: undefined, |
|
|
historicalData: historicalDataArray, |
|
|
historicalData: historicalDataArray, |
|
|
investment: 0, |
|
|
investment: 0, |
|
|
|
|
|
netPerformance: undefined, |
|
|
|
|
|
netPerformancePercent: undefined, |
|
|
quantity: 0, |
|
|
quantity: 0, |
|
|
symbol: aSymbol, |
|
|
symbol: aSymbol, |
|
|
transactionCount: undefined |
|
|
transactionCount: undefined |
|
@ -515,6 +528,9 @@ export class PortfolioService { |
|
|
investment: new Big(position.investment).toNumber(), |
|
|
investment: new Big(position.investment).toNumber(), |
|
|
marketState: dataProviderResponses[position.symbol].marketState, |
|
|
marketState: dataProviderResponses[position.symbol].marketState, |
|
|
name: symbolProfileMap[position.symbol].name, |
|
|
name: symbolProfileMap[position.symbol].name, |
|
|
|
|
|
netPerformance: position.netPerformance?.toNumber() ?? null, |
|
|
|
|
|
netPerformancePercentage: |
|
|
|
|
|
position.netPerformancePercentage?.toNumber() ?? null, |
|
|
quantity: new Big(position.quantity).toNumber() |
|
|
quantity: new Big(position.quantity).toNumber() |
|
|
}; |
|
|
}; |
|
|
}) |
|
|
}) |
|
@ -540,6 +556,8 @@ export class PortfolioService { |
|
|
performance: { |
|
|
performance: { |
|
|
currentGrossPerformance: 0, |
|
|
currentGrossPerformance: 0, |
|
|
currentGrossPerformancePercent: 0, |
|
|
currentGrossPerformancePercent: 0, |
|
|
|
|
|
currentNetPerformance: 0, |
|
|
|
|
|
currentNetPerformancePercent: 0, |
|
|
currentValue: 0 |
|
|
currentValue: 0 |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
@ -559,11 +577,17 @@ export class PortfolioService { |
|
|
currentPositions.grossPerformance.toNumber(); |
|
|
currentPositions.grossPerformance.toNumber(); |
|
|
const currentGrossPerformancePercent = |
|
|
const currentGrossPerformancePercent = |
|
|
currentPositions.grossPerformancePercentage.toNumber(); |
|
|
currentPositions.grossPerformancePercentage.toNumber(); |
|
|
|
|
|
const currentNetPerformance = currentPositions.netPerformance.toNumber(); |
|
|
|
|
|
const currentNetPerformancePercent = |
|
|
|
|
|
currentPositions.netPerformancePercentage.toNumber(); |
|
|
|
|
|
|
|
|
return { |
|
|
return { |
|
|
hasErrors: currentPositions.hasErrors || hasErrors, |
|
|
hasErrors: currentPositions.hasErrors || hasErrors, |
|
|
performance: { |
|
|
performance: { |
|
|
currentGrossPerformance, |
|
|
currentGrossPerformance, |
|
|
currentGrossPerformancePercent, |
|
|
currentGrossPerformancePercent, |
|
|
|
|
|
currentNetPerformance, |
|
|
|
|
|
currentNetPerformancePercent, |
|
|
currentValue: currentValue |
|
|
currentValue: currentValue |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
@ -734,6 +758,8 @@ export class PortfolioService { |
|
|
marketPrice: 0, |
|
|
marketPrice: 0, |
|
|
marketState: MarketState.open, |
|
|
marketState: MarketState.open, |
|
|
name: 'Cash', |
|
|
name: 'Cash', |
|
|
|
|
|
netPerformance: 0, |
|
|
|
|
|
netPerformancePercent: 0, |
|
|
quantity: 0, |
|
|
quantity: 0, |
|
|
sectors: [], |
|
|
sectors: [], |
|
|
symbol: ghostfolioCashSymbol, |
|
|
symbol: ghostfolioCashSymbol, |
|
|