Tamlyn
Tamlyn

Reputation: 23582

Modelling investments in double entry bookkeeping

I'm building an app where users can buy and sell investments – imagine Robinhood or Freetrade. My app uses APIs to manage the money and trades and isn't the ultimate source of truth for balances, but I want to implement a ledger system so that I have an internally consistent view of a customer's funds at any given time as the money moves between accounts.

I'm using a fairly standard data model with accounts and transactions, similar to this gist.

My question is about how to represent investments (which can rise and fall in value) in a ledger (which is all about keeping value constant). I understand that the book value is only updated when the customer sells their investments, but which account does the growth (or loss) come from?

For example:

  1. Customer adds money to their app account

    amount: $100 from: customer_payable to: cash_account

  2. Customer buys a share for $50

    amount $50 from: cash_account to: investment_account

  3. Customer sells their share for $55

    amount: $50 from: investment_account to: cash_account

    amount: $5 from: ????? to: cash_account

Which account does that $5 growth come from?

Upvotes: 0

Views: 24

Answers (0)

Related Questions