pyrtfolio - Python package to generate stock portfolios
Project description
pyrtfolio - Python package to generate stock portfolios
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 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
Usage
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()
portfolio.add_stock(stock_symbol='BBVA',
stock_country='spain',
purchase_date='04/01/2018',
num_of_shares=2,
cost_per_share=7.2)
portfolio.add_stock(stock_aymbol='ELE',
stock_country='spain',
purchase_date='13/06/2019',
num_of_shares=15,
cost_per_share=23.8)
print(portfolio.data)
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%
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file pyrtfolio-0.4.tar.gz
.
File metadata
- Download URL: pyrtfolio-0.4.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c5d582244430f09d07183a4ee1a4edc24ba5bca04ebe5a83bc940a582d0f22a0 |
|
MD5 | 31dfd13a364d1efac25838469ed0033d |
|
BLAKE2b-256 | b194c79fa0574621827cb087f8681c93bfb477e0e35df1e580c5d01a892bf411 |