Investment Analysis — Dataset

Getting the dataset for investment analysis.

alpha2phi
3 min readSep 12, 2022

--

Investment Analysis — Dataset

In this article, we will use open-source libraries to create the dataset for investment analysis purposes.

This article is part of the Investment Analysis series.

The source code is available in this repository.

Getting Started

Previously we talked about open source investment research using the OpenBB Terminal. For every market, there could be thousands of stocks to research. Without any automation, it becomes challenging to short-list promising stocks worth spending our time researching.

In an earlier article, we use Python to gather stock data and perform fundamental analysis. Leveraging the same idea, let’s create a better dataset for analysis purposes.

Python Libraries — investpy and yfinance

We will use the investpy and yfinance Python libraries to gather data from different sources.

Using the investpy library, we can get a list of stocks for a particular market. With the information, we can get the stock details, financial information, dividend history, cash flow, earning dates, news, recommendations, and other information from the respective sources using investpy or yfinance library.

The Code

We will get started by developing the code to download stock information (e.g. EPS, PEG, yield, etc), stock financials, and the last 10 years' dividend history.

Downloader

The Downloader is a class decorator we use to manage the downloading. It can resume the download from the point it gets stopped previously.

The downloaded information is saved into an Excel file to make it easy for analysis purposes.

Using the Downloader, we can download any information we need easily.

Stock Information

--

--

alpha2phi

Software engineer, Data Science and ML practitioner.