Welcome to pyrtfolio’s documentation!

Introduction

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.

Installation

In order to get the package working you will need to install it 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

Usage

pyrtfolio usage is pretty simple, since until the current release (0.4), just the StockPortfolios are available with the basic data. So on, the one and only usage that can be currently done with this package consists on generating portfolios for the introduced stocks.

An example will be presented below to show the user how to use the package to generate his/her custom stock portfolios.

from pyrtfolio.StockPortfolio import StockPortfolio

portfolio = StockPortfolio()

portfolio.add_stock(stock_name='bbva',
                    stock_country='spain',
                    purchase_date='04/01/2018',
                    num_of_shares=2,
                    cost_per_share=7.2)

portfolio.add_stock(stock_name='endesa',
                    stock_country='spain',
                    purchase_date='13/06/2019',
                    num_of_shares=15,
                    cost_per_share=23.8)

print(portfolio.data)

Which outputs the following stock portfolio:

  stock_name stock_country purchase_date  num_of_shares  cost_per_share  current_price  gross_current_value
0       bbva         spain    04/01/2018              2             7.2          4.597                9.194
1     endesa         spain    13/06/2019             15            23.8         23.890              358.350

Further usage will be documented whenever the package is updated with new features. Make sure to watch and star the repo to be notified about all conversations!

API Reference

pyrtfolio.Stock

pyrtfolio.StockPortfolio

Contribute

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.

Indices and tables