<jupyter_start><jupyter_text>Determine If A Stock Is Under/Over Valued Using Python Programming<jupyter_code># Finding undervalued stocks using this simple technique
# Using Profit to Earning P/E Ratio
#Concept : if company earnings = 4$ per share and the company is trading at 100$, P/E = 100/4 = 25, The stock is trading at 25 times the earnings
#get the P/E ratio of the particular sector
# get the P/E ratio of the stock's individually
#import the libraries
import pandas as pd;
import numpy as np;
# Load the CSV From the local system
from google.colab import files;
files.upload()
# download and load a csv with TICKER, PE_RATIO, CURRENT_PRICE, EARNINGS_PER_SHARE
df = pd.read_csv('MW-NIFTY-MIDCAP-50-20-Aug-2021.csv');
df = pd.read_csv('MW-NIFTY-NEXT-50-20-Aug-2021.csv');
df = pd.read_csv('MW-NIFTY-50-20-Aug-2021.csv');
df
#set the index to the Stock Ticker like ONGC
df = df.set_index('SYMBOL \n')
#calculate the mean P/E ratio for the IT stocks in the dataset
PE_Ratio_Mean = df.PERatio.mean()
PE_Ratio_Mean
#calculate and print the fare market value
#create a new column in the dataset for the fare_market_value
df['fare_market_value'] = PE_Ratio_Mean * df['Earnings_Per_Share'];
df
# If the current_price of the stock is lesser than the newly created fare_market_value, then the particular stock is undervalued
df['Ratio'] =  df['current_price'] / df['fare_market_value'];
#create a new column to store a label for over valued or under labeled
df['valued'] = np.where(df['Ratio'] <1.0, 'Under Valued', 'Fair or Over Valued');
df
#create a column to show the percentage that stock is over valued or undervalued
df['value_percent'] = abs(df['Ratio'] - 1) * 100
#show only a list of stocks that are under valued 
#prints the stock tickers that only under valued
df[df.valued == 'Under Valued'].index<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09516041326808047, 'fraction_numerical': 0.022838499184339316, 'mean_word_length': 5.032786885245901, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '96707', 'license': 'MIT', 'n_tokens_mistral': 635, 'n_tokens_neox': 581, 'n_words': 238, 'path': 'Determine_If_A_Stock_Is_Under_Over_Valued_Using_Python_Programming.ipynb', 'repo_name': 'Benjamindavid03/StockSelection', 'size': '1839'}