Created
January 26, 2021 06:26
-
-
Save sailesh8584/a1c3f051d607e184d7511b885b8169ca to your computer and use it in GitHub Desktop.
Quantile based approach for historical stock analysis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import libraries | |
import pandas as pd | |
import matplotlib as mp | |
import matplotlib.pyplot as plt | |
# Historical stock data available in Excel file | |
# Asking the user to enter the stock for which the quantile analysis has to be done | |
stock = input ("Enter Stock Name: ") | |
xls = pd.ExcelFile('D:\Raw Stock Data1.xlsx') | |
df1 = pd.read_excel(xls,stock) | |
# Printing the quantile data for 10th, 20th, 30th, 40th.... upto 100th percentiles (represented as 0.1, 0.2 etc.) | |
print(df1['Close_Price'].quantile([0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1])) | |
print('Median Price of', stock, 'is Rs', df1['Close_Price'].median()) | |
# Box plot for visualizing the historical stock data in a jiffy | |
plt.boxplot(df1.Close_Price) | |
plt.title(stock) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment