Feature/filter public endpoint by equity asset class (#1014)
* Filter by ASSET_CLASS: EQUITY * Update changelog
This commit is contained in:
parent
8d2e110e3d
commit
3332ade3d3
@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Changed the default `HOST` to `0.0.0.0`
|
- Changed the default `HOST` to `0.0.0.0`
|
||||||
|
- Refactored the endpoint of the public page (filter by equity)
|
||||||
|
|
||||||
## 1.158.1 - 12.06.2022
|
## 1.158.1 - 12.06.2022
|
||||||
|
|
||||||
|
@ -316,7 +316,9 @@ export class PortfolioController {
|
|||||||
|
|
||||||
const { holdings } = await this.portfolioService.getDetails(
|
const { holdings } = await this.portfolioService.getDetails(
|
||||||
access.userId,
|
access.userId,
|
||||||
access.userId
|
access.userId,
|
||||||
|
'1d',
|
||||||
|
[{ id: 'EQUITY', type: 'ASSET_CLASS' }]
|
||||||
);
|
);
|
||||||
|
|
||||||
const portfolioPublicDetails: PortfolioPublicDetails = {
|
const portfolioPublicDetails: PortfolioPublicDetails = {
|
||||||
@ -325,9 +327,6 @@ export class PortfolioController {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const totalValue = Object.values(holdings)
|
const totalValue = Object.values(holdings)
|
||||||
.filter((holding) => {
|
|
||||||
return holding.assetClass === 'EQUITY';
|
|
||||||
})
|
|
||||||
.map((portfolioPosition) => {
|
.map((portfolioPosition) => {
|
||||||
return this.exchangeRateDataService.toCurrency(
|
return this.exchangeRateDataService.toCurrency(
|
||||||
portfolioPosition.quantity * portfolioPosition.marketPrice,
|
portfolioPosition.quantity * portfolioPosition.marketPrice,
|
||||||
@ -338,17 +337,15 @@ export class PortfolioController {
|
|||||||
.reduce((a, b) => a + b, 0);
|
.reduce((a, b) => a + b, 0);
|
||||||
|
|
||||||
for (const [symbol, portfolioPosition] of Object.entries(holdings)) {
|
for (const [symbol, portfolioPosition] of Object.entries(holdings)) {
|
||||||
if (portfolioPosition.assetClass === 'EQUITY') {
|
portfolioPublicDetails.holdings[symbol] = {
|
||||||
portfolioPublicDetails.holdings[symbol] = {
|
allocationCurrent: portfolioPosition.allocationCurrent,
|
||||||
allocationCurrent: portfolioPosition.allocationCurrent,
|
countries: hasDetails ? portfolioPosition.countries : [],
|
||||||
countries: hasDetails ? portfolioPosition.countries : [],
|
currency: portfolioPosition.currency,
|
||||||
currency: portfolioPosition.currency,
|
markets: portfolioPosition.markets,
|
||||||
markets: portfolioPosition.markets,
|
name: portfolioPosition.name,
|
||||||
name: portfolioPosition.name,
|
sectors: hasDetails ? portfolioPosition.sectors : [],
|
||||||
sectors: hasDetails ? portfolioPosition.sectors : [],
|
value: portfolioPosition.value / totalValue
|
||||||
value: portfolioPosition.value / totalValue
|
};
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return portfolioPublicDetails;
|
return portfolioPublicDetails;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user