Skip to content

Commit

Permalink
fix: Only add capital gains if your portfolio has grown
Browse files Browse the repository at this point in the history
  • Loading branch information
notheotherben committed Jun 15, 2024
1 parent a73caf6 commit b741ef1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion automations/stocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class StockAutomation extends Automation {

public static getNetValue(stockValues: StockValue[], options: { cgtRate?: number; costBasis?: number }): number {
const gross = stockValues.reduce((sum, stock) => sum + stock.value, 0);
const cgt = (gross - options.costBasis || 0) * options.cgtRate || 0;
const cgt = Math.max((gross - options.costBasis || 0) * options.cgtRate || 0, 0);
return gross - cgt;
}

Expand Down
2 changes: 1 addition & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74139,7 +74139,7 @@ class StockAutomation extends automation_1.Automation {
}
static getNetValue(stockValues, options) {
const gross = stockValues.reduce((sum, stock) => sum + stock.value, 0);
const cgt = (gross - options.costBasis || 0) * options.cgtRate || 0;
const cgt = Math.max((gross - options.costBasis || 0) * options.cgtRate || 0, 0);
return gross - cgt;
}
getStocks(options) {
Expand Down

0 comments on commit b741ef1

Please sign in to comment.