BalanceTwoFunds
A Python CLI that brings balance to your portfolio, your mind, and the universe.
Table of Contents
Requirements
BalanceTwoFunds requires Python 3.6 or later.
Installation
For simplicity's sake, we assume you have Python and pip properly configured and on your machine's path.
Download the latest source distribution or wheel and install it via pip:
pip install <distro/wheel file>
Alternatively, clone/fork the repository, use a terminal to change into its directory, and run
pip install setup.py
Examples
Rebalance two funds, no deposit
Say you have $55 dollars in fund one and $45 in fund two, but you want them to be balanced 50% and 50%.
Issue the following command from your terminal:
C:\some\dir>balancetwofunds 55 .5 45 .5
Which will output the following to your terminal:
╒════════════════╕
│ FUND ONE │
╞════════════════╡
│ ACTION: SELL │
│ MOVE: -5.00 │
├────────────────┤
│ Current: 55.00 │
│ Target: 50.00 │
└────────────────┘
╒════════════════╕
│ FUND TWO │
╞════════════════╡
│ ACTION: BUY │
│ MOVE: 5.00 │
├────────────────┤
│ Current: 45.00 │
│ Target: 50.00 │
└────────────────┘
Rebalance two funds with a deposit
Let's take the last example, but this time, instead of selling, you simply want to rebalance using a deposit or cash position. For our purposes, let's say we deposited $20.
Use the optional -d or --deposit flag to provide the program with the context:
C:\some\dir>balancetwofunds 55 .5 45 .5 -d 20
Which will output:
╒════════════════╕
│ FUND ONE │
╞════════════════╡
│ ACTION: BUY │
│ MOVE: 5.00 │
├────────────────┤
│ Current: 55.00 │
│ Target: 60.00 │
└────────────────┘
╒════════════════╕
│ FUND TWO │
╞════════════════╡
│ ACTION: BUY │
│ MOVE: 15.00 │
├────────────────┤
│ Current: 45.00 │
│ Target: 60.00 │
└────────────────┘
I can't remember which one is fund one and fund two...
Add the -n1 and -n2 optional arguments to provide the program with the names of your fund:
C:\some\dir>balancetwofunds 55 .5 -n1 FZROX 45 .5 -n2 FXNAX -d 20
Which will output:
╒════════════════╕
│ FZROX │
╞════════════════╡
│ ACTION: BUY │
│ MOVE: 5.00 │
├────────────────┤
│ Current: 55.00 │
│ Target: 60.00 │
└────────────────┘
╒════════════════╕
│ FXNAX │
╞════════════════╡
│ ACTION: BUY │
│ MOVE: 15.00 │
├────────────────┤
│ Current: 45.00 │
│ Target: 60.00 │
└────────────────┘
Usage
usage: balancewithdeposit.py [-h] [-v] [-d DEPOSIT] [-n1 FUNDONENAME]
[-n2 FUNDTWONAME]
fundOneCurrentBalance fundOneTargetPercentage
fundTwoCurrentBalance fundTwoTargetPercentage
A Python CLI that does the necessary math to balance two investment funds with
a new deposit.
positional arguments:
fundOneCurrentBalance
The current value of the first fund to be rebalanced
fundOneTargetPercentage
The desired percentage of how much the first fund
should contribute to the total balance between the two
funds
fundTwoCurrentBalance
The current value of the second fund to be rebalanced
fundTwoTargetPercentage
The desired percentage of how much the second fund
should contribute to the total balance between the two
funds
optional arguments:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-d DEPOSIT, --deposit DEPOSIT
An amount deposited to be accounted for the in the
rebalancing
-n1 FUNDONENAME, --fundOneName FUNDONENAME
A name for the first fund to be used in the program
output
-n2 FUNDTWONAME, --fundTwoName FUNDTWONAME
A name for the second fund to be used in the program
output
Notes
- This program relies heavily on the
DecimalPython standard library. It will provide up to 20 digits of precision. - Money values will be rounded to two cents before usage in the program's math.
- Percentage values will take whatever precision you give them, but they must sum perfectly to one. The program will throw an explicit error if this is not the case.
The contents of this repository are distributed under the generic MIT License.
This program is maintained by Matt Youngberg. Feel free to email him with any issues at matt_youngberg@outlook.com
Metadata
Release files for balancetwofunds 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 | Actions |
|---|---|---|---|---|
| balancetwofunds-1.0.0.tar.gz | 6.4 kB | Without provenance | Details for balancetwofunds-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| balancetwofunds-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for balancetwofunds-1.0.0-py3-none-any.whl |
Total release size: 13.3 kB
Release files / balancetwofunds-1.0.0.tar.gz
| Download URL | balancetwofunds-1.0.0.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fb389068eed3990b1bfdeae0fce602898288cd85ea47f5ea8d54d24345a67887
|
|
BLAKE2b-256 checksum How to use checksums |
80381ac45b806c7e2e24a24b86642c044df8a3d26165314079dbf981d2038e2f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.6
|
Release files / balancetwofunds-1.0.0-py3-none-any.whl
| Download URL | balancetwofunds-1.0.0-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
75f23f140bc183ef4761282461b412e5b3ce4cd020d6428d8048aae8cb57b611
|
|
BLAKE2b-256 checksum How to use checksums |
e5fc95312d595b1df7088e84f975fbe8d4dcb827be0dff83a14a4988ccfbebe5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.6
|
Security for balancetwofunds 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.