{"id":14977359,"url":"https://github.com/anuragagrawaal/pyportfolioanalysis","last_synced_at":"2026-03-09T05:32:44.769Z","repository":{"id":55090226,"uuid":"327867737","full_name":"anuragagrawaal/pyPortfolioAnalysis","owner":"anuragagrawaal","description":"'Portfolio Analysis, methods for portfolio optimization'","archived":false,"fork":false,"pushed_at":"2021-01-26T09:35:23.000Z","size":3515,"stargazers_count":22,"open_issues_count":1,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-01T10:51:12.495Z","etag":null,"topics":["finance","financial-data","financial-engineering","jupyter-notebook","mathematical-modelling","optimization","optimization-methods","portfolio-construction","portfolio-management","portfolio-optimization","portfoliomanager","portfoliooptimization","python","python3","quantitative-finance","scipy","statistics"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anuragagrawaal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2021-01-08T10:14:07.000Z","updated_at":"2024-03-31T05:10:20.000Z","dependencies_parsed_at":"2022-08-14T11:40:35.134Z","dependency_job_id":null,"html_url":"https://github.com/anuragagrawaal/pyPortfolioAnalysis","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anuragagrawaal%2FpyPortfolioAnalysis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anuragagrawaal%2FpyPortfolioAnalysis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anuragagrawaal%2FpyPortfolioAnalysis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anuragagrawaal%2FpyPortfolioAnalysis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anuragagrawaal","download_url":"https://codeload.github.com/anuragagrawaal/pyPortfolioAnalysis/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238590593,"owners_count":19497351,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["finance","financial-data","financial-engineering","jupyter-notebook","mathematical-modelling","optimization","optimization-methods","portfolio-construction","portfolio-management","portfolio-optimization","portfoliomanager","portfoliooptimization","python","python3","quantitative-finance","scipy","statistics"],"created_at":"2024-09-24T13:55:30.803Z","updated_at":"2025-10-28T03:31:16.781Z","avatar_url":"https://github.com/anuragagrawaal.png","language":"Python","funding_links":["https://paypal.me/anuragagrawal1"],"categories":[],"sub_categories":[],"readme":"# pyPortfolioAnalysis\n\npyPortfolioAnalysis is a Python library for numeric method for portfolio optimisation.\n\n## Installation\n\nUse the package manager [pip](https://pip.pypa.io/en/stable/) to install [pyPortfolioAnalysis](https://pypi.org/project/pyPortfolioAnalysis/).\n\nDocumentation is available as docstring, [HTML](https://pyportfolioanalysis.readthedocs.io/en/latest/index.html) or [Text](https://github.com/anuragagrawaal/pyPortfolioAnalysis/blob/main/docs/doc_pyPortfolioAnalysis.txt)\n\n\n\n```bash\npip install pyPortfolioAnalysis\n```\n\n## Usage\n\n```python\nfrom pyPortfolioAnalysis import *\nimport pandas as pd\n#Sample portfolio optimisation\nimport pandas_datareader as pdr\naapl = pdr.get_data_yahoo('AAPL')\nmsft = pdr.get_data_yahoo('MSFT')\ntsla = pdr.get_data_yahoo('TSLA')\nuber = pdr.get_data_yahoo('UBER')\namzn = pdr.get_data_yahoo('AMZN')\nport = pd.DataFrame({'aapl': pd.DataFrame.reset_index(aapl).iloc[:,6], 'msft':pd.DataFrame.reset_index(msft).iloc[:,6],\n                   'tsla': pd.DataFrame.reset_index(tsla).iloc[:,6], 'uber': pd.DataFrame.reset_index(uber).iloc[:,6],\n                    'amzn': pd.DataFrame.reset_index(amzn).iloc[:,6]})\nport_ret = port.pct_change().dropna()\np1 = portfolio_spec(assets = ['AAPL', 'MSFT', 'TSLA', 'UBER', 'AMZN'])\nadd_constraint(p1, 'long_only')\nadd_constraint(p1, 'full_investment')\nadd_objective(p1, kind='return', name = 'mean', target = 0.002)\nadd_objective(p1, kind='risk', name = 'std', target = .018)\np1.port_summary()\nconstraints = get_constraints(p1)\np1.port_summary()\n\noptimize_portfolio(port_ret, p1, optimize_method = 'DEoptim', disp = False)\n```\n\n## Contributing\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\nPlease make sure to update tests as appropriate.\n\n## Authors\nAnurag Agrawal\n\n[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://paypal.me/anuragagrawal1)\n\n## License\n[GPL3](https://choosealicense.com/licenses/gpl-3.0/)\n\n## References\nBrian G. Peterson and Peter Carl (2018). PortfolioAnalytics: Portfolio Analysis, Including Numerical Methods for Optimization of Portfolios. R package version 1.1.0. https://CRAN.R-project.org/package=PortfolioAnalytics\n\nBoudt, Kris and Lu, Wanbo and Peeters, Benedict, Higher Order Comoments of Multifactor Models and Asset Allocation (June 16, 2014). Available at SSRN: http://ssrn.com/abstract=2409603 or http://dx.doi.org/10.2139/ssrn.2409603\n\nChriss, Neil A and Almgren, Robert, Portfolios from Sorts (April 27, 2005). Available at SSRN: http://ssrn.com/abstract=720041 or http://dx.doi.org/10.2139/ssrn.720041\n\nMeucci, Attilio, The Black-Litterman Approach: Original Model and Extensions (August 1, 2008). Shorter version in, THE ENCYCLOPEDIA OF QUANTITATIVE FINANCE, Wiley, 2010. Avail- able at SSRN: http://ssrn.com/abstract=1117574 or http://dx.doi.org/10.2139/ssrn.1117574\n\nMeucci, Attilio, Fully Flexible Views: Theory and Practice (August 8, 2008). Fully Flexible Views: Theory and Practice, Risk, Vol. 21, No. 10, pp. 97-102, October 2008. Available at SSRN: http://ssrn.com/abstract=1213325\n\nScherer, Bernd and Martin, Doug, Modern Portfolio Optimization. Springer. 2005.\n\nShaw, William Thornton, Portfolio Optimization for VAR, CVaR, Omega and Utility with General Return Distributions: A Monte Carlo Approach for Long-Only and Bounded Short Portfolios with Optional Robustness and a Simplified Approach to Covariance Matching (June 1, 2011). Available at SSRN: http://ssrn.com/abstract=1856476 or http://dx.doi.org/10.2139/ssrn.1856476\n\n[![Downloads](https://pepy.tech/badge/pyportfolioanalysis)](https://pepy.tech/project/pyportfolioanalysis)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanuragagrawaal%2Fpyportfolioanalysis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanuragagrawaal%2Fpyportfolioanalysis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanuragagrawaal%2Fpyportfolioanalysis/lists"}