Modeling a stock IPO in a micro economy

Hey y'all :raising_hand_man:

In the below, I'm tracking 3 different balance sheets in a single ledger:

person_a
person_b
corp

corp is going to issue 10 shares of CORP.

person_a buys the 10 shares at a price of 1 each.

person_b buys the 10 shares from person_a at a price of 2 each.

Example 1 : sale to person_b not using symbol notation:

2020-01-01 dig for gold
    corp:assets:gold  100
    corp:equity:gold

2020-01-01 dig for gold
    person_a:assets:gold  100
    person_a:equity:gold

2020-01-02 IPO
    corp:assets:gold       10
    person_a:assets:gold  -10
    person_a:assets:common_stock    10 CORP @ 1
    corp:equity:common_stock       -10

2020-02-01 dig for gold
    person_b:assets:gold  20
    person_b:equity:gold

2020-02-01
    person_b:assets:gold          -20
    person_b:assets:common_stock   20
    ;
    person_a:assets:common_stock  -10
    person_a:assets:gold           20
    person_a:income:stock_gains   -10

Before sale to person_b:

$ ledger -f stock-ipo-2-persons-000-reddit-non-symbol.ledger balance --market --end 2020-01-10
                   0  corp
                 110    assets:gold
                -110    equity
                 -10      common_stock
                -100      gold
                   0  person_a
                 100    assets
                  10      common_stock
                  90      gold
                -100    equity:gold
--------------------
                   0

