Imbalanced Report When Closing Out Lot + Using --unrealized

30 views
Skip to first unread message

Brandon Olivares

unread,
Mar 12, 2020, 2:14:46 AM3/12/20
to Ledger
Not sure if I'm doing something wrong. I'm trying to use ledger to track investments in my portfolio.

Everything seems to work fine. I like the --unrealized option so that I can see how my investments are currently doing, but yet keep the balance report totalling to 0.

However, if I close out a lot, my balance is no longer adding to 0, but currently shows $258.63.

Here's the journal file (it's pretty short):

2020/03/02 Initial Deposit
    Assets:Cash         $10,000.00
    Equity:Opening Balances     $-10,000.00

2020/03/02 Buy SEDG
    Assets:SEDG    15 SEDG @ $126.03
    Assets:Cash           $-1,890.45

2020/03/02 Buy REGN
    Assets:REGN    4 REGN @ $454.88
    Assets:Cash          $-1,819.52

2020/03/02 Buy FRPT
    Assets:FRPT    29 FRPT @ $68.65
    Assets:Cash          $-1,990.85

2020/03/06 Buy TBT
    Assets:TBT     117 TBT @ $17.07
    Assets:Cash          $-1,997.19

2020/03/10 Short SPR
    Assets:SPR                  -45 SPR @ $43.84
    Assets:Cash    $1,972.80

2020/03/11 Sell TBT
    Assets:TBT     -117 TBT {$17.07} @ $17.48
    Income:Capital Gains
    Assets:Cash          $2,045.16

2020/03/11 Sell SEDG
    Assets:SEDG    -15 SEDG {$126.03} @ $105.59
    Equity:Capital Losses  $306.60
    Assets:Cash           $1,583.85

Here's the output:

$ ledger -f journal.dat bal -VQ --unrealized
           $9,775.49  Assets
           $7,903.80    Cash
           $1,775.09    FRPT
           $1,858.80    REGN
          $-1,762.20    SPR
          $-9,468.89  Equity
             $306.60    Capital Losses
         $-10,000.00    Opening Balances
            $-250.77    Unrealized Gains
             $475.28    Unrealized Losses
             $-47.97  Income:Capital Gains
--------------------
             $258.63

I can't seem to figure out why it's not balancing?

John Wiegley

unread,
Mar 12, 2020, 10:59:37 AM3/12/20
to Brandon Olivares, Ledger
>>>>> "BO" == Brandon Olivares <program...@gmail.com> writes:

BO> However, if I close out a lot, my balance is no longer adding to 0, but
BO> currently shows $258.63.

The only report that is guaranteed to always balance to zero is the cost basis
report, or -B.

John

timmy...@gmail.com

unread,
Mar 18, 2020, 4:40:51 PM3/18/20
to Ledger
It's not balancing because the realized gains and losses seem to be still reported as "Unrealized" - I am trying to understand this myself.

Here is a simpler example ledger file (note the sale transaction has been commented out):

17/05/2010 XYZ Purchase
  Assets:XYZ    100 XYZ {$10}
  Assets:Bank   $-1000
P 19/09/2019 XYZ $11
comment
20/09/2019 XYZ Sale
  Assets:XYZ    -100 XYZ {$10} @ $11
  Assets:Bank   $1100
  Income:Realised Gains
end comment

Report based on above:
$ ledger -f test.dat bal -V --unrealized
                $100  Assets
              $-1000    Bank
               $1100    XYZ
               $-100  Equity:Unrealized Gains
--------------------
                   0

That looks OK.
Now after uncommenting the sale transaction:
$ ledger -f test.dat bal -V --unrealized
                $100  Assets:Bank
               $-100  Equity:Unrealized Gains
               $-100  Income:Realised Gains
--------------------
               $-100

Why is the unrealized gain still there?

Tim.

Brandon Olivares

unread,
Mar 18, 2020, 4:42:50 PM3/18/20
to ledge...@googlegroups.com
Yeah seems like a bug, definitely shouldn’t be handled that way IMO.

--

---
You received this message because you are subscribed to the Google Groups "Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ledger-cli+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ledger-cli/2dacec44-0421-463d-acc7-9ff2f39abd21%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages