@ -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
} ;
} ;