From 111d8d8e3c76781b23743038c691824ab689e7d0 Mon Sep 17 00:00:00 2001 From: Thomas <4159106+dtslvr@users.noreply.github.com> Date: Sat, 15 May 2021 10:12:12 +0200 Subject: [PATCH] Feature/rename share to allocation in columns of positions table (#93) * Rename columns * Initial Share -> Initial Allocation * Current Share -> Current Allocation * Update changelog --- CHANGELOG.md | 1 + .../portfolio-position.interface.ts | 4 ++-- apps/api/src/models/portfolio.spec.ts | 8 +++---- apps/api/src/models/portfolio.ts | 21 ++++++++++--------- .../positions-table.component.html | 14 ++++++------- .../positions-table.component.ts | 4 ++-- .../pages/analysis/analysis-page.component.ts | 4 ++-- 7 files changed, 29 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bfd2dd3..0a3808b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Refactored the active menu item state by parsing the current url - Used a desaturated background color for unknown types in pie charts +- Renamed the columns _Initial Share_ and _Current Share_ to _Initial Allocation_ and _Current Allocation_ in the positions table ### Fixed diff --git a/apps/api/src/app/portfolio/interfaces/portfolio-position.interface.ts b/apps/api/src/app/portfolio/interfaces/portfolio-position.interface.ts index 4f353094..5184d188 100644 --- a/apps/api/src/app/portfolio/interfaces/portfolio-position.interface.ts +++ b/apps/api/src/app/portfolio/interfaces/portfolio-position.interface.ts @@ -5,6 +5,8 @@ export interface PortfolioPosition { accounts: { [name: string]: { current: number; original: number }; }; + allocationCurrent: number; + allocationInvestment: number; currency: Currency; exchange?: string; grossPerformance: number; @@ -18,8 +20,6 @@ export interface PortfolioPosition { name: string; quantity: number; sector?: string; - shareCurrent: number; - shareInvestment: number; transactionCount: number; symbol: string; type?: string; diff --git a/apps/api/src/models/portfolio.spec.ts b/apps/api/src/models/portfolio.spec.ts index 5831373a..e1f6d3cc 100644 --- a/apps/api/src/models/portfolio.spec.ts +++ b/apps/api/src/models/portfolio.spec.ts @@ -188,6 +188,8 @@ describe('Portfolio', () => { ) } }, + // allocationCurrent: 0.9999999559148652, + allocationInvestment: 1, currency: Currency.USD, exchange: UNKNOWN_KEY, grossPerformance: 0, @@ -201,8 +203,6 @@ describe('Portfolio', () => { marketState: MarketState.open, name: 'Bitcoin USD', quantity: 1, - // shareCurrent: 0.9999999559148652, - shareInvestment: 1, symbol: 'BTCUSD', transactionCount: 1, type: 'Cryptocurrency' @@ -289,6 +289,8 @@ describe('Portfolio', () => { ) } }, + // allocationCurrent: 1, + allocationInvestment: 1, currency: Currency.USD, exchange: UNKNOWN_KEY, // grossPerformance: 0, @@ -301,8 +303,6 @@ describe('Portfolio', () => { // marketPrice: 57973.008, name: 'Ethereum USD', quantity: 0.2, - // shareCurrent: 1, - shareInvestment: 1, transactionCount: 1, symbol: 'ETHUSD', type: 'Cryptocurrency' diff --git a/apps/api/src/models/portfolio.ts b/apps/api/src/models/portfolio.ts index c82072be..3451bd63 100644 --- a/apps/api/src/models/portfolio.ts +++ b/apps/api/src/models/portfolio.ts @@ -39,6 +39,7 @@ import { IOrder } from '../services/interfaces/interfaces'; import { RulesService } from '../services/rules.service'; import { PortfolioInterface } from './interfaces/portfolio.interface'; import { Order } from './order'; +import { OrderType } from './order-type'; import { AccountClusterRiskCurrentInvestment } from './rules/account-cluster-risk/current-investment'; import { AccountClusterRiskInitialInvestment } from './rules/account-cluster-risk/initial-investment'; import { AccountClusterRiskSingleAccount } from './rules/account-cluster-risk/single-account'; @@ -285,6 +286,14 @@ export class Portfolio implements PortfolioInterface { ...data[symbol], accounts, symbol, + allocationCurrent: + this.exchangeRateDataService.toCurrency( + portfolioItem.positions[symbol].quantity * now, + data[symbol]?.currency, + this.user.Settings.currency + ) / value, + allocationInvestment: + portfolioItem.positions[symbol].investment / investment, grossPerformance: roundTo( portfolioItemsNow.positions[symbol].quantity * (now - before), 2 @@ -292,14 +301,6 @@ export class Portfolio implements PortfolioInterface { grossPerformancePercent: roundTo((now - before) / before, 4), investment: portfolioItem.positions[symbol].investment, quantity: portfolioItem.positions[symbol].quantity, - shareCurrent: - this.exchangeRateDataService.toCurrency( - portfolioItem.positions[symbol].quantity * now, - data[symbol]?.currency, - this.user.Settings.currency - ) / value, - shareInvestment: - portfolioItem.positions[symbol].investment / investment, transactionCount: portfolioItem.positions[symbol].transactionCount }; }); @@ -537,12 +538,12 @@ export class Portfolio implements PortfolioInterface { this.orders.push( new Order({ account: order.Account, - currency: order.currency, + currency: order.currency, date: order.date.toISOString(), fee: order.fee, quantity: order.quantity, symbol: order.symbol, - type: order.type, + type: order.type, unitPrice: order.unitPrice }) ); diff --git a/apps/client/src/app/components/positions-table/positions-table.component.html b/apps/client/src/app/components/positions-table/positions-table.component.html index 2c7901a3..1bc05e88 100644 --- a/apps/client/src/app/components/positions-table/positions-table.component.html +++ b/apps/client/src/app/components/positions-table/positions-table.component.html @@ -1,7 +1,7 @@ - + - + diff --git a/apps/client/src/app/components/positions-table/positions-table.component.ts b/apps/client/src/app/components/positions-table/positions-table.component.ts index e934417c..abc90c8d 100644 --- a/apps/client/src/app/components/positions-table/positions-table.component.ts +++ b/apps/client/src/app/components/positions-table/positions-table.component.ts @@ -73,8 +73,8 @@ export class PositionsTableComponent implements OnChanges, OnInit { this.displayedColumns = [ 'symbol', 'performance', - 'shareInvestment', - 'shareCurrent' + 'allocationInvestment', + 'allocationCurrent' ]; this.isLoading = true; diff --git a/apps/client/src/app/pages/analysis/analysis-page.component.ts b/apps/client/src/app/pages/analysis/analysis-page.component.ts index 9f889e1e..e8b7498b 100644 --- a/apps/client/src/app/pages/analysis/analysis-page.component.ts +++ b/apps/client/src/app/pages/analysis/analysis-page.component.ts @@ -108,8 +108,8 @@ export class AnalysisPageComponent implements OnDestroy, OnInit { type: position.type, value: aPeriod === 'original' - ? position.shareInvestment - : position.shareCurrent + ? position.allocationInvestment + : position.allocationCurrent }; this.positionsArray.push(position);
- Initial Share + Initial Allocation
- Current Share + Current Allocation