normalized_data
This commit is contained in:
parent
4ed823f7bb
commit
fa9ca0cd8b
4 changed files with 224 additions and 20 deletions
91
Elaborated_Data/Not_Normalized.csv
Normal file
91
Elaborated_Data/Not_Normalized.csv
Normal file
|
@ -0,0 +1,91 @@
|
|||
,Ticker,Valuation,Financial Health,Estimated Growth,Past Performance
|
||||
0,AAPL,2.8478,0.3300066233140655,8.02%,1.55
|
||||
1,ABBV,0.0,0.4558265192176074,-4.20%,1.47
|
||||
2,ABT,22.469,0.23799672210430156,-2.70%,16.58
|
||||
3,ACN,2.9116,0.06722571231732856,9.00%,3.05
|
||||
4,ADBE,1.568,0.17055034051168783,13.98%,2.39
|
||||
5,AMAT,3.3254,0.20233198612253658,12.98%,6.8
|
||||
6,AMGN,1.2905,0.6942628494138864,1.72%,3.81
|
||||
7,AMZN,2.2453,0.3043878047624995,-278.70%,-42.47
|
||||
8,APD,1.739,0.30713303133498127,9.38%,1.68
|
||||
9,AVGO,1.0479,0.5382865599649199,8.30%,2.43
|
||||
10,BA,0.0,0.4062502291946284,93.80%,987.5
|
||||
11,BAC,4.1895,0.10656449190006939,3.36%,7.07
|
||||
12,BDX,2.4258,0.3350369526050667,9.85%,5.53
|
||||
13,BIDU,5.8388,0.2336580786908559,0.85%,31.9
|
||||
14,BMY,0.0,0.4175920917257984,3.75%,6.57
|
||||
15,CAT,1.4198,0.4427787540795467,12.87%,16.75
|
||||
16,CCI,5.0871,0.7302196958058074,-4.38%,1.05
|
||||
17,CHTR,0.362,0.6762752812866708,16.84%,-2.77
|
||||
18,CMCSA,0.8061,0.36824333439977797,7.42%,9.12
|
||||
19,CME,4.0654,0.02071438551860043,4.38%,2.09
|
||||
20,COST,3.6281,0.1367131402584969,9.27%,0.74
|
||||
21,CRM,1.3911,0.142520409918158,19.56%,15.89
|
||||
22,CSCO,1.923,0.09272746243739566,7.32%,2.08
|
||||
23,CSX,2.6633,0.43208447851873283,8.19%,5.95
|
||||
24,CVS,1.4292,0.3195504115656207,4.00%,6.24
|
||||
25,CVX,2.7809,0.0905633873865484,-7.68%,7.46
|
||||
26,D,10.427,0.45626394493235223,5.60%,2.08
|
||||
27,DE,1.143,0.5900895001091465,13.70%,3.41
|
||||
28,DHR,3.3251,0.23320790216368767,2.81%,12.23
|
||||
29,DIS,1.0565,0.2393431754764402,21.87%,2.8
|
||||
30,DUK,3.0382,0.43067554645954603,5.80%,-0.19
|
||||
31,EXC,2.5916,0.43109620840856333,6.30%,3.11
|
||||
32,FDX,1.3726,0.4440454677936462,4.78%,-3.7
|
||||
33,FIS,0.7185,0.327646615802744,2.05%,1.73
|
||||
34,GE,3.1891,0.1363210759278175,25.50%,25.71
|
||||
35,GILD,0.5725,0.40789643803736503,2.25%,9.03
|
||||
36,GOOGL,1.1345,0.0717094597703327,17.61%,-6.07
|
||||
37,GS,2.0757,0.19895968790637192,1.11%,0.86
|
||||
38,HD,1.7271,0.658826607364772,2.52%,4.12
|
||||
39,HON,2.2588,0.3199906484311073,7.80%,3.59
|
||||
40,IBM,2.0869,0.4615188907263707,6.62%,2.02
|
||||
41,INTC,6.2729,0.27130159792340114,6.02%,-12.15
|
||||
42,ISRG,3.3782,2.0,15.96%,0.63
|
||||
43,JNJ,4.3545,0.21165238181643523,4.34%,4.52
|
||||
44,JPM,3.2773,0.12896465432169654,-4.33%,10.71
|
||||
45,KO,3.5034,0.43530039834093054,5.97%,5.0
|
||||
46,LIN,3.4208,0.23381232255815113,10.41%,7.12
|
||||
47,LLY,1.8737,0.3552019261516468,23.67%,-2.53
|
||||
48,LMT,3.2504,0.28559920910988246,10.89%,0.18
|
||||
49,LOW,1.1925,0.8692687837466825,7.63%,4.73
|
||||
50,LRCX,1.7507,0.2601092917188427,0.01%,10.79
|
||||
51,MA,1.5338,0.3998356276967331,20.29%,4.6
|
||||
52,MCD,3.6629,0.9219276110270812,8.57%,6.31
|
||||
53,MCO,2.0425,0.5378762144167403,12.21%,8.25
|
||||
54,MDT,2.4965,0.29880808209573584,1.58%,0.38
|
||||
55,MMC,2.2618,0.4360265440363234,9.73%,2.76
|
||||
56,MMM,4.4859,0.3460094697777588,1.64%,5.13
|
||||
57,MO,8.8684,0.6893770705479824,3.92%,0.0
|
||||
58,MRK,2.3138,0.28115610113594725,8.17%,7.5
|
||||
59,MSFT,2.3007,0.15923154637873335,12.54%,2.63
|
||||
60,NEE,2.5982,0.42720296086648885,8.80%,9.85
|
||||
61,NFLX,1.635,0.2917160508782066,21.72%,10.98
|
||||
62,NKE,2.0436,0.32814540136836057,8.56%,19.24
|
||||
63,NSC,2.9593,0.3826495442824683,5.47%,4.54
|
||||
64,NVDA,3.5519,0.28786848623184885,21.20%,-17.57
|
||||
65,ORCL,1.9008,0.6975459656587145,9.06%,3.73
|
||||
66,PEP,3.3521,0.44890479568366976,7.80%,5.74
|
||||
67,PFE,1.1173,0.17682107451636622,-14.72%,19.04
|
||||
68,PG,4.3277,0.30530408590666747,5.38%,1.23
|
||||
69,PM,2.4533,0.7592813406380922,7.40%,4.23
|
||||
70,PYPL,0.5571,0.1394518218093805,16.48%,7.28
|
||||
71,SCHW,1.6392,0.06864791979295796,10.27%,3.54
|
||||
72,SO,3.4609,0.4493306420493336,7.30%,9.94
|
||||
73,SPG,13.079,0.7646523728202831,8.60%,10.74
|
||||
74,SPGI,2.2617,0.1971656133109764,12.70%,2.88
|
||||
75,T,4.4541,0.3888937394137295,-0.64%,7.17
|
||||
76,TGT,0.8275,0.3520577481953689,-7.51%,-17.78
|
||||
77,TMO,3.8993,0.372467197701198,8.57%,4.94
|
||||
78,TMUS,0.3603,0.5235163412997864,65.36%,6.97
|
||||
79,TSLA,1.6016,0.030817776651733787,10.66%,7.84
|
||||
80,TXN,3.0209,0.3465434633812457,10.00%,7.62
|
||||
81,UNH,1.5703,0.24883054438291166,13.04%,4.74
|
||||
82,UNP,2.7512,0.5308179723502304,9.01%,1.69
|
||||
83,UPS,2.4608,0.3656374239842635,3.62%,2.54
|
||||
84,USB,1.0216,0.1449638542916892,3.84%,2.21
|
||||
85,V,1.4973,0.26257002842072025,14.65%,7.49
|
||||
86,VZ,6.652,0.47213514915968613,-0.26%,0.4
|
||||
87,WFC,0.7586,0.13489874893977946,5.68%,-6.79
|
||||
88,WMT,3.6193,0.24202631265480146,5.09%,5.9
|
||||
89,XOM,1.809,0.11220696806192149,-10.74%,10.51
|
|
91
Elaborated_Data/normalized_data.csv
Normal file
91
Elaborated_Data/normalized_data.csv
Normal file
|
@ -0,0 +1,91 @@
|
|||
,Unnamed: 0,Ticker,Valuation,Financial Health,Estimated Growth,Past Performance
|
||||
0,0,AAPL,100.37236494563554,71.91074584729277,108.98,50.22864143559244
|
||||
1,1,ABBV,128.0757006911408,99.32777907526436,62.12,49.98829507192271
|
||||
2,2,ABT,3.903272785624139,51.86114637294232,67.37,105.48825740982531
|
||||
3,3,ACN,99.73436729144395,14.648951782564373,112.86,54.87552258889583
|
||||
4,4,ADBE,113.09474091365172,37.16410921556946,131.72,52.79831233698156
|
||||
5,5,AMAT,95.59921096703175,44.08955155117806,128.07,67.58636122420656
|
||||
6,6,AMGN,115.8115875705338,151.28471911882195,83.95,57.3294184458553
|
||||
7,7,AMZN,106.38865357852976,66.32822652913868,0.0,1.962719193567985
|
||||
8,8,APD,111.41045537738816,66.9264305541503,114.35,50.62083916878424
|
||||
9,9,AVGO,118.16743710104177,117.29639732052325,110.09,52.92275822659215
|
||||
10,10,BA,128.0757006911408,88.52475955980067,199.83,200.0
|
||||
11,11,BAC,87.02885672660139,23.22114634068666,90.4,68.55624922628604
|
||||
12,12,BDX,104.5891409798187,73.00688969901516,116.18,63.11751643656517
|
||||
13,13,BIDU,71.29243525267314,50.91572570018997,80.58,158.348982708326
|
||||
14,14,BMY,128.0757006911408,90.99623054339271,91.95,66.76549150803656
|
||||
15,15,CAT,114.54840127334644,96.48458001066467,127.67,106.16594582416573
|
||||
16,16,CCI,78.32852868831253,159.11996683716484,61.5,48.73910491310664
|
||||
17,17,CHTR,124.70829183516719,147.3651025153211,141.6,38.36719142424548
|
||||
18,18,CMCSA,120.49495151602524,80.24279199020978,106.6,76.12367142225216
|
||||
19,19,CME,88.25088121502138,4.513809139501069,94.45,51.87096942525953
|
||||
20,20,COST,92.58301243995469,29.79074718072496,113.92,47.83075748481232
|
||||
21,21,CRM,114.82920872764136,31.05619175989376,150.18,102.73309694796748
|
||||
22,22,CSCO,109.59079683339692,20.205961072647767,106.2,51.8402409569602
|
||||
23,23,CSX,102.21700333279603,94.15422274646298,109.66,64.57789456959388
|
||||
24,24,CVS,114.45637828205703,69.63226434890085,92.94,65.59648607467646
|
||||
25,25,CVX,101.04132902481982,19.734394019195516,50.86,69.96882496581931
|
||||
26,26,D,36.235424407706844,99.42309719065304,99.33,51.8402409569602
|
||||
27,27,DE,117.24626163879934,128.5846194338981,130.7,56.0297272881746
|
||||
28,28,DHR,95.60220516090067,50.817629093805174,88.22,88.14972071019906
|
||||
29,29,DIS,118.0842626059964,52.154547957634,156.77,54.08274821363356
|
||||
30,30,DUK,98.46848642408442,93.84720661991736,100.13,45.17595002844379
|
||||
31,31,EXC,102.93352474374487,93.93887179378456,102.13,55.06686019467603
|
||||
32,32,FDX,115.01009064759145,96.7606057674847,96.05,36.11299438295461
|
||||
33,33,FIS,121.33263038562899,71.3964837435809,85.24,50.772222440029985
|
||||
34,34,GE,96.96030338780842,29.70531362743399,165.8,139.7046496026774
|
||||
35,35,GILD,122.72176329769937,88.88347995308483,86.02,75.78448727890905
|
||||
36,36,GOOGL,117.32872134581163,15.625991638002597,144.12,30.837600812615126
|
||||
37,37,GS,108.07574163031246,43.35470423960425,81.58,48.18099359602783
|
||||
38,38,HD,111.52789001410734,143.5629147193028,87.08,58.34898433068543
|
||||
39,39,HON,106.25419306449868,69.72819503365103,108.11,56.61235803598746
|
||||
40,40,IBM,107.96446204894477,100.5681865456486,103.41,51.65611882252366
|
||||
41,41,INTC,67.36065467705929,59.118511199295,101.01,20.15714828519607
|
||||
42,42,ISRG,95.07236085735104,435.81395503602187,138.65,47.51124468536676
|
||||
43,43,JNJ,85.41022920558748,46.12053080610741,94.29,59.680172857534586
|
||||
44,44,JPM,96.07937735460422,28.10229802989597,61.67,82.20525436144348
|
||||
45,45,KO,93.82423614969966,94.85499411485834,100.81,61.30038430228592
|
||||
46,46,LIN,94.64748701325152,50.949336515112954,118.36,68.7365882072592
|
||||
47,47,LLY,110.07902724894022,77.40097813628108,161.45,38.96605042928049
|
||||
48,48,LMT,96.3479915485429,62.23406043866885,120.21,46.219501051665546
|
||||
49,49,LOW,116.76557817038395,189.41973331699705,107.43,60.385988930203325
|
||||
50,50,LRCX,111.29496333398598,56.6796295828036,77.37,82.5152969561821
|
||||
51,51,MA,113.43072478606045,87.1269731354118,152.33,59.94849611082308
|
||||
52,52,MCD,92.23701754912624,200.89445920931172,111.16,65.8435826070515
|
||||
53,53,MCO,108.40548678487258,117.20698016238146,125.21,72.87040339212528
|
||||
54,54,MDT,103.8834127204269,65.11236602743546,83.4,46.79055844390791
|
||||
55,55,MMC,106.22430984950167,95.01322632857912,115.72,53.95657532168604
|
||||
56,56,MMM,84.126733647578,75.39787775188097,83.64,61.74339347884984
|
||||
57,57,MO,46.4135318774777,150.22007381333142,92.62,45.709732413314406
|
||||
58,58,MRK,105.7061613994012,61.26587620928245,109.58,70.11446487776
|
||||
59,59,MSFT,105.83672502534945,34.69766499690875,126.44,53.54779756728987
|
||||
60,60,NEE,102.86758027329674,93.09050598916167,112.07,78.8957471199218
|
||||
61,61,NFLX,112.43566117364969,63.566962940360305,156.36,83.25302875018251
|
||||
62,62,NKE,108.3945644013568,71.50517259861401,111.12,115.9952333583064
|
||||
63,63,NSC,99.25738031854726,83.38200564323695,98.81,59.747188952170255
|
||||
64,64,NVDA,93.34123440057793,62.728551757467315,154.92,13.545606179950594
|
||||
65,65,ORCL,109.81070761854856,152.00013305657274,113.09,57.06804115086576
|
||||
66,66,PEP,95.33276000587897,97.8194872207687,108.11,63.84548798636756
|
||||
67,67,PFE,117.49550657549727,38.53054590934835,32.52,115.2147190477393
|
||||
68,68,PG,85.67262649041187,66.52789058382105,98.45,49.271869110498486
|
||||
69,69,PM,104.3146861910115,165.45270202426994,106.52,58.713318161304116
|
||||
70,70,PYPL,122.86776140601104,30.387524999862347,140.41,69.31518433773357
|
||||
71,71,SCHW,112.39430852805086,14.958860714982293,117.82,56.45014875933075
|
||||
72,72,SO,94.2477238002292,97.91228211519756,106.12,79.23997313802575
|
||||
73,73,SPG,23.037945514747708,166.62308741324316,111.28,82.32147928830356
|
||||
74,74,SPGI,106.2253059746783,42.96376286707977,127.04,54.335650344289206
|
||||
75,75,T,84.43687680647686,84.74265933132276,74.92,68.91715284950327
|
||||
76,76,TGT,120.28985079459592,76.7158398210498,51.38,13.334987110686992
|
||||
77,77,TMO,89.89200425040458,81.16320127567148,111.16,61.096517889077184
|
||||
78,78,TMUS,124.7242533151007,114.0778636139239,198.31,68.19625231090778
|
||||
79,79,TSLA,112.76435826134933,6.715408564004417,119.32,71.35797462546317
|
||||
80,80,TXN,98.64145025650339,75.51423868403076,116.77,70.55221850582774
|
||||
81,81,UNH,113.07213461934721,54.22191184064154,128.29,60.41971719335949
|
||||
82,82,UNP,101.33828676184909,115.6689399670778,112.9,50.6510919364983
|
||||
83,83,UPS,104.23982340635455,79.67494592788235,91.43,53.26595116675375
|
||||
84,84,USB,118.42163459170818,31.588635338063334,92.3,52.24063320906951
|
||||
85,85,V,113.78896354941334,57.21584127997737,134.11,70.07804181463166
|
||||
86,86,VZ,64.01650111199801,102.88154333340245,76.35,46.8479328972033
|
||||
87,87,WFC,120.94955349309633,29.395378652428313,99.65,29.36497090944773
|
||||
88,88,WMT,92.67053402685255,52.73922227043689,97.29,64.40311313622539
|
||||
89,89,XOM,110.71902830024783,24.45068126683328,42.14,81.43170431167135
|
|
|
@ -1,11 +1,14 @@
|
|||
import sys
|
||||
sys.path.append('../group-1')
|
||||
|
||||
sys.path.append('../VISUAL-AN-PROJECT')
|
||||
import math
|
||||
import pandas as pd
|
||||
import os
|
||||
from scraper.top100_extractor import programming_crime_list
|
||||
|
||||
import numpy as np
|
||||
from sklearn import preprocessing
|
||||
|
||||
|
||||
|
||||
pd.set_option('display.max_rows', 500)
|
||||
|
||||
def get_peg(ticker: str):
|
||||
|
@ -25,7 +28,7 @@ def get_peg(ticker: str):
|
|||
|
||||
# Take first value (the last peg ratio)
|
||||
# If it does not exist, it returns 0
|
||||
print(ticker)
|
||||
|
||||
try:
|
||||
if len(current_ratios['PegRatio']) > 0:
|
||||
peg_ratio = current_ratios['PegRatio'].iloc[:1]
|
||||
|
@ -53,7 +56,7 @@ def get_financial_health(ticker: str):
|
|||
try:
|
||||
balance_sheet['financial_health'] = balance_sheet['TotalDebt'] / balance_sheet['TotalAssets']
|
||||
except KeyError:
|
||||
return "NoDebt"
|
||||
return 2.0
|
||||
|
||||
# Get financial health
|
||||
financial_health = balance_sheet['financial_health'].iloc[:1]
|
||||
|
@ -79,12 +82,37 @@ def normalizer():
|
|||
# Read Not_normalized .csv
|
||||
not_normalized = pd.read_csv('Elaborated_Data/Not_Normalized.csv')
|
||||
|
||||
# Takes values for Valuation and compute normalization
|
||||
|
||||
v_low, v_up = not_normalized['Valuation'].min(), not_normalized['Valuation'].max()
|
||||
# v_values = (100 - 0) * ((not_normalized['Valuation'] - v_low) / v_up - v_low) + 0
|
||||
v_values = 240 / not_normalized['Valuation']
|
||||
|
||||
|
||||
v_values = (200/(1+math.e**( 0.2*(-not_normalized['Valuation'].mean()+not_normalized['Valuation'])))) #VALUATION STAT
|
||||
not_normalized['Valuation'] = v_values
|
||||
|
||||
fh_values= (80/not_normalized['Financial Health'].mean())*not_normalized['Financial Health'] #FINANCIAL HEALTH STAT
|
||||
|
||||
not_normalized['Financial Health'] = fh_values
|
||||
|
||||
|
||||
|
||||
not_normalized['Estimated Growth'] = not_normalized['Estimated Growth'].str.strip("%").astype("float")
|
||||
|
||||
eg_values= (200/(1+math.e**( 0.08*(not_normalized['Estimated Growth'].mean()-not_normalized['Estimated Growth'])))) #ESTIMATED GROWTH STAT
|
||||
|
||||
for i in range(len(eg_values)):
|
||||
eg_values[i] = float(round(eg_values[i],2))
|
||||
|
||||
not_normalized['Estimated Growth']= eg_values
|
||||
|
||||
pf_values = (200/(1+math.e**( 0.08*(not_normalized['Past Performance'].mean()-not_normalized['Past Performance'])))) #PAST PERFORMANCE
|
||||
|
||||
not_normalized['Past Performance'] = pf_values
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# # Takes values for financial health and compute normalization
|
||||
# fh_low, fh_up = not_normalized['Financial Health'],min(), not_normalized['Financial Health'].max()
|
||||
# fh_values = (100 - 0) * ((not_normalized['Financial Health'] - fh_low) / fh_up - fh_low) + 0
|
||||
|
@ -93,7 +121,7 @@ def normalizer():
|
|||
# eg_low, eg_up = not_normalized['Estimated Growth'],min(), not_normalized['Estimated Growth'].max()
|
||||
# eg_values = (100 - 0) * ((not_normalized['Financial Health'] - fh_low) / fh_up - fh_low) + 0
|
||||
|
||||
print(not_normalized)
|
||||
not_normalized.to_csv(r'Elaborated_Data/normalized_data.csv')
|
||||
|
||||
def create_df(companies_list):
|
||||
# Dictionary
|
||||
|
@ -120,7 +148,11 @@ def create_df(companies_list):
|
|||
df.to_csv("Elaborated_Data/Not_Normalized.csv")
|
||||
|
||||
def main():
|
||||
# create_df(programming_crime_list)
|
||||
|
||||
if not os.path.exists(r"Elaborated_Data"):
|
||||
os.mkdir(r"Elaborated_Data")
|
||||
|
||||
create_df(programming_crime_list)
|
||||
normalizer()
|
||||
# print(get_peg('GOOGL')) # < 1 ( GREEN); > 1 (RED); = 1 (ORANGE)
|
||||
# print(get_financial_health('GOOGL')) # < 1 (GREEN); > 1 (RED); = 1 (ORANGE)
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
from yahooquery import Ticker
|
||||
|
||||
|
||||
stock_symbol = 'AAPL' # Replace with your desired stock symbol
|
||||
ticker = Ticker(stock_symbol)
|
||||
|
||||
summary = ticker.summary_detail
|
||||
market_cap = summary[stock_symbol.upper()]['marketCap']
|
||||
|
||||
print("Market Cap:", market_cap)
|
Reference in a new issue