-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFindingFallingKnives.py
More file actions
57 lines (37 loc) · 1.41 KB
/
Copy pathFindingFallingKnives.py
File metadata and controls
57 lines (37 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# imports
import StockVisualization
import pandas as pd
import seaborn as sns
def getTickerList(df):
return list(df["Ticker"].unique())
def stockSetup(df, ticker):
'''the stock setup function cleans the dataframe and filters it according to a specific ticker you input'''
df = df.round(2)
df.drop("Return", axis=1)
sector = df['GICS Sector'][0]
df = df.drop("GICS Sector", axis=1)
industry = df['GICS Sub Industry'][0]
df = df.drop("GICS Sub Industry", axis=1)
cik = df['CIK'][0]
df = df.drop("CIK", axis=1)
headLoc = df['Headquarters Location'][0]
df = df.drop("Headquarters Location", axis=1)
DateFirstAdded = df['Date first added'][0]
df = df.drop("Date first added", axis=1)
founded = df['Founded'][0]
df = df.drop("Founded", axis=1)
df['Date'] = pd.to_datetime(df['Date'])
df = df.set_index('Date')
return (df, sector, industry, cik, headLoc, DateFirstAdded, founded)
def main():
# load in dataset
SAndPData = pd.read_csv("database2.csv")
ticker = input("Please enter a ticker: ")
while not(ticker in getTickerList(SAndPData)):
print("Ticker is not valid. Please try again. ")
ticker = input("Please enter a ticker: ")
stockData = stockSetup(SAndPData, ticker)[0]
stockData.head(-5)
print(stockData.dtypes)
if __name__ == "__main__":
main()