Tracking Short Sales

33 views
Skip to first unread message

Brandon Olivares

unread,
Mar 13, 2020, 2:31:50 AM3/13/20
to ledge...@googlegroups.com
Sorry for another question but having trouble with this.

As I said in my last message I’m using ledger to track my portfolio. I have it down pretty well, but one thing I can’t figure out is short sales.

It seems simple up front: just something like:

2020/03/13 Sell Short
    Assets:Portfolio:AAPL  -8 AAPL @ $250.00
    Assets:Portfolio:Cash  $2,000.00

Then if I view balance by cost basis, I see Assets:Portfolio:Cash is up by $2,000 and Assets:Portfolio:AAPL is -$2,000.

But say I have 5 different stocks, 4 are long and 1 is short. I’d like to calculate the percent of each stock in the portfolio.

But if one is negative, there’s no easy way to calculate that.

I was thinking of transferring out of cash the collateral that is held for the stock, but it seems to overcomplicate things.

Imagine this file for example:

2020/03/13 Initial Deposit
    Assets:Portfolio:Cash                 $10,000.00
    Equity:Opening Balances

2020/03/13 Buy Facebook
    Assets:Portfolio:FB                        13 FB @ $155.00
    Assets:Portfolio:Cash

2020/03/13 Short Apple
    Assets:Portfolio:AAPL                    -8 AAPL @ $250.00
    Assets:Portfolio:Cash

2020/03/12 Buy Amazon
    Assets:Portfolio:AMZN                     1 AMZN @ $1,700.00
    Assets:Portfolio:Cash

2020/03/13 Buy Netflix
    Assets:Portfolio:NFLX                     7 NFLX @ $315.00
    Assets:Portfolio:Cash

2020/03/13 Buy Google
    Assets:Portfolio:GOOGL                   2 GOOGL @ $1,100.00
    Assets:Portfolio:Cash

Running balance on this looks like:

$ ledger -f portfolio.dat -B balance ^Assets
          $10,000.00  Assets:Portfolio
          $-2,000.00    AAPL
           $1,700.00    AMZN
           $3,880.00    Cash
           $2,015.00    FB
           $2,200.00    GOOGL
           $2,205.00    NFLX
--------------------
          $10,000.00

So each stock is roughly 20% (give or take) of the portfolio. But cash looks like it is nearly 40% while AAPL is of course negative by -$2,000.

Just would like a nicer way of looking at this. Ideas? Couldn’t find any resources out there about this.

Jostein Berntsen

unread,
Mar 13, 2020, 3:51:20 AM3/13/20
to ledge...@googlegroups.com
Would it work to move Cash out of the Portfolio category to something
like Assets:Stock:Cash instead?

Jostein



Brandon Olivares

unread,
Mar 13, 2020, 7:01:39 AM3/13/20
to ledge...@googlegroups.com
That’s sort of what I’m thinking of. I tried something like this, and it works mathematically but not sure how clear it is. But I like it because it’s very obvious that as the stock goes down in price, the short position gains value.

2020/03/12 Short AAPL
Assets:Portfolio:AAPL -8 AAPL @ $250.00
Assets:Portfolio:Cash $-2,000.00 ; Set aside collateral
Assets:Portfolio:AAPL:Collateral

The Collateral account gets the cash set aside from the short, plus the cash received for actually selling the position.
> --
>
> ---
> 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/20200313074956.GB27739%40jostein.

John Wiegley

unread,
Mar 13, 2020, 5:44:05 PM3/13/20
to Brandon Olivares, ledge...@googlegroups.com
>>>>> "BO" == Brandon Olivares <program...@gmail.com> writes:

BO> But say I have 5 different stocks, 4 are long and 1 is short. I’d like to
BO> calculate the percent of each stock in the portfolio.

BO> But if one is negative, there’s no easy way to calculate that.

Hmm.. what I do is include a note to my entries to distinguish symbols, and
leave accounts to map to their real world counterparts:

2020/03/12 Buy Amazon
; Symbol: AMZN
Assets:Portfolio:Equities 1 AMZN @ $1,700.00
Assets:Portfolio:Cash

I then use:

ledger bal --pivot=Symbol -B Equities

However, adding --percent does not work here, because each equity value
represents 100% of its contribution to that symbol...

Interestingly, changing to --group-by='tag("Symbol")' causes Ledger to crash,
which is nice to know.

I do wonder if we can't massage the data from this report somehow to get the
figures out that we need.

John
Reply all
Reply to author
Forward
0 new messages