beancount_portfolio_allocation
Reports on portfolio asset allocations in beancount. Useful for risk analysis and for rebalancing purposes.
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
Metadata
Release files for beancount_portfolio_allocation 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| beancount_portfolio_allocation-1.0.0.tar.gz | 4.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| beancount_portfolio_allocation-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.9 kB
Release files / beancount_portfolio_allocation-1.0.0.tar.gz
| Download URL | beancount_portfolio_allocation-1.0.0.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7b57a67f6197ed9aaa79176cd403a23e148c0b7d566a181ca09510b998d6b3f5
|
|
BLAKE2b-256 checksum How to use checksums |
0c16c7c9f42ce1152fc4b2c30b7f847cd218327b4b54d7a10982288798d4f857
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / beancount_portfolio_allocation-1.0.0-py3-none-any.whl
| Download URL | beancount_portfolio_allocation-1.0.0-py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c20fb88191b2b9e0557588f57646995c2107cb47e276a7d71e85feb833ffcf46
|
|
BLAKE2b-256 checksum How to use checksums |
fb4b61404d5729f4e87b47bd99606801e39d13a2568e134b297da6ffd6f1bccf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for beancount_portfolio_allocation 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.