Skip to main content

pyrtfolio - Python package to generate stock portfolios

Project description

pyrtfolio - Python package to generate stock portfolios

Python Version PyPi Version Package Status Build Status Build Status Documentation Status codecov


pyrtfolio is a Python package created based on investpy data which aims to create custom stock portfolios. In investment, a portfolio is a grouping of financial assets as well as their fund counterparts; note that a portfolio can also consist of non-publicly tradable securities. So on, investpy data will be used to create custom portfolios from the data provided by the user such as the asset symbol, purchase date, number of bought shares, etc.


In order to get this package working you will need to install pyrtfolio via pip by typing the following command in the terminal:

$ pip install pyrtfolio==0.4

Every package used is listed in requirements.txt file, which can also be installed via pip:

$ pip install -r requirements.txt


Currently, pyrtfolio can just be used for generating stock portfolios, so on, an example is proposed below which creates a new portfolio and adds some equities/stocks. Note that the returned portfolio is a :obj:pandas.DataFrame, but the package is intended to generate either a CVS or a XLSX file.

from pyrtfolio.StockPortfolio import StockPortfolio

portfolio = StockPortfolio()


  stock_symbol stock_name stock_country stock_currency purchase_date  num_of_shares  ...  current_price  gross_current_value  total_dividends  net_current_value  total_gain_loss  total_gain_loss_percentage
0         BBVA       BBVA         spain            EUR    04/01/2018              2  ...          4.716                9.432           5.8788            15.3108           0.9108                    0.06325%
1          ELE     Endesa         spain            EUR    13/06/2019             15  ...         23.500              352.500         326.0250           678.5250         321.5250         0.9006302521008402%


As this is an open source project it is open to contributions, bug reports, bug fixes, documentation improvements, enhancements and ideas.

Also there is an open tab of issues where anyone can contribute opening new issues if needed or navigate through them in order to solve them or contribute to its solving. Remember that issues are not threads to describe multiple issues, this does not mean that issues can't be discussed, but if new issues are reported, a new issue should be open so to keep a structured project management.

Project details

Release history Release notifications | RSS feed

This version


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pyrtfolio, version 0.4
Filename, size File type Python version Upload date Hashes
Filename, size pyrtfolio-0.4.tar.gz (7.7 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page