Stock clustering and portfolio diversification. Suitable features. - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: Stock clustering and portfolio diversification. Suitable features. (/thread-41846.html) |
Stock clustering and portfolio diversification. Suitable features. - timurkanaz - Mar-26-2024 Hi. I want to conduct a research. I want to cluster stocks and then make a safe diversified portfolio. I want to work with annual data. From price data I took beta coefficient and average price change. I also want to use companies reports to take some fundamental data, especially multipliers. Aiming to build a diversified portfolio, what multipliers can I take from the company's annual reports? Maybe someone had an experience? Thanks in advance for answers! RE: Stock clustering and portfolio diversification. Suitable features. - Larz60+ - Mar-27-2024 The yahoo finance package will get you the historic information you need reference: https://pypi.org/project/yfinance/ simple code to get one years data: import yfinance as yf import pandas as pd from pathlib import Path # supply ticker symbol: symbol = "NVDA" ticker = yf.Ticker(symbol) # get one years historical data data is formatted as (data will be pandas dataframe) data = ticker.history(period="1y") # to save as csv (change path as desired) currentpath = Path(".") savefilename = currentpath / f"{symbol}_History_1yr.csv" data.to_csv(savefilename, index=False)first few lines of file : as for the clustering, see this click on Lecture 7 for slides. Also, this blog looks interesting |