Skip to main content

Beancount portfolio allocation report

Project description

beancount_portfolio_allocation

Reports on portfolio asset allocations in beancount. Useful for risk analysis and for rebalancing purposes.

Build Status Coverage Status

Installation

From source

$ python3 setup.py install

PIP

$ pip install beancount_portfolio_allocation

Usage

usage: Report on portfolio asset classes allocation vs targets.
       [-h] --portfolio PORTFOLIO bean

positional arguments:
  bean                  Path to the beancount file.

optional arguments:
  -h, --help            show this help message and exit
  --portfolio PORTFOLIO
                        Name of portfolio to report on

Example

$ bean-portfolio-allocation-report ledger.beancount --portfolio pension
CASH
====
Subclass      Market Value    Percentage    Target %    Difference
----------  --------------  ------------  ----------  ------------
cash                380.00         19.00        0.00       -380.00


EQUITY
======
Subclass      Market Value    Percentage    Target %    Difference
----------  --------------  ------------  ----------  ------------
ca-stock            700.00         35.00       30.00       -100.00
us-stock            600.00         30.00       30.00          0.00


FIXED
=====
Subclass      Market Value    Percentage    Target %    Difference
----------  --------------  ------------  ----------  ------------
ca-bond             320.00         16.00       40.00        480.00

Prerequisites

Before running this tool, your beancount files will need some additional metadata to help it do its job.

Commodities

All the commodities/currency you want to track will need to have the asset-class and asset-subclass metadata strings filled in. The actual values are up to you. Here are some examples:

1867-01-01 commodity CAD
  asset-class: "cash"
  asset-subclass: "cash"

1986-03-13 commodity MSFT
  asset-class: "equity"
  asset-subclass: "us-stock"

1977-01-03 commodity AAPL
  asset-class: "equity"
  asset-subclass: "us-stock"

2007-04-04 commodity VAB
  asset-class: "fixed-income"
  asset-subclass: "ca-bond"

You will also need valid price directives for all commodities held at cost and at least one 'operating_currency' option defined. The values in the report will all be converted to the first 'operating_currency' defined. A future version will offer a way to specify the currency to use for reporting.

Accounts

Accounts need to be part of a specific portfolio to track. Only one portfolio is supported by account, but you can have multiple portfolios over multiple accounts:

2000-01-01 open Assets:CA:Employer:PensionPlan
  portfolio: "pension"

2000-01-01 open Assets:CA:Questrade:RRSP
  portfolio: "pension"

2000-01-01 open Assets:CA:Questrade:Trading
  portfolio: "day-trading"

Cash Based Accounts

It is possible to specify asset-class and asset-subclasse or accounts that are reported as a cash-value, but are backed by specific asset classes.

This is use in particular for managed retirement accounts.

2000-01-01 open Assets:CA:Employer:PensionPlan
  portfolio: "pension"
  asset-class: "fixed-income"
  asset-subclass: "ca-bond"

Target allocations

You can currently define your target allocation percentages for different asset subclasses in a portfolio using custom directives. There can currently be only one directive for the same portfolio and asset subclass. Missing allocation targets will be assumed to be 0%. An example 60/40 portfolio target might look like this (NOT a financial advice):

2018-06-14 custom "allocation" "pension" "ca-stock" 30
2018-06-14 custom "allocation" "pension" "us-stock" 30
2018-06-14 custom "allocation" "pension" "ca-bond" 40

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

beancount_portfolio_allocation-0.3.0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file beancount_portfolio_allocation-0.3.0.tar.gz.

File metadata

  • Download URL: beancount_portfolio_allocation-0.3.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

File hashes

Hashes for beancount_portfolio_allocation-0.3.0.tar.gz
Algorithm Hash digest
SHA256 9336d8ff7e4407bb11b35d4539f214d27efa5620eb56e04102ba3e77ea979654
MD5 d1ea0f81c1cd494508b85a322b1d3779
BLAKE2b-256 a6553ce2a842480f554d41b1ca38a37d1d8df65d7a4e95e53ffdd41acda8d484

See more details on using hashes here.

File details

Details for the file beancount_portfolio_allocation-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: beancount_portfolio_allocation-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0

File hashes

Hashes for beancount_portfolio_allocation-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c66d8c3eb893ee43048e3ba1fa1b35cdb8a96130bf1e4024fc15ed1f17edbdf6
MD5 095f7453f237081295d758d497d0a2ec
BLAKE2b-256 1d0460f93ac9ea61a286421c3e81336e1c6f4720766cdaad84e7a0f4b86138a8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page