Package: beancount-portfolio-allocation
beancount_portfolio_allocationReports on portfolio asset allocations in beancount. Useful for risk analysis
and for rebalancing purposes.InstallationFrom source$python3setup.pyinstallPIP$pipinstallbeancount_portfolio_allocationUsageusage: 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 onExample$bean-portfolio-allocation-reportledger.beancount--portfoliopensionCASH====SubclassMarketValuePercentageTarget%Difference
----------------------------------------------------------
cash380.0019.000.00-380.00EQUITY======SubclassMarketValuePercentageTarget%Difference
----------------------------------------------------------
ca-stock700.0035.0030.00-100.00
us-stock600.0030.0030.000.00FIXED=====SubclassMarketValuePercentageTarget%Difference
----------------------------------------------------------
ca-bond320.0016.0040.00480.00PrerequisitesBefore running this tool, your beancount files will need some additional
metadata to help it do its job.CommoditiesAll the commodities/currency you want to track will need to have theasset-classandasset-subclassmetadata 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.AccountsAccounts 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 AccountsIt is possible to specifyasset-classandasset-subclasseor 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 allocationsYou 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 (NOTa 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