A calculator which tells you how to split your investment amongst your portfolio's assets based on your target asset allocation.
Project description
Rebalance
A calculator that tells you how to split your investment amongst your portfolio's assets based on your target asset allocation.
To use it, install the package and write a portfolio JSON file as described below.
Installation
pip install rebalance
Usage
rebalance portfolios/my_portfolio.json
Portfolio file format
Create a JSON file describing your portfolio:
{
"name": "My portfolio",
"selling_allowed": false,
"cash": [
{"amount": 3000.0, "currency": "USD"},
{"amount": 200.0, "currency": "CAD"}
],
"assets": [
{"ticker": "XBB.TO", "quantity": 36, "target_allocation": 20},
{"ticker": "XIC.TO", "quantity": 64, "target_allocation": 20},
{"ticker": "ITOT", "quantity": 32, "target_allocation": 36},
{"ticker": "IEFA", "quantity": 8, "target_allocation": 20},
{"ticker": "IEMG", "quantity": 7, "target_allocation": 4}
]
}
Example output
Ticker Ask Quantity Amount Currency Old allocation New allocation Target allocation
to buy ($) (%) (%) (%)
---------------------------------------------------------------------------------------------------------------
XBB.TO 33.43 30 1002.90 CAD 17.52 19.99 20.00
XIC.TO 24.27 27 655.29 CAD 22.61 20.01 20.00
ITOT 69.38 10 693.80 USD 43.93 35.88 36.00
IEFA 57.65 20 1153.00 USD 9.13 19.88 20.00
IEMG 49.14 0 0.00 USD 6.81 4.24 4.00
Largest discrepancy between the new and the target asset allocation is 0.24 %.
Before making the above purchases, the following currency conversion is required:
1072.88 USD to 1458.19 CAD at a rate of 1.3591.
Remaining cash:
80.32 USD.
0.00 CAD.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rebalance-0.4.0.tar.gz.
File metadata
- Download URL: rebalance-0.4.0.tar.gz
- Upload date:
- Size: 102.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.12 {"installer":{"name":"uv","version":"0.11.12","subcommand":["publish"]},"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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f85106408e5a23296a39281e0b64db70c90f5be0e741d285a18384683fd7bc4e
|
|
| MD5 |
2939bb2fd5325b08a8f73938ac7f8780
|
|
| BLAKE2b-256 |
39a061a4b88a036017ba6511f3895e969505215644e260c99f2d7b1ea66695e6
|
File details
Details for the file rebalance-0.4.0-py3-none-any.whl.
File metadata
- Download URL: rebalance-0.4.0-py3-none-any.whl
- Upload date:
- Size: 26.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.12 {"installer":{"name":"uv","version":"0.11.12","subcommand":["publish"]},"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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8228b1b519eb2deb2ed1f1e24dc42d014e3b0bc8a09d288825f56e6275e86085
|
|
| MD5 |
82ebdd7024828bc9088d8d9b7fb3e5d6
|
|
| BLAKE2b-256 |
8421b9557928b8484ea7c51cf2e3ad895dc4f6e30ce0a62d1b742ff8344ddae0
|