From c5bb3023d3a4c5c97c95d7fc15dfe3f117ece7af Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Thu, 26 Aug 2021 17:45:04 +0200 Subject: [PATCH] Bugfix/filter out positions without quantity (#317) * Filter out positions without any quantity * Update changelog --- CHANGELOG.md | 6 ++++++ apps/api/src/app/portfolio/portfolio.service.ts | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf0e81084..916044ae0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Fixed + +- Filtered out positions without any quantity in the positions table + ## 1.43.0 - 24.08.2021 ### Added diff --git a/apps/api/src/app/portfolio/portfolio.service.ts b/apps/api/src/app/portfolio/portfolio.service.ts index 5f77ef58d..19fbf91e8 100644 --- a/apps/api/src/app/portfolio/portfolio.service.ts +++ b/apps/api/src/app/portfolio/portfolio.service.ts @@ -211,6 +211,11 @@ export class PortfolioService { } for (const item of currentPositions.positions) { + if (item.quantity.lte(0)) { + // Ignore positions without any quantity + continue; + } + const value = item.quantity.mul(item.marketPrice); const symbolProfile = symbolProfileMap[item.symbol]; const dataProviderResponse = dataProviderResponses[item.symbol];