========
Overview
========
A simple python tool for calculating ratios used to measure portfolio performance.
Ratios include alpha, beta, sharpe, volatility, upside capture, downside capture, sortino ratio,
treynor ratio, drawdown etc.
It also can be used to calculating portfolio returns like XIRR. (twirr, holding period return etc. will be added).
The tool is largely based on pandas and numpy and is capable of giving continuous (rolling) values of ratios
wherever required in the form of a pandas dataframe. All data (portfolio/ navs/ market) needs to be passed in
arguments based on the function getting called.
For example
- XIRR can be calculated from portfolio cashflows [(date, amount)].
- Sharpe ratio will need scheme/portfolio nav [(date, nav)].
- Alpha will need both scheme nav as well as benchmark nav.
For definitions of above terms, check Investopedia. You can find the examples of
few of these ratios here. https://www.valueresearchonline.com/funds/197/sbi-large-and-midcap-fund
* Free software: BSD 2-Clause License
Installation
============
::
pip install finance-calculator
You can also install the in-development version with::
pip install https://github.com/sprksh/finance-calculator/archive/master.zip
Documentation
=============
https://finance-calculator.readthedocs.io/
Development
===========
To run all the tests run::
tox
Note, to combine the coverage data from all the tox environments run:
.. list-table::
:widths: 10 90
:stub-columns: 1
- - Windows
- ::
set PYTEST_ADDOPTS=--cov-append
tox
- - Other
- ::
PYTEST_ADDOPTS=--cov-append tox
=====
Usage
=====
To use finance_calculator in a project::
import finance_calculator as fc
.. code-block:: python
drawdown = fc.get_drawdown(scheme_data, 250, 22)
volatility = fc.get_volatility(scheme_data, 250, 22)
sharpe = fc.get_sharpe(scheme_data, 250, 22)
sortino = fc.get_sortino(scheme_data, 250, 22)
treynor = fc.get_treynor(scheme_data, benchmark_data, 250, 22)
alpha = fc.get_alpha(scheme_data, benchmark_data, 250, 22)
beta = fc.get_beta(scheme_data, benchmark_data, 250, 22)
upside_capture = fc.get_upside_capture(scheme_data, benchmark_data, 250, 22)
downside_capture = fc.get_downside_capture(scheme_data, benchmark_data, 250, 22)
If you want only current value of a given ratio, you can use ``tail=True`` as a keyword argument
in all of these functions. With ``tail=False`` it will give a pandas dataframe with values in a
rolling window fashion.
The scheme data and the benchmark data can either be a pandas dataframe or list of tuples: (date, nav).
Also you can use it to calculate xirr:
.. code-block:: python
>>> import finance_calculator as fc
>>> cashflow_data = [
(datetime.date(2020, 3, 1), 10000),
(datetime.date(2020, 4, 1), 10000),
(datetime.date(2020, 5, 1), 10000),
(datetime.date(2020, 6, 1), 10000),
(datetime.date(2020, 7, 1), 10000),
(datetime.date(2020, 8, 1), -60000),
]
>>> xirr = fc.get_xirr(cashflow_data)
Changelog
=========
0.0.0 (2020-07-29)
------------------
* First release on PyPI.
Raw data
{
"_id": null,
"home_page": "https://github.com/sprksh/finance-calculator",
"name": "finance-calculator",
"maintainer": "",
"docs_url": null,
"requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*",
"maintainer_email": "",
"keywords": "",
"author": "Surya Prakash",
"author_email": "sprksh.j@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/ec/51/a71e74f84a173c16740475f5fbbdc8c0890cfc2e68f1b4140006790b6d84/finance-calculator-0.0.6.tar.gz",
"platform": "",
"description": "========\nOverview\n========\n\n\n\nA simple python tool for calculating ratios used to measure portfolio performance.\nRatios include alpha, beta, sharpe, volatility, upside capture, downside capture, sortino ratio,\ntreynor ratio, drawdown etc.\n\nIt also can be used to calculating portfolio returns like XIRR. (twirr, holding period return etc. will be added).\n\nThe tool is largely based on pandas and numpy and is capable of giving continuous (rolling) values of ratios\nwherever required in the form of a pandas dataframe. All data (portfolio/ navs/ market) needs to be passed in\narguments based on the function getting called.\n\nFor example\n- XIRR can be calculated from portfolio cashflows [(date, amount)].\n- Sharpe ratio will need scheme/portfolio nav [(date, nav)].\n- Alpha will need both scheme nav as well as benchmark nav.\n\n\nFor definitions of above terms, check Investopedia. You can find the examples of\nfew of these ratios here. https://www.valueresearchonline.com/funds/197/sbi-large-and-midcap-fund\n\n* Free software: BSD 2-Clause License\n\nInstallation\n============\n\n::\n\n pip install finance-calculator\n\nYou can also install the in-development version with::\n\n pip install https://github.com/sprksh/finance-calculator/archive/master.zip\n\n\nDocumentation\n=============\n\n\nhttps://finance-calculator.readthedocs.io/\n\n\nDevelopment\n===========\n\nTo run all the tests run::\n\n tox\n\nNote, to combine the coverage data from all the tox environments run:\n\n.. list-table::\n :widths: 10 90\n :stub-columns: 1\n\n - - Windows\n - ::\n\n set PYTEST_ADDOPTS=--cov-append\n tox\n\n - - Other\n - ::\n\n PYTEST_ADDOPTS=--cov-append tox\n\n=====\nUsage\n=====\n\nTo use finance_calculator in a project::\n\n\timport finance_calculator as fc\n\n\n.. code-block:: python\n\n drawdown = fc.get_drawdown(scheme_data, 250, 22)\n volatility = fc.get_volatility(scheme_data, 250, 22)\n sharpe = fc.get_sharpe(scheme_data, 250, 22)\n sortino = fc.get_sortino(scheme_data, 250, 22)\n treynor = fc.get_treynor(scheme_data, benchmark_data, 250, 22)\n alpha = fc.get_alpha(scheme_data, benchmark_data, 250, 22)\n beta = fc.get_beta(scheme_data, benchmark_data, 250, 22)\n upside_capture = fc.get_upside_capture(scheme_data, benchmark_data, 250, 22)\n downside_capture = fc.get_downside_capture(scheme_data, benchmark_data, 250, 22)\n\nIf you want only current value of a given ratio, you can use ``tail=True`` as a keyword argument\nin all of these functions. With ``tail=False`` it will give a pandas dataframe with values in a\nrolling window fashion.\n\nThe scheme data and the benchmark data can either be a pandas dataframe or list of tuples: (date, nav).\n\nAlso you can use it to calculate xirr:\n\n.. code-block:: python\n\n >>> import finance_calculator as fc\n >>> cashflow_data = [\n (datetime.date(2020, 3, 1), 10000),\n (datetime.date(2020, 4, 1), 10000),\n (datetime.date(2020, 5, 1), 10000),\n (datetime.date(2020, 6, 1), 10000),\n (datetime.date(2020, 7, 1), 10000),\n (datetime.date(2020, 8, 1), -60000),\n ]\n >>> xirr = fc.get_xirr(cashflow_data)\n\n\nChangelog\n=========\n\n0.0.0 (2020-07-29)\n------------------\n\n* First release on PyPI.\n\n\n",
"bugtrack_url": null,
"license": "BSD-2-Clause",
"summary": "A simple python tool for calculating ratios used to measure portfolio performance.",
"version": "0.0.6",
"project_urls": {
"Changelog": "https://finance-calculator.readthedocs.io/en/latest/changelog.html",
"Documentation": "https://finance-calculator.readthedocs.io/",
"Homepage": "https://github.com/sprksh/finance-calculator",
"Issue Tracker": "https://github.com/sprksh/finance-calculator/issues"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5cb2965e372ba6c4bf0a7b702ae4b6556d13c00c602cc01e4fc1e59cf838e8f0",
"md5": "4beebb13e7162769c1059898773c58af",
"sha256": "91a1eabf38538e144b0b965cdf87341650b27daeee943b407c81d00a55a47459"
},
"downloads": -1,
"filename": "finance_calculator-0.0.6-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "4beebb13e7162769c1059898773c58af",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*",
"size": 12605,
"upload_time": "2020-11-09T14:34:31",
"upload_time_iso_8601": "2020-11-09T14:34:31.155282Z",
"url": "https://files.pythonhosted.org/packages/5c/b2/965e372ba6c4bf0a7b702ae4b6556d13c00c602cc01e4fc1e59cf838e8f0/finance_calculator-0.0.6-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ec51a71e74f84a173c16740475f5fbbdc8c0890cfc2e68f1b4140006790b6d84",
"md5": "d929c2b2f3c5d95e71539dbc374848f2",
"sha256": "14696f99fce16d9a0bfaacb551d837a1d2519c486d6b0c9acb9487139fed8aae"
},
"downloads": -1,
"filename": "finance-calculator-0.0.6.tar.gz",
"has_sig": false,
"md5_digest": "d929c2b2f3c5d95e71539dbc374848f2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*",
"size": 133088,
"upload_time": "2020-11-09T14:34:35",
"upload_time_iso_8601": "2020-11-09T14:34:35.958777Z",
"url": "https://files.pythonhosted.org/packages/ec/51/a71e74f84a173c16740475f5fbbdc8c0890cfc2e68f1b4140006790b6d84/finance-calculator-0.0.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2020-11-09 14:34:35",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "sprksh",
"github_project": "finance-calculator",
"travis_ci": true,
"coveralls": true,
"github_actions": false,
"appveyor": true,
"requirements": [
{
"name": "numpy",
"specs": [
[
">=",
"1.18.0"
]
]
},
{
"name": "pandas",
"specs": [
[
">=",
"0.25.0"
]
]
}
],
"tox": true,
"lcname": "finance-calculator"
}