Asset allocation again

113 views
Skip to first unread message

Matthew Harris

unread,
Nov 8, 2012, 3:50:36 PM11/8/12
to ledge...@googlegroups.com
I'm very impressed that Ledger is able to compute asset allocation. I know the asset allocation command is a big hack, so I shouldn't expect too much, but...

Is it possible to restrict the asset allocation to a particular set of accounts? For example, can I compute the asset allocation of only my 401(k)? I don't see an option that lets me do that, but it's possible I'm missing something.


Matthew

Craig Earls

unread,
Nov 8, 2012, 4:09:13 PM11/8/12
to ledge...@googlegroups.com
Well, it isn't a HACK, I thought it was pretty elegant!  Try getting Quicken to do that!

Anyway, assuming you are using the method in Ledger3.pdf the simplest way would be would be to add a clause to the expr limiting the automated transaction to specific accounts. Something like (not debugged or tested):

= /401K/ and expr ( commodity == 'VTHRX')
     (allocation:Equities:Domestic)  1.000

That will only apply the allocation to accounts with 401K in the name.

Does that get what you want?
--
Craig, Corona De Tucson, AZ
enderw88.wordpress.com

Matthew Harris

unread,
Nov 9, 2012, 4:38:35 PM11/9/12
to ledge...@googlegroups.com
It's an impressive hack, but it's still a hack. Ledger doesn't have any notion of asset allocation. Even if my 401k consists of a stock fund and a bond fund, the --percent balance report won't tell me the asset allocation of my account unless I split the account into one account per fund, which I would prefer not to do. Your example works if I always want to see the asset allocation of my 401k, but it doesn't scale: I want to see the asset allocation of my 401k, my wife's 401k, the sum of our 401k's, the sum of our investments ... really every investment account in the journal.

Ideally Ledger would have an idea of the asset allocation of each commodity and I could pass a flag so the balance report would give the balance in terms of asset allocation categories instead of the underlying commodities.

In this case, I was hoping that there was a flag so I could tell Ledger to add up the asset allocation virtual postings only for my 401k, for example. But that would have been a hack too, so I'm not really sad that there isn't one.


Matthew

John Wiegley

unread,
Nov 9, 2012, 5:06:53 PM11/9/12
to ledge...@googlegroups.com
>>>>> Matthew Harris <mharr...@gmail.com> writes:

> Ideally Ledger would have an idea of the asset allocation of each commodity
> and I could pass a flag so the balance report would give the balance in
> terms of asset allocation categories instead of the underlying commodities.

Perhaps you could use metadata to achieve this. But the fact is, Ledger
doesn't actually know _anything_ about finances. It just looks that way.
Under the hood, it's simple a fancy calculator, and it's up to the user to
ascribe meaning to both the input and the output.

John

Craig Earls

unread,
Nov 9, 2012, 5:07:52 PM11/9/12
to ledge...@googlegroups.com
Unfortunately, Asset Allocation looks like an exchange rate from one commodity to multiple commodities which I think would require very deep changes in Ledgers math core.  John?

I thought about the use case you bring up, but I haven't solved it yet.  There is a way, I just don't have it yet.

John Wiegley

unread,
Nov 9, 2012, 5:28:13 PM11/9/12
to ledge...@googlegroups.com
>>>>> Craig Earls <ende...@gmail.com> writes:

> Unfortunately, Asset Allocation looks like an exchange rate from one
> commodity to multiple commodities which I think would require very deep
> changes in Ledgers math core.  John?

How would one convert a single commodity to multiple?

John

Craig Earls

unread,
Nov 9, 2012, 5:58:48 PM11/9/12
to ledge...@googlegroups.com
Yes, one way is to establish a multi-exchange rate, i.e. 1 pesata = .3 Euro + .9 dollars.  Or in this case  1 VIFDF = 0.1 Bond +0.5 Stock + 03 Cash

I don't think the math core could do something like that out of the box without major changes.


John Wiegley

unread,
Nov 9, 2012, 6:22:01 PM11/9/12
to ledge...@googlegroups.com
>>>>> Craig Earls <ende...@gmail.com> writes:

> Yes, one way is to establish a multi-exchange rate, i.e. 1 pesata = .3 Euro
> + .9 dollars.  Or in this case  1 VIFDF = 0.1 Bond +0.5 Stock + 03 Cash

> I don't think the math core could do something like that out of the box
> without major changes.

Mostly that's true, but the changes wouldn't be as you might think. In
commodity.h there is a price_point_t structure, with member "amount_t price".
That would have to be changed to value_t price, and then all the code which
uses it would have to change to know about value_t.

There would have to be a restriction that prices in journal files could *not*
use multiple-exchange rates, since AMOUNT * COST must be an amount (single
commodity). Changing _that_ would be huge. But in terms of reporting only,
extending to allow multiple-exchange rates would not be too terrible.

What I would need to see is a really compelling reason to add this extra
complexity. Is it only the asset allocation question that needs this?

John

Matthew Harris

unread,
Nov 9, 2012, 6:36:30 PM11/9/12
to ledge...@googlegroups.com, jo...@newartisans.com
On Friday, November 9, 2012 3:22:05 PM UTC-8, John Wiegley wrote:
What I would need to see is a really compelling reason to add this extra
complexity.  Is it only the asset allocation question that needs this?

Yeah, it's the only one I'm aware of right now. I think it's more important to fix existing bugs than to add a whole new layer of complexity. If I could get the Python interface working for me, then I could probably satisfy many of my wants.


Matthew

Craig Earls

unread,
Nov 9, 2012, 6:38:14 PM11/9/12
to ledge...@googlegroups.com
I can't think of another reason.  Another way that I think can be done, but I can't remember (or find in the docs) how to do it would be to set a value on the command line that would be used in the automatic transmission expr to mix in the account I want to run the auto xact against.
Reply all
Reply to author
Forward
0 new messages