{ "info": { "author": "Frank Milthaler", "author_email": "f.milthaler@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Education", "Intended Audience :: Financial and Insurance Industry", "Intended Audience :: Other Audience", "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3 :: Only" ], "description": "

\n \n

\n\n

\n \n pypi\n \n \n travis\n \n \n \"docs\"\n \n \n \"license\"\n \n

\n\n# FinQuant\n*FinQuant* is a program for financial **portfolio management, analysis and optimisation**.\n\nThis README only gives a brief overview of *FinQuant*. The interested reader should refer to its [documentation](https://finquant.readthedocs.io \"FinQuant Documentation\").\n\n## Table of contents\n - [Motivation](#Motivation)\n - [Installation](#Installation)\n - [Portfolio Management](#Portfolio-Management)\n - [Returns](#Returns)\n - [Moving Averages](#Moving-Averages)\n - [Portfolio Optimisation](#Portfolio-Optimisation)\n - [Efficient Frontier](#Efficient-Frontier)\n - [Monte Carlo](#Monte-Carlo)\n - [Examples](#Examples)\n - [Building a portfolio with data from web](#Building-a-portfolio-with-data-from-web)\n - [Building a portfolio with preset data](#Building-a-portfolio-with-preset-data)\n - [Analysis of a portfolio](#Analysis-of-a-portfolio)\n - [Optimisation of a portfolio](#Optimisation-of-a-portfolio)\n\n## Motivation\nWithin a few lines of code, *FinQuant* can generate an object that holds your stock prices of your desired financial portfolio, analyses it, and can create plots of different kinds of *Returns*, *Moving Averages*, *Moving Average Bands with buy/sell signals*, and *Bollinger Bands*. It also allows for the optimisation based on the *Efficient Frontier* or a *Monte Carlo* run of the financial portfolio within a few lines of code. Some of the results are shown here.\n\n### Automatically generating an instance of `Portfolio`\n`finquant.portfolio.build_portfolio` is a function that eases the creating of your portfolio. See below for one of several ways of using `build_portfolio`.\n```\nfrom finquant.portfolio import build_portfolio\nnames = ['GOOG', 'AMZN', 'MCD', 'DIS']\nstart_date = '2015-01-01'\nend_date = '2017-12-31'\npf = build_portfolio(names=names,\n start_date=start_date,\n end_date=end_date)\n```\n`pf` is an instance of `finquant.portfolio.Portfolio`, which contains the prices of the stocks in your portfolio. Then...\n```\npf.data.head(3)\n```\nyields\n```\n GOOG AMZN MCD DIS\nDate\n2015-01-02 524.81 308.52 85.783317 90.586146\n2015-01-05 513.87 302.19 84.835892 89.262380\n2015-01-06 501.96 295.29 84.992263 88.788916\n```\n\n### Portfolio properties\nNicely printing out the portfolio's properties\n```\npf.properties()\n```\nDepending on the stocks within your portfolio, the output looks something like the below.\n```\n----------------------------------------------------------------------\nStocks: GOOG, AMZN, MCD, DIS\nTime window/frequency: 252\nRisk free rate: 0.005\nPortfolio expected return: 0.266\nPortfolio volatility: 0.156\nPortfolio Sharpe ratio: 1.674\n\nSkewness:\n GOOG AMZN MCD DIS\n0 0.124184 0.087516 0.58698 0.040569\n\nKurtosis:\n GOOG AMZN MCD DIS\n0 -0.751818 -0.856101 -0.602008 -0.892666\n\nInformation:\n Allocation Name\n0 0.25 GOOG\n1 0.25 AMZN\n2 0.25 MCD\n3 0.25 DIS\n----------------------------------------------------------------------\n```\n\n### Cumulative Return\n```\npf.comp_cumulative_returns().plot().axhline(y = 0, color = \"black\", lw = 3)\n```\nyields\n

\n \n

\n\n### Band Moving Average (Buy/Sell Signals)\n```\nfrom finquant.moving_average import compute_ma, ema\n# get stock data for disney\ndis = pf.get_stock(\"DIS\").data.copy(deep=True)\nspans = [10, 50, 100, 150, 200]\nma = compute_ma(dis, ema, spans, plot=True)\n```\nyields\n

\n \n

\n\n### Bollinger Band\n```\nfrom finquant.moving_average import plot_bollinger_band\n# get stock data for disney\ndis = pf.get_stock(\"DIS\").data.copy(deep=True)\nspan=20\nplot_bollinger_band(dis, sma, span)\n```\nyields\n

\n \n

\n\n### Portfolio Optimisation\n```\n# performs and plots results of Monte Carlo run (5000 iterations)\nopt_w, opt_res = pf.mc_optimisation(num_trials=5000)\n# plots the results of the Monte Carlo optimisation\npf.mc_plot_results()\n# plots the Efficient Frontier\npf.ef_plot_efrontier()\n# plots optimal portfolios based on Efficient Frontier\npf.ef.plot_optimal_portfolios()\n# plots individual plots of the portfolio\npf.plot_stocks()\n```\n

\n \n

\n\n## Installation\nAs it is common for open-source projects, there are several ways to get hold of the code. Choose whichever suits you and your purposes best.\n\n### Dependencies\n*FinQuant* depends on the following Python packages:\n - python>=3.5.0\n - numpy>=1.15\n - pandas>=0.24\n - matplotlib>=1.5.1\n - quandl>=3.4.5\n - yfinance>=0.1.43\n - scipy>=1.2.0\n - pytest>=2.8.7\n\n### From PyPI\n*FinQuant* can be obtained from PyPI\n\n```pip install FinQuant```\n\n### From GitHub\nGet the code from GitHub:\n\n```git clone https://github.com/fmilthaler/FinQuant.git```\n\nThen inside `FinQuant` run:\n\n```python setup.py install```\n\nAlternatively, if you do not wish to install *FinQuant*, you can also download/clone it as stated above, and then make sure to add it to your ``PYTHONPATH``.\n\n## Portfolio Management\nThis is the core of *FinQuant*. `finquant.portfolio.Portfolio` provides an object that holds prices of all stocks in your portfolio, and automatically computes the most common quantities for you. To make *FinQuant* an user-friendly program, that combines data analysis, visualisation and optimisation, the object provides interfaces to the main features that are provided in the modules in `./finquant/`.\n\nTo learn more about the object, please read through the [documentation](https://finquant.readthedocs.io/en/latest/ \"FinQuant Documentation\"), docstring of the module/class, and/or have a look at the examples.\n\n`finquant.portfolio.Portfolio` also provides a function `build_portfolio` which is designed to automatically generate an instance of `Portfolio` for the user's convenience. For more information on how to use `build_portfolio`, please refer to the [documentation](https://finquant.readthedocs.io/en/latest/ \"FinQuant Documentation\"), its `docstring` and/or have a look at the examples.\n\n## Returns\nDaily returns of stocks are often computed in different ways. *FinQuant* provides three different ways of computing the daily returns in `finquant.returns`:\n1. The cumulative return: \n2. Percentage change of daily returns: \n3. Log Return: \n\nIn addition to those, the module provides the function `historical_mean_return(data, freq=252)`, which computes the historical mean of the daily returns over a time period `freq`.\n\n## Moving Averages\nThe module `finquant.moving_average` allows the computation and visualisation of Moving Averages of the stocks listed in the portfolio is also provided. It entails functions to compute and visualise the\n - `sma`: Simple Moving Average, and\n - `ema`: Exponential Moving Average.\n - `compute_ma`: a Band of Moving Averages (of different time windows/spans) including Buy/Sell signals\n - `plot_bollinger_band`: a Bollinger Band for\n - `sma`,\n - `ema`.\n\n## Portfolio Optimisation\n### Efficient Frontier\nAn implementation of the Efficient Frontier (`finquant.efficient_frontier.EfficientFrontier`) allows for the optimisation of the portfolio for\n - `minimum_volatility` Minimum Volatility,\n - `maximum_sharpe_ratio` Maximum Sharpe Ratio\n - `efficient_return` Minimum Volatility for a given expected return\n - `efficient_volatility` Maximum Sharpe Ratio for a given target volatility\n\nby performing a numerical solve to minimise/maximise an objective function.\n\nOften it is useful to visualise the *Efficient Frontier* as well as the optimal solution. This can be achieved with the following methods:\n - `plot_efrontier`: Plots the *Efficient Frontier*. If no minimum/maximum Return values are provided, the algorithm automatically chooses those limits for the *Efficient Frontier* based on the minimum/maximum Return values of all stocks within the given portfolio.\n - `plot_optimal_portfolios`: Plots markers of the portfolios with the Minimum Volatility and Maximum Sharpe Ratio.\n\nFor reasons of user-friendliness, interfaces to these functions are provided in `finquant.portfolio.Portfolio`. Please have a look at the [documentation](https://finquant.readthedocs.io \"FinQuant Documentation\").\n\n### Monte Carlo\nAlternatively a *Monte Carlo* run of `n` trials can be performed to find the optimal portfolios for\n - minimum volatility,\n - maximum Sharpe ratio\n\nThe approach branded as *Efficient Frontier* should be the preferred method for reasons of computational effort and accuracy. The latter approach is only included for the sake of completeness, and creation of beautiful plots.\n\n## Examples\nFor more information about the project and details on how to use it, please\nlook at the examples provided in `./example`.\n\n**Note**: In the below examples, `pf` refers to an instance of `finquant.portfolio.Portfolio`, the object that holds all stock prices and computes its most common quantities automatically. To make *FinQuant* a user-friendly program, that combines data analysis, visualisation and optimisation, the object also provides interfaces to the main features that are provided in the modules in `./finquant/` and are discussed throughout this README.\n\n### Building a portfolio with data from web\n`./example/Example-Build-Portfolio-from-web.py`: Shows how to use *FinQuant* to build a financial portfolio by downloading stock price data through the Python package `quandl`/`yfinance`.\n\n### Building a portfolio with preset data\n`./example/Example-Build-Portfolio-from-file.py`: Shows how to use *FinQuant* to build a financial portfolio by providing stock price data yourself, e.g. by reading data from disk/file.\n\n### Analysis of a portfolio\n`./example/Example-Analysis.py`: This example shows how to use an instance of `finquant.portfolio.Portfolio`, get the portfolio's quantities, such as\n - Expected Returns,\n - Volatility,\n - Sharpe Ratio.\n\nIt also shows how to extract individual stocks from the given portfolio. Moreover it shows how to compute and visualise:\n - the different Returns provided by the module `finquant.returns`,\n - *Moving Averages*, a band of *Moving Averages*, and a *Bollinger Band*.\n\n### Optimisation of a portfolio\n`./example/Example-Optimisation.py`: This example focusses on the optimisation of a portfolio. To achieve this, the example shows the usage of `finquant.efficient_frontier.EfficientFrontier` for optimising the portfolio, for the\n - Minimum Volatility\n - Maximum Sharpe Ratio\n - Minimum Volatility for a given target Return\n - Maximum Sharpe Ratio for a given target Volatility.\n\nFurthermore, it is also shown how the entire *Efficient Frontier* and the optimal portfolios can be computed and visualised. If needed, it also gives an example of plotting the individual stocks of the given portfolio within the computed *Efficient Frontier*.\n\nAlso, the optimisation of a portfolio and its visualisation based on a *Monte Carlo* is shown.\n\nFinally, *FinQuant*'s visualisation methods allow for overlays, if this is desired. Thus, with only the following few lines of code, one can create an overlay of the *Monte Carlo* run, the *Efficient Frontier*, its optimised portfolios for *Minimum Volatility* and *Maximum Sharpe Ratio*, as well as the portfolio's individual stocks.\n\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "https://github.com/fmilthaler/FinQuant/archive/v0.2.tar.gz", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/fmilthaler/FinQuant", "keywords": "finance,portfolio,investment,numerical,optimisation,monte carlo,efficient frontier,quantitative,quant", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "FinQuant", "package_url": "https://pypi.org/project/FinQuant/", "platform": "", "project_url": "https://pypi.org/project/FinQuant/", "project_urls": { "Documentation": "https://finquant.readthedocs.io", "Download": "https://github.com/fmilthaler/FinQuant/archive/v0.2.tar.gz", "Homepage": "https://github.com/fmilthaler/FinQuant" }, "release_url": "https://pypi.org/project/FinQuant/0.2/", "requires_dist": [ "quandl", "yfinance", "numpy", "pandas", "scipy", "matplotlib", "pytest" ], "requires_python": ">=3.5", "summary": "A program for financial portfolio management, analysis and optimisation", "version": "0.2" }, "last_serial": 5531183, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "d18c195a4822b1e5300e2c4f83d31191", "sha256": "98130a20ea4e91f332dfbfb86d0b1f621170eabe15697453d1c64e4b38f438eb" }, "downloads": -1, "filename": "FinQuant-0.1.tar.gz", "has_sig": false, "md5_digest": "d18c195a4822b1e5300e2c4f83d31191", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 23447, "upload_time": "2019-01-29T21:25:40", "url": "https://files.pythonhosted.org/packages/e1/45/19c3016cee7af219e1ae603defcaa94594430b8a511f9a82610efc2403cb/FinQuant-0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "7a13eebe6a5f492646cde0a17c90ce5b", "sha256": "b80a8dd42b62d389a7099a80ba7b28559c19feef5499bbc03c48bfb00775e5b3" }, "downloads": -1, "filename": "FinQuant-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "7a13eebe6a5f492646cde0a17c90ce5b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 27110, "upload_time": "2019-01-30T15:23:04", "url": "https://files.pythonhosted.org/packages/4a/1c/581da55142765dfe3ff0b3fc60908c7e5934e3422a9fc72488caa1e1f39e/FinQuant-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c16ae947b858ec02d9917a8bdc2a62e0", "sha256": "8e42cb466a7dc4dfdaf8a265ad8dab4e862401fd21ad6de9d99929a53b2c4b7b" }, "downloads": -1, "filename": "FinQuant-0.1.1.tar.gz", "has_sig": false, "md5_digest": "c16ae947b858ec02d9917a8bdc2a62e0", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 23623, "upload_time": "2019-01-30T15:23:06", "url": "https://files.pythonhosted.org/packages/52/54/a39ec1c4c6347b2c83a4b6af4115eae9bb60a104737a11d662afe95298e4/FinQuant-0.1.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "c6ba658dc54a88d1e19cdb0caffa4046", "sha256": "2d29318084be6015e3c369956f07fdc96db562ebf65091ec6f93c96e167587d6" }, "downloads": -1, "filename": "FinQuant-0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "c6ba658dc54a88d1e19cdb0caffa4046", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 28070, "upload_time": "2019-07-14T14:43:47", "url": "https://files.pythonhosted.org/packages/06/3c/901a7e2d758b7f6520d1ecc6d3e087667b3c9094330ddf0f3cac82ef9c96/FinQuant-0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "13d0cf10eb74412928946f39b0ef39e2", "sha256": "d45c1ec8629225c5c87ec793f84d3127c80989827968319771c773b64dd15834" }, "downloads": -1, "filename": "FinQuant-0.2.tar.gz", "has_sig": false, "md5_digest": "13d0cf10eb74412928946f39b0ef39e2", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 24672, "upload_time": "2019-07-14T14:43:49", "url": "https://files.pythonhosted.org/packages/94/d8/4d7ee8332c14f95df5ab3a4f3801e831999bb3dc99e6665cbc8aeb39bcaf/FinQuant-0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c6ba658dc54a88d1e19cdb0caffa4046", "sha256": "2d29318084be6015e3c369956f07fdc96db562ebf65091ec6f93c96e167587d6" }, "downloads": -1, "filename": "FinQuant-0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "c6ba658dc54a88d1e19cdb0caffa4046", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 28070, "upload_time": "2019-07-14T14:43:47", "url": "https://files.pythonhosted.org/packages/06/3c/901a7e2d758b7f6520d1ecc6d3e087667b3c9094330ddf0f3cac82ef9c96/FinQuant-0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "13d0cf10eb74412928946f39b0ef39e2", "sha256": "d45c1ec8629225c5c87ec793f84d3127c80989827968319771c773b64dd15834" }, "downloads": -1, "filename": "FinQuant-0.2.tar.gz", "has_sig": false, "md5_digest": "13d0cf10eb74412928946f39b0ef39e2", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 24672, "upload_time": "2019-07-14T14:43:49", "url": "https://files.pythonhosted.org/packages/94/d8/4d7ee8332c14f95df5ab3a4f3801e831999bb3dc99e6665cbc8aeb39bcaf/FinQuant-0.2.tar.gz" } ] }