After sale to person_b (person_a's assets to up by 10):

$ ledger -f stock-ipo-2-persons-000-reddit-non-symbol.ledger balance --market
                   0  corp
                 110    assets:gold
                -110    equity
                 -10      common_stock
                -100      gold
                   0  person_a
                 110    assets:gold
                -100    equity:gold
                 -10    income:stock_gains
                   0  person_b
                  20    assets:common_stock
                 -20    equity:gold
--------------------
                   0

OK, all the sheets are balanced.

Example 2 : sale to person_b using symbol notation

Now, in the above, when person_a sells the 10 shares to person_b, here's the transaction for that:

2020-02-01
    person_b:assets:gold          -20
    person_b:assets:common_stock   20
    ;
    person_a:assets:common_stock  -10
    person_a:assets:gold           20
    person_a:income:stock_gains   -10

I'd prefer to show that transaction using symbol notation. I.e. something like this:

2020-02-01
    person_b:assets:gold          -20
    person_b:assets:common_stock   10 CORP @ 2
    ;
    person_a:assets:common_stock  -10 CORP @ 1
    person_a:assets:gold           20
    person_a:income:stock_gains   -10

The issue is, when I take this approach, person_b is unbalanced:

$ ledger -f stock-ipo-2-persons-001-reddit-symbol.ledger balance --market
                   0  corp
                 110    assets:gold
                -110    equity
                 -10      common_stock
                -100      gold
                   0  person_a
                 110    assets:gold
                -100    equity:gold
                 -10    income:stock_gains
                 -10  person_b
                  10    assets:common_stock
                 -20    equity:gold
--------------------
                 -10

Here's the entire example for this second variation:

2020-01-01 dig for gold
    corp:assets:gold  100
    corp:equity:gold

2020-01-01 dig for gold
    person_a:assets:gold  100
    person_a:equity:gold

2020-01-02 IPO
    corp:assets:gold       10
    person_a:assets:gold  -10
    person_a:assets:common_stock    10 CORP @ 1
    corp:equity:common_stock       -10

2020-02-01 dig for gold
    person_b:assets:gold  20
    person_b:equity:gold

2020-02-01
    person_b:assets:gold          -20
    person_b:assets:common_stock   10 CORP @ 2
    ;
    person_a:assets:common_stock  -10 CORP @ 1
    person_a:assets:gold           20
    person_a:income:stock_gains   -10

Question

Is there a way to get the sheets balanced using symbol notation for the sale to person_b?

I'm using ledger-cli in the above, but I'm open to other systems if this can be more easily expressed there.

Thanks!

P.S.

Thanks to theaccountingnerd01 on reddit who helped me with the first part of this.

2 Likes

bal --market — i.e bal -V — shows you the value of the portfolio today. The outstanding balance you see is the "gain" — in this case "loss", since it's negative — for person_b. You can confirm this by running bal -G.

If you run the report on the cost basis bal -B, you should see the result as you expect.

2 Likes

Wow, thank you, @igbanam!

I confirmed that the results for the symbol version match up with the non-symbol version:

The --basis flag was the key here.

1 Like

Here's another example modeling a company in ledger.

  • three initial investors
  • four later investors

For this, I'm not using commodity syntax. Just straight dollar values.

If you have any suggestions for how to more clearly express this in ledger, suggestions welcome!

Or if you have suggestions on how to make the model more accurate (even though it's a very simple model), those are welcome too.

; Modeling a corporation with investors
;
; 3 initial investors
; 4 later investors
; ----------------------------------------------------------------------
; early investors mine for gold
; ----------------------------------------------------------------------
2020-01-01
    person_a:assets:gold  100
    person_a:equity:earnings:mining

2020-01-01
    person_b:assets:gold  100
    person_b:equity:earnings:mining

2020-01-01
    person_c:assets:gold  100
    person_c:equity:earnings:mining
; ----------------------------------------------------------------------
; corp is formed with initial investors. 100 shares each. $1 per share.
;
; Three initial investors. 300 total shares.
; ----------------------------------------------------------------------
define NUM_SHARES = 100

define COMMISION  =   0

define GROSS_BUY_PRICE  = 1
define NET_BUY_PRICE    = GROSS_BUY_PRICE + COMMISION

define GROSS_BUY = NUM_SHARES * GROSS_BUY_PRICE
define NET_BUY   = GROSS_BUY + COMMISION ; $100
; ----------------------------------------------------------------------
2020-02-01
    corp:assets:gold       (NET_BUY)
    person_a:assets:gold

2020-02-01
    person_a:assets:shares:corp  (NET_BUY)
    corp:equity:original_investment:person_a    
; ----------------------------------------------------------------------
2020-02-01
    corp:assets:gold       (NET_BUY)
    person_b:assets:gold

2020-02-01
    person_b:assets:shares:corp  (NET_BUY)
    corp:equity:original_investment:person_b
; ----------------------------------------------------------------------
2020-02-01
    corp:assets:gold       (NET_BUY)
    person_c:assets:gold

2020-02-01
    person_c:assets:shares:corp  (NET_BUY)
    corp:equity:original_investment:person_c
; ----------------------------------------------------------------------    
# $ ledger -f ledger.ledger bal --end 2020-02-15
#                    0  corp
#                  300    assets:gold
#                 -300    equity:original_investment
#                 -100      person_a
#                 -100      person_b
#                 -100      person_c
#                    0  person_a
#                  100    assets:shares:corp
#                 -100    equity:earnings:mining
#                    0  person_b
#                  100    assets:shares:corp
#                 -100    equity:earnings:mining
#                    0  person_c
#                  100    assets:shares:corp
#                 -100    equity:earnings:mining
# --------------------
#                    0    
; ----------------------------------------------------------------------
; corp mines for gold
; ----------------------------------------------------------------------
2020-03-01
    corp:expenses:mining:project_1  300
    corp:assets:gold
    
2020-03-01
    corp:assets:gold  100000
    corp:equity:mining
; ----------------------------------------------------------------------
; later investors mine for gold
; so they have capital to invest
; ----------------------------------------------------------------------
2020-04-01
    person_d:assets:gold  20000
    person_d:equity:earnings:mining

2020-04-01
    person_e:assets:gold  20000
    person_e:equity:earnings:mining

2020-04-01
    person_f:assets:gold  20000
    person_f:equity:earnings:mining

2020-04-01
    person_g:assets:gold  20000
    person_g:equity:earnings:mining    
; ----------------------------------------------------------------------
# $ ledger -f ledger.ledger bal --end 2020-04-15
#                    0  corp
#               100000    assets:gold
#              -100300    equity
#              -100000      mining
#                 -300      original_investment
#                 -100        person_a
#                 -100        person_b
#                 -100        person_c
#                  300    expenses:mining:project_1
#                    0  person_a
#                  100    assets:shares:corp
#                 -100    equity:earnings:mining
#                    0  person_b
#                  100    assets:shares:corp
#                 -100    equity:earnings:mining
#                    0  person_c
#                  100    assets:shares:corp
#                 -100    equity:earnings:mining
#                    0  person_d
#                20000    assets:gold
#               -20000    equity:earnings:mining
#                    0  person_e
#                20000    assets:gold
#               -20000    equity:earnings:mining
#                    0  person_f
#                20000    assets:gold
#               -20000    equity:earnings:mining
#                    0  person_g
#                20000    assets:gold
#               -20000    equity:earnings:mining
# --------------------
#                    0
; ----------------------------------------------------------------------
; IPO
; value of company: $100,000 
; Issuing 400 more shares
; $100,000 / 700 = $142.86 per share
; ----------------------------------------------------------------------
define total_number_of_shares = 700
define value_of_company = 100000
define price_per_share = value_of_company / total_number_of_shares ; $142.86

define NUM_SHARES = 100
define GROSS_BUY_PRICE = 142.85
define GROSS_BUY = NUM_SHARES * GROSS_BUY_PRICE ; 100 * $142.85 : $14,285

; define amount_invested = 14285 ; 100 shares each
; ----------------------------------------------------------------------
2020-05-01
    corp:assets:gold  (GROSS_BUY)
    person_d:assets:gold

2020-05-01
    person_d:assets:shares:corp  (GROSS_BUY)
    corp:equity:shares:person_d
; ----------------------------------------------------------------------
2020-05-01
    corp:assets:gold  (GROSS_BUY)
    person_e:assets:gold

2020-05-01
    person_e:assets:shares:corp  (GROSS_BUY)
    corp:equity:shares:person_e
; ----------------------------------------------------------------------
2020-05-01
    corp:assets:gold  (GROSS_BUY)
    person_f:assets:gold

2020-05-01
    person_f:assets:shares:corp  (GROSS_BUY)
    corp:equity:shares:person_f
; ----------------------------------------------------------------------
2020-05-01
    corp:assets:gold  (GROSS_BUY)
    person_g:assets:gold

2020-05-01
    person_g:assets:shares:corp  (GROSS_BUY)
    corp:equity:shares:person_g
; ----------------------------------------------------------------------
# $ ledger -f ledger.ledger bal --end 2020-05-15
#                    0  corp
#               157140    assets:gold
#              -157440    equity
#              -100000      mining
#                 -300      original_investment
#                 -100        person_a
#                 -100        person_b
#                 -100        person_c
#               -57140      shares
#               -14285        person_d
#               -14285        person_e
#               -14285        person_f
#               -14285        person_g
#                  300    expenses:mining:project_1
#                    0  person_a
#                  100    assets:shares:corp
#                 -100    equity:earnings:mining
#                    0  person_b
#                  100    assets:shares:corp
#                 -100    equity:earnings:mining
#                    0  person_c
#                  100    assets:shares:corp
#                 -100    equity:earnings:mining
#                    0  person_d
#                20000    assets
#                 5715      gold
#                14285      shares:corp
#               -20000    equity:earnings:mining
#                    0  person_e
#                20000    assets
#                 5715      gold
#                14285      shares:corp
#               -20000    equity:earnings:mining
#                    0  person_f
#                20000    assets
#                 5715      gold
#                14285      shares:corp
#               -20000    equity:earnings:mining
#                    0  person_g
#                20000    assets
#                 5715      gold
#                14285      shares:corp
#               -20000    equity:earnings:mining
# --------------------
#                    0    
; ----------------------------------------------------------------------
; corp mines more gold
; ----------------------------------------------------------------------
2020-06-01
    corp:expenses:mining:project_2  7140
    corp:assets:gold
    
2020-06-01
    corp:assets:gold  100000
    corp:equity:mining
; ----------------------------------------------------------------------    
# $ ledger -f ledger.ledger bal --end 2020-06-15 ^corp
#                    0  corp
#               250000    assets:gold
#              -257440    equity
#              -200000      mining
#                 -300      original_investment
#                 -100        person_a
#                 -100        person_b
#                 -100        person_c
#               -57140      shares
#               -14285        person_d
#               -14285        person_e
#               -14285        person_f
#               -14285        person_g
#                 7440    expenses:mining
#                  300      project_1
#                 7140      project_2
# --------------------
#                    0
; ----------------------------------------------------------------------
; corp liquidates
; ----------------------------------------------------------------------
; assets - liabilities = 250,000
; total shares = 700
; $250,000 / 700 shares = $357.14 share
; ----------------------------------------------------------------------
; Handle the three original investors first
define NUM_SHARES = 100

define COMMISION  =   0

define GROSS_BUY_PRICE  = 1
define NET_BUY_PRICE    = GROSS_BUY_PRICE + COMMISION

define GROSS_SELL_PRICE = 357.14
define NET_SELL_PRICE   = GROSS_SELL_PRICE - COMMISION

define GROSS_BUY        = NUM_SHARES * GROSS_BUY_PRICE   ; 100 * $1 : $100
define NET_BUY          = GROSS_BUY + COMMISION          ;            $100

define GROSS_SALE       = NUM_SHARES * GROSS_SELL_PRICE  ; 100 * $357.14 : $35,714
define NET_SALE         = GROSS_SALE - COMMISION         ;                 $35,714

define GROSS_PROFIT     = GROSS_SALE - GROSS_BUY         ; $35,713 - $100 : $35,613
define NET_PROFIT       = NET_SALE - NET_BUY             ; 
; ----------------------------------------------------------------------
2020-07-01
    person_a:assets:gold                (NET_SALE)
    person_a:assets:shares:corp      (-GROSS_SALE)
    person_a:assets:shares:corp     (GROSS_PROFIT)
    person_a:income:capital_gains  (-GROSS_PROFIT)

2020-07-01
    corp:assets:gold  (-GROSS_BUY)
    corp:equity:original_investment:person_a
    
2020-07-01
    corp:assets:gold  (-GROSS_PROFIT)
    corp:liquidation:person_a:capital_gains    
; ----------------------------------------------------------------------
2020-07-01
    person_b:assets:gold                (NET_SALE)
    person_b:assets:shares:corp  (-GROSS_SALE)
    person_b:assets:shares:corp  (GROSS_PROFIT)
    person_b:income:capital_gains   (-GROSS_PROFIT)

2020-07-01
    corp:assets:gold  (-GROSS_BUY)
    corp:equity:original_investment:person_b
    
2020-07-01
    corp:assets:gold  (-GROSS_PROFIT)
    corp:liquidation:person_b:capital_gains        
; ----------------------------------------------------------------------
2020-07-01
    person_c:assets:gold                (NET_SALE)
    person_c:assets:shares:corp      (-GROSS_SALE)
    person_c:assets:shares:corp     (GROSS_PROFIT)
    person_c:income:capital_gains  (-GROSS_PROFIT)

2020-07-01
    corp:assets:gold  (-GROSS_BUY)
    corp:equity:original_investment:person_c
    
2020-07-01
    corp:assets:gold  (-GROSS_PROFIT)
    corp:liquidation:person_c:capital_gains    
; ----------------------------------------------------------------------
; later investors
; ----------------------------------------------------------------------
define NUM_SHARES = 100

define COMMISION  =   0

define GROSS_SELL_PRICE = 357.14
define NET_SELL_PRICE   = GROSS_SELL_PRICE - COMMISION

define GROSS_BUY_PRICE  = 142.85
define NET_BUY_PRICE    = GROSS_BUY_PRICE + COMMISION

define GROSS_BUY        = NUM_SHARES * GROSS_BUY_PRICE   ; 100 * $142.85 : $14,285
define NET_BUY          = GROSS_BUY + COMMISION          ; $14,286

define GROSS_SALE       = NUM_SHARES * GROSS_SELL_PRICE  ; 100 * $357.14 : $35,714
define NET_SALE         = GROSS_SALE - COMMISION         ; $35,714

define GROSS_PROFIT     = GROSS_SALE - GROSS_BUY         ; $35,713 - $14,285 : $21,429
define NET_PROFIT       = NET_SALE - NET_BUY             ; 
; ----------------------------------------------------------------------
2020-07-10
    person_d:assets:gold                (NET_SALE)
    person_d:assets:shares:corp  (-GROSS_SALE)
    person_d:assets:shares:corp  (GROSS_PROFIT)
    person_d:income:capital_gains   (-GROSS_PROFIT)
 
2020-07-10
    corp:assets:gold  (-GROSS_BUY)
    corp:equity:shares:person_d
    
2020-07-10
    corp:assets:gold  (-GROSS_PROFIT)
    corp:liquidation:person_d:capital_gains    
; ----------------------------------------------------------------------
2020-07-10
    person_e:assets:gold                (NET_SALE)
    person_e:assets:shares:corp  (-GROSS_SALE)
    person_e:assets:shares:corp  (GROSS_PROFIT)
    person_e:income:capital_gains   (-GROSS_PROFIT)

2020-07-10
    corp:assets:gold  (-GROSS_BUY)
    corp:equity:shares:person_e
    
2020-07-10
    corp:assets:gold  (-GROSS_PROFIT)
    corp:liquidation:person_e:capital_gains    
; ----------------------------------------------------------------------
2020-07-10
    person_f:assets:gold                (NET_SALE)
    person_f:assets:shares:corp  (-GROSS_SALE)
    person_f:assets:shares:corp  (GROSS_PROFIT)
    person_f:income:capital_gains   (-GROSS_PROFIT)

2020-07-10
    corp:assets:gold  (-GROSS_BUY)
    corp:equity:shares:person_f
    
2020-07-10
    corp:assets:gold  (-GROSS_PROFIT)
    corp:liquidation:person_f:capital_gains    
; ----------------------------------------------------------------------
2020-07-10
    person_g:assets:gold                (NET_SALE)
    person_g:assets:shares:corp  (-GROSS_SALE)
    person_g:assets:shares:corp  (GROSS_PROFIT)
    person_g:income:capital_gains   (-GROSS_PROFIT)

2020-07-10
    corp:assets:gold  (-GROSS_BUY)
    corp:equity:shares:person_g
    
2020-07-10
    corp:assets:gold  (-GROSS_PROFIT)
    corp:liquidation:person_g:capital_gains    
; ----------------------------------------------------------------------
# $ ledger -f ledger.ledger bal
#                    0  corp
#                    2    assets:gold
#              -200000    equity:mining
#                 7440    expenses:mining
#                  300      project_1
#                 7140      project_2
#               192558    liquidation
#                35614      person_a:capital_gains
#                35614      person_b:capital_gains
#                35614      person_c:capital_gains
#                21429      person_d:capital_gains
#                21429      person_e:capital_gains
#                21429      person_f:capital_gains
#                21429      person_g:capital_gains
#                    0  person_a
#                35714    assets:gold
#                 -100    equity:earnings:mining
#               -35614    income:capital_gains
#                    0  person_b
#                35714    assets:gold
#                 -100    equity:earnings:mining
#               -35614    income:capital_gains
#                    0  person_c
#                35714    assets:gold
#                 -100    equity:earnings:mining
#               -35614    income:capital_gains
#                    0  person_d
#                41429    assets:gold
#               -20000    equity:earnings:mining
#               -21429    income:capital_gains
#                    0  person_e
#                41429    assets:gold
#               -20000    equity:earnings:mining
#               -21429    income:capital_gains
#                    0  person_f
#                41429    assets:gold
#               -20000    equity:earnings:mining
#               -21429    income:capital_gains
#                    0  person_g
#                41429    assets:gold
#               -20000    equity:earnings:mining
#               -21429    income:capital_gains
# --------------------
#                    0
1 Like