Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍
TypeScript angularetffinancefintechghostfoliohacktoberfestinvestingnestjsosspersonal-financeportfolioprismasoftwarestocktrackertradingtypescriptwealth-managementweb
remove getPerformance from portfolio.ts
Valentin Zickner328d8149222f
diff --git a/apps/api/src/models/portfolio.spec.ts b/apps/api/src/models/portfolio.spec.tsindex 053ef4f8c8..5e3b34f7b0 100644--- a/apps/api/src/models/portfolio.spec.ts+++ b/apps/api/src/models/portfolio.spec.ts@@ -208,28 +208,6 @@ describe('Portfolio', () => {}});});-- it('should return zero performance for 1d', async () => {- const performance = await portfolio.getPerformance('1d');- expect(performance).toEqual({- currentGrossPerformance: 0,- currentGrossPerformancePercent: 0,- currentNetPerformance: 0,- currentNetPerformancePercent: 0,- currentValue: 0- });- });-- it('should return zero performance for max', async () => {- const performance = await portfolio.getPerformance('max');- expect(performance).toEqual({- currentGrossPerformance: 0,- currentGrossPerformancePercent: 0,- currentNetPerformance: 0,- currentNetPerformancePercent: 0,- currentValue: 0- });- });});describe(`works with today's orders`, () => {@@ -303,32 +281,6 @@ describe('Portfolio', () => {expect(portfolio.getFees()).toEqual(0);- /*const performance1d = await portfolio.getPerformance('1d');- expect(performance1d).toEqual({- currentGrossPerformance: 0,- currentGrossPerformancePercent: 0,- currentNetPerformance: 0,- currentNetPerformancePercent: 0,- currentValue: exchangeRateDataService.toBaseCurrency(- 1 * 49631.24,- Currency.USD,- baseCurrency- )- });*/-- /*const performanceMax = await portfolio.getPerformance('max');- expect(performanceMax).toEqual({- currentGrossPerformance: 0,- currentGrossPerformancePercent: 0,- currentNetPerformance: 0,- currentNetPerformancePercent: 0,- currentValue: exchangeRateDataService.toBaseCurrency(- 1 * 49631.24,- Currency.USD,- baseCurrency- )- });*/-expect(portfolio.getPositions(getYesterday())).toMatchObject({});expect(portfolio.getSymbols(getYesterday())).toEqual([]);@@ -367,55 +319,8 @@ describe('Portfolio', () => {));- /*const details = await portfolio.getDetails('1d');- expect(details).toMatchObject({- ETHUSD: {- accounts: {- [UNKNOWN_KEY]: {- current: exchangeRateDataService.toCurrency(- 0.2 * 991.49,- Currency.USD,- baseCurrency- ),- original: exchangeRateDataService.toCurrency(- 0.2 * 991.49,- Currency.USD,- baseCurrency- )- }- },- // allocationCurrent: 1,- allocationInvestment: 1,- countries: [],- currency: Currency.USD,- exchange: UNKNOWN_KEY,- // grossPerformance: 0,- // grossPerformancePercent: 0,- investment: exchangeRateDataService.toCurrency(- 0.2 * 991.49,- Currency.USD,- baseCurrency- ),- marketPrice: 3915.337,- name: 'Ethereum USD',- quantity: 0.2,- transactionCount: 1,- symbol: 'ETHUSD',- type: 'Cryptocurrency'- }- });*/-expect(portfolio.getFees()).toEqual(0);- /*const performance = await portfolio.getPerformance('max');- expect(performance).toEqual({- currentGrossPerformance: 0,- currentGrossPerformancePercent: 0,- currentNetPerformance: 0,- currentNetPerformancePercent: 0,- currentValue: 0- });*/-expect(portfolio.getPositions(getYesterday())).toMatchObject({ETHUSD: {averagePrice: 991.49,diff --git a/apps/api/src/models/portfolio.ts b/apps/api/src/models/portfolio.tsindex 1ea8418218..b03a9b8298 100644--- a/apps/api/src/models/portfolio.ts+++ b/apps/api/src/models/portfolio.ts@@ -426,49 +426,6 @@ export class Portfolio implements PortfolioInterface {return null;}- public async getPerformance(- aDateRange: DateRange = 'max'- ): Promise<PortfolioPerformance> {- const dateRangeDate = this.convertDateRangeToDate(- aDateRange,- this.getMinDate()- );-- const currentInvestment = this.getInvestment(new Date());- const currentValue = await this.getValue();-- let originalInvestment = currentInvestment;- let originalValue = this.getCommittedFunds();-- if (dateRangeDate) {- originalInvestment = this.getInvestment(dateRangeDate);- originalValue = (await this.getValue(dateRangeDate)) || originalValue;- }-- const fees = this.getFees(dateRangeDate);-- const currentGrossPerformance =- currentValue - currentInvestment - (originalValue - originalInvestment);-- // https://www.skillsyouneed.com/num/percent-change.html- const currentGrossPerformancePercent =- currentGrossPerformance / originalInvestment || 0;-- const currentNetPerformance = currentGrossPerformance - fees;-- // https://www.skillsyouneed.com/num/percent-change.html- const currentNetPerformancePercent =- currentNetPerformance / originalInvestment || 0;-- return {- currentGrossPerformance,- currentGrossPerformancePercent,- currentNetPerformance,- currentNetPerformancePercent,- currentValue- };- }-public getPositions(aDate: Date) {const [portfolioItem] = this.get(aDate);