How to keep track of both gross and net earnings from investments with regressive taxation?

Hello, fellow PTAers!

I have been tracking (Brazilian) bonds and taxes in hledger and this post is intended as both my asking for tips and as a discussion on how to automate these records.

Here's my use case: when I go to my broker and look at a bond, it tells me both the gross rentability (how much my money grew) and the net rentability (total money minus due taxes at the expiration date). The gross amount increases daily at a variable rate, while the net amount equals

NetTotal = InitialAmount + GrossEarning*(1-Tax)

Where Tax varies with how long I keep the money invested

  • 22.5% until 6 months
  • 20% until 1 year
  • 17.5% until 2 years
  • 15% thereafter

So the net amount increases steadily but gets a bump whenever we cross one of the boundaries.

What is a good way to keep track of both these amounts using hledger?
Right now, I am trying two ideas on how to model it and would be happy to hear your opinion on them!

Directly track the money
We can record all cash flows using these accounts

account assets:bond         ; The total money
account liabilities:bond:tax  ; How much taxes are due
account revenues:bond        ; The money I earn
account expenses:tax           ; The money I pay

Let's say I start the year buying $1000 on this bond.

2024-01-01 * Investment
  assets:bond $ 1000
  assets:bank $-1000

Although the earnings are daily, for the sake of my sanity, I can add a transaction at the end of each month recording the earnings. Let's say the end of January, the gross earnings are $100. I debit a revenue for it and pay the future taxes using the liability.

2024-01-31 * Investment earnings
  assets:bond $ 100
  assets:revenue $-100
  ; Due taxes
  expenses:tax $ 22.5  ; To be paid on expiration date
  liabilities:bond:tax $-22.5

This works ok, and I can assert the rentability with the values in my broker by checking

  • Gross = assets:bond
  • Net = assets:bond - liabilities:bond:tax

Finally, each time the tax rate changes, there is a transaction "taking back" from the expenses:tax account. To be fair, I find it strange to debit an expense account, but it works nevertheless.

2024-07-01 * New tax rate
  liabilities:bond:tax  = $ 2500
  expenses:tax

This approach works but I have to manually record everything, even though the rates and proportions are fixed. So, I've also been experimenting with using prices.

Bonds as commodities

I recently found out that I can download daily data from my broker about how much the bonds value. So, another idea is to automatically download this data (as one usually does with stocks, for example) and turn them into P directives.

We start with a 1 to 1 correspondence and then increase it.

commodity 1.00 "BOND"
P 2024-01-01 "BOND" $ 1
P 2024-01-02 "BOND" $ 1.001
P 2024-01-03 "BOND" $ 1.0013

From time to time, I can just go to my broker and an assertion for the total amount. And that's it. No more revenues nor expenses.

This is a lot less work! Nevertheless, I don't know how to keep track of the net rentability... Do you guys have any idea for also automating the rates?
I thought about keeping a liability account with a fraction of the total BOND due. But this seems strange.

I prefer simple things and I would only increase Liability:bond:tax or any Liability:... account when the liability appears. That happens when you sell your bonds not before and at that moment you know exactly the ammount you owe because you know the years since the buy (that is the rule for a liability: (1) something you owe and (2) something you can estimate/measure). Until the sell of the bonds, you can estimate the gross rentability but not the net rentability.

I am not sure if you could use "automated transactions" or create one script to taking into account your bonds' date, simulate the sell and the net rentability.

What's the definition of "rentability" in this thread ? I think I roughly get it but it's an unfamiliar word for me.

Return is more correct than rentability. The question is about the calculation of gross return and net return.

Return is more correct than rentability.

This! Sorry for the confusion, I'm not so well acquainted with the terminology.

Until the sell of the bonds, you can estimate the gross rentability but not the net rentability.

At least in the Brazilian case, it is possible to know the net rentability. The broker even shows you both numbers (gross and net).
The tax money is also automatically retained at the moment you sell, so my idea was to keep track of the liability to prevent overestimating the final return. If, for example, I am counting on this money to pay some bills, it would be rather bad to look at my ledger and think I would receive more money than I actually will.

I understand gross and net return can be calculated and even the broker can calculate (or estimate) them for you. My concern is that, specially net return, is difficult to do with PTA.

Gross return is quite easy if you update prices of the commodities. hledger bal assets:investments --cost for purchase cost and hledge bal assets:investments --value for current value, and you can calculate the gross return (if there are other outflows such as dividends or interests you should take them into account).

However, net return calculation is more difficult because you need to record the expenses (fees, taxes...) you would have if you sell just now the assets. So, you have to introduce that information somehow...

  • inside the pta file: you could estimate monthly or yearly the fees and taxes you would have if you sell the assets. You could creare a transation againts the unrealized gain and losses equity account What Are Unrealized Gains and Losses?. Because expenses happen when you really sell the assets.
2024-08-31 estimation of taxes and fees 
    liabilities:taxes 25.00 EUR
    liabilities:fees  25.00 EUR
    equity:unrealized-gain-losses
  • outside the pta file: you dont record information to estimate the net return. you could export your opened lots to process the lots in a spreadsheet. Or you could create one script to look at your hledger file and calculate net return.

You should consider if this worth the work.

You shoul also take a look to hledger-roi script GitHub - adept/hledger-roi: Hledger Return-on-investment calucator. Does time-weighted (TWR) and money-weighted (IRR) computations . I use it to estimate IRR and TWR of my investments.

Is hledger balance --gain of any use here ?

Hi everyone! Excuse the interjection, please. Armchair linguist and elementary Portuguese learner here. If @ilf's first language is Portuguese, then it's possible that rentability is a translation of rendimento, the Portuguese word for income or profit. But yes, return, profit or income would probably be better words for this case. :smile: Here's a fitting example sentence from the Cambridge Portuguese-English dictionary: investimento com pouco rendimento, investment with little profit.

To me as an English speaker, rentability would mean something's fitness for being rented, like an apartment or house.

2 Likes

Is hledger balance --gain of any use here ?

Yes! In fact, using the second approach in my original post, it gives exactly the gross return.

However, net return calculation is more difficult because you need to record the expenses (fees, taxes...) you would have if you sell just now the assets. So, you have to introduce that information somehow...

Yeah... I was just wondering if there was some way to automate that since the taxes are a straightforward percentage of the gross return. Maybe postprocessing in a spreadsheet or script is indeed the best way to go.

Thanks for your help!