Skip to main content


Showing posts with the label Risk Analysis

Stock Risk Analysis App in Python

In this article, I’ll explain about how we can perform risk analysis for certain publicly listed stocks. To perform this, we will look at the data of certain time frames and will try to analyze which stock is riskier than the other one based on the price deviation and the average price. Throughout this exercise, I’ll be using Python as a programming language. Required Packages Here is the list of packages we need to be installed before proceeding: pandas numpy yfinance matplotlib Once packages are installed, we are good to go. Importing Libraries import pandas as pd import numpy as np import yfinance as yf import matplotlib . pyplot as pyplot Select Stocks and Duration Next, we need to select the list of stocks we want to analyze and the duration. Here, I’m going with Microsoft and Tesla stocks, and the duration I’m selecting is from 2018–01–01 to 2022–02–01. stocks = yf . download ( [ ‘MSFT’ , ’TSLA’ ] , start = ” 2018 – 01 – 01 ", end=”2022–02–01&quo