|
|
@ -583,6 +583,7 @@ export class PortfolioService { |
|
|
|
quantity: item.quantity.toNumber(), |
|
|
|
sectors: symbolProfile.sectors, |
|
|
|
symbol: item.symbol, |
|
|
|
tags: item.tags, |
|
|
|
transactionCount: item.transactionCount, |
|
|
|
url: symbolProfile.url, |
|
|
|
valueInBaseCurrency: value.toNumber() |
|
|
@ -628,7 +629,7 @@ export class PortfolioService { |
|
|
|
const emergencyFundInCash = emergencyFund |
|
|
|
.minus( |
|
|
|
this.getEmergencyFundPositionsValueInBaseCurrency({ |
|
|
|
activities: orders |
|
|
|
holdings |
|
|
|
}) |
|
|
|
) |
|
|
|
.toNumber(); |
|
|
@ -656,7 +657,7 @@ export class PortfolioService { |
|
|
|
balanceInBaseCurrency: cashDetails.balanceInBaseCurrency, |
|
|
|
emergencyFundPositionsValueInBaseCurrency: |
|
|
|
this.getEmergencyFundPositionsValueInBaseCurrency({ |
|
|
|
activities: orders |
|
|
|
holdings |
|
|
|
}) |
|
|
|
}); |
|
|
|
|
|
|
@ -742,6 +743,7 @@ export class PortfolioService { |
|
|
|
name: order.SymbolProfile?.name, |
|
|
|
quantity: new Big(order.quantity), |
|
|
|
symbol: order.SymbolProfile.symbol, |
|
|
|
tags: order.tags, |
|
|
|
type: order.type, |
|
|
|
unitPrice: new Big(order.unitPrice) |
|
|
|
})); |
|
|
@ -1392,13 +1394,13 @@ export class PortfolioService { |
|
|
|
} |
|
|
|
|
|
|
|
private getEmergencyFundPositionsValueInBaseCurrency({ |
|
|
|
activities |
|
|
|
holdings |
|
|
|
}: { |
|
|
|
activities: Activity[]; |
|
|
|
holdings: PortfolioDetails['holdings']; |
|
|
|
}) { |
|
|
|
const emergencyFundOrders = activities.filter((activity) => { |
|
|
|
const emergencyFundHoldings = Object.values(holdings).filter(({ tags }) => { |
|
|
|
return ( |
|
|
|
activity.tags?.some(({ id }) => { |
|
|
|
tags?.some(({ id }) => { |
|
|
|
return id === EMERGENCY_FUND_TAG_ID; |
|
|
|
}) ?? false |
|
|
|
); |
|
|
@ -1406,18 +1408,9 @@ export class PortfolioService { |
|
|
|
|
|
|
|
let valueInBaseCurrencyOfEmergencyFundPositions = new Big(0); |
|
|
|
|
|
|
|
for (const order of emergencyFundOrders) { |
|
|
|
if (order.type === 'BUY') { |
|
|
|
valueInBaseCurrencyOfEmergencyFundPositions = |
|
|
|
valueInBaseCurrencyOfEmergencyFundPositions.plus( |
|
|
|
order.valueInBaseCurrency |
|
|
|
); |
|
|
|
} else if (order.type === 'SELL') { |
|
|
|
valueInBaseCurrencyOfEmergencyFundPositions = |
|
|
|
valueInBaseCurrencyOfEmergencyFundPositions.minus( |
|
|
|
order.valueInBaseCurrency |
|
|
|
); |
|
|
|
} |
|
|
|
for (const { value } of emergencyFundHoldings) { |
|
|
|
valueInBaseCurrencyOfEmergencyFundPositions = |
|
|
|
valueInBaseCurrencyOfEmergencyFundPositions.plus(value); |
|
|
|
} |
|
|
|
|
|
|
|
return valueInBaseCurrencyOfEmergencyFundPositions.toNumber(); |
|
|
@ -1476,6 +1469,7 @@ export class PortfolioService { |
|
|
|
quantity: 0, |
|
|
|
sectors: [], |
|
|
|
symbol: currency, |
|
|
|
tags: [], |
|
|
|
transactionCount: 0, |
|
|
|
valueInBaseCurrency: balance |
|
|
|
}; |
|
|
@ -1687,7 +1681,16 @@ export class PortfolioService { |
|
|
|
totalBuy, |
|
|
|
totalSell, |
|
|
|
committedFunds: committedFunds.toNumber(), |
|
|
|
emergencyFund: emergencyFund.toNumber(), |
|
|
|
emergencyFund: { |
|
|
|
assets: emergencyFundPositionsValueInBaseCurrency, |
|
|
|
cash: emergencyFund |
|
|
|
.minus(emergencyFundPositionsValueInBaseCurrency) |
|
|
|
.toNumber(), |
|
|
|
total: emergencyFund.toNumber() |
|
|
|
}, |
|
|
|
fireWealth: new Big(performanceInformation.performance.currentValue) |
|
|
|
.minus(emergencyFundPositionsValueInBaseCurrency) |
|
|
|
.toNumber(), |
|
|
|
ordersCount: activities.filter(({ type }) => { |
|
|
|
return type === 'BUY' || type === 'SELL'; |
|
|
|
}).length |
|
|
@ -1739,6 +1742,7 @@ export class PortfolioService { |
|
|
|
name: order.SymbolProfile?.name, |
|
|
|
quantity: new Big(order.quantity), |
|
|
|
symbol: order.SymbolProfile.symbol, |
|
|
|
tags: order.tags, |
|
|
|
type: order.type, |
|
|
|
unitPrice: new Big( |
|
|
|
this.exchangeRateDataService.toCurrency( |
|
|
|