PortfolioBuilder is a powerful tool designed to help investors construct optimal portfolios by analyzing stock information. Utilizing data from the yfinance package, this tool enables users to gather stock data for a specified range and compute returns, ultimately assisting in identifying companies that are suitable for portfolio inclusion based on correlation analysis.
- Data Gathering: Retrieve stock data for selected companies using the yfinance package.
- Customizable Time Range: Specify a date range with a daily time interval for data collection.
- Return Calculation: Compute the daily returns for each company based on closing values.
- Correlation Analysis: Generate a correlation matrix to identify relationships between companies.
- Portfolio Optimization: Exclude highly correlated companies to minimize risk and enhance diversification.
To use PortfolioBuilder, follow these simple steps:
-
Clone the repository: Navigate to your desired directory in your terminal and run the following command:
https://github.com/MauroAndretta/PortfolioBuilder.git
Then, change into the directory by executing:
cd PortfolioBuilder
-
Install the required packages: Ensure you have Python 3.7+ installed. Then, install the necessary packages by running:
pip install -r requirements.txt
or using the dedicated conda environment going first the appropiate conda
folder:
conda env create --name notebooks_portfolio_builder --file=notebooks_portfolio_builder.yml
Here's a step-by-step guide to using PortfolioBuilder:
-
Prepare your list of companies: Create a list in the
PortfolioBuilder.ipynb
the stock ticker symbols. -
Run the tool: Execute the main
PortfolioBuilder.ipynb
with your desired parameters.-
start-date and end-date: Define the time range for data collection.
-
range_analysis : Define the time range for data analysis. The valid options are:
1d, 5d, 1mo, 3mo, 6mo, 1y, 2y, 5y, 10y, ytd, max
-
companies: List the ticker symbols of companies you wish to include.
-
tickers = ["TCEHY", "HSBC", "RTX", "ROG.SW", "SSNLF", "TM", "UL", "NVDA",
"QBE. AX", "RIO", "MHR.SG", "RMS.PA", "ESLOY", "SPOT", "WMT",
"ENR.DE", "ABNB", "BAYN.DE", "MMM", "EL.PA", "AMZN"]
- Analyze the results: Review the generated correlation matrix and identify suitable companies for your portfolio.
Contributions are welcome!
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions, feel free to open an issue on GitHub or contact me at [email protected].
- Special thanks to the contributors of the yfinance package.
- Inspired by various portfolio optimization techniques and financial analysis tools.
Stay updated with our latest developments: