๐ APY (Annual Percentage Yield) trend calculator, with configurable MA (Moving Average).
Note: APY is calculated over a period of 365 days.
This utility is available as a Python package on PyPI:
python3 -mpip install apycalcThere are some files in the example directory of this repo that can be useful to demonstrate how this tool works, so let's change directory first:
cd example/We need a Python virtual environment ("venv") with some packages to do the demonstration:
python3 -mvenv venv
venv/bin/python3 -mpip install -r requirements.txtNow we need to fetch data related to some asset. To do that, we can use https://github.com/dmotte/misc/blob/main/python-scripts/ohlcv-fetchers/yahoo-finance.py.
Note: in the following commands, replace the local path of the
invoke.shscript with the correct one.
bash ~/git/misc/python-scripts/ohlcv-fetchers/invoke.sh yahoo-finance '^GSPC' -i1wk -d2000-01-01T00Z -f'{:.6f}' > ohlcv-SPX500.csvNow that we have the data, we can compute the APY and MA values:
python3 -mapycalc -w104 --fmt-{rate,yield}='{:.6f}' ohlcv-SPX500.csv apy-SPX500.csvAnd finally display some nice plots using the plots.py script (which uses the Plotly Python library):
venv/bin/python3 plots.py -ra apy-SPX500.csvFor more details on how to use this command, you can also refer to its help message (--help).
If you want to contribute to this project, you can create a Python virtual environment ("venv") with the package in editable mode:
python3 -mvenv venv
venv/bin/python3 -mpip install -e .This will link the package to the original location, so any changes to the code will reflect directly in your environment (source).
If you want to run the tests:
venv/bin/python3 -mpip install pytest
venv/bin/python3 -mpytest test