Asset Allocation

92 views
Skip to first unread message

Alen Šiljak

unread,
May 2, 2019, 3:40:03 PM5/2/19
to Beancount
Please note that I'm completely new to Beancount so I'd like some opinions and pointers.
I would like to implement the Asset Allocation with Beancount, in order to migrate the functionality I currently have in https://github.com/MisterY/asset-allocation.

What currently happens, briefly:

- Asset Allocation is defined. I.e. Equities:Australian:Large 60%; Fixed:Australian:Government 40%. I'll used this for a simplified example.
- Stock symbols are linked to asset classes.
- Stock/fund amounts are read from the book, combined with the current prices to get the current market value; including multiple currencies;
- The resulting report displays:

Equities:Australian:Large - allocation 60%, current 53.25%, allocated value 6000, current value 5325, diff -675, diff -9.5%
Fixed:Australian:Government - allocation 40%, current 46.75%, allocated value 4000, current value 4675, diff 675, diff 15% (approximate value)

From what I've read, this should be quite possible to get from Beancount. I would like to add the allocation percentages in the commodity declarations as meta tags.
Ideally, this could be a plugin. It could even operate on the balance sheet, rather than depending on individual transactions.

So, since I currently have no idea how to complete this, any pointers are helpful. I assume a good doc to go through would be Beancount Scripting and Plugins.
I've seen the experimental portfolio.py script, as well the asset allocator project. These are on my reference list, to be examined into more details.
I understand conceptually what needs to be done but what I don't know at the moment is where to put the plugin script and how to read the holdings data under "Assets:Investments", for example.

I noticed that a few people are doing this so I'm wondering if there are more working examples out there.

Justus Pendleton

unread,
May 3, 2019, 8:35:51 PM5/3/19
to Beancount
There's an existing script that does this, or something very like it at least, so looking at how it works is probably the best place to start

Martin Blais

unread,
May 3, 2019, 9:47:30 PM5/3/19
to Beancount
I do this:

- I run
This joins a bunch of different data (e.g. metadata from open directives, positions, and more, read the source) to a single table of output for each lot, writes out a CSV file.
The result is a single table of all the positions in my account including all the information I need to do various aggregations and determinations later, e.g. estimate tax liability, market value, long vs short term, category, etc.

Then I us this script:
This takes the CSV file and uploads it to replace a specific sheet in an existing Google Sheets document.

The google sheets doc has multiple sheets that all feed from that one flattened list of position.
One of those sheets is something very close to what you describe.

The advantage of this doings this way is that I can easily just change my allocations by fiddling with the sheets doc and see results immediately, rather than writing code.
It also gives me intra-day changes and hedge protection estimates.

Enjoy,



--
You received this message because you are subscribed to the Google Groups "Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beancount+...@googlegroups.com.
To post to this group, send email to bean...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/df7fd48b-c725-4b1d-9435-d56e6b8f0e33%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages