bikrammaharjan commited on
Commit
2bf380c
1 Parent(s): 310a76b

added ford and tesla

Browse files
Files changed (4) hide show
  1. .DS_Store +0 -0
  2. app.py +23 -7
  3. final_sentiment_data.csv +12 -0
  4. images/ford_logo.png +0 -0
.DS_Store ADDED
Binary file (6.15 kB). View file
 
app.py CHANGED
@@ -14,12 +14,15 @@ from plotly.subplots import make_subplots
14
 
15
  # Read CSV file into pandas and extract timestamp data
16
  # dfSentiment = ### YOUR LINE OF CODE HERE
17
- dfSentiment = pd.read_csv('sentiment_data.csv')
18
  dfSentiment['timestamp'] = [datetime.strptime(dt, '%Y-%m-%d') for dt in dfSentiment['timestamp'].tolist()]
19
 
20
  # Multi-select columns to build chart
21
  col_list = dfSentiment.columns.tolist()
22
 
 
 
 
23
 
24
  r_sentiment = re.compile(".*sentiment")
25
  sentiment_cols = list(filter(r_sentiment.match, col_list))
@@ -40,18 +43,24 @@ volume_list = list(filter(r_volume.match, col_list))
40
  sentiment_cols = sentiment_cols + post_list
41
  stocks_cols = close_list + volume_list
42
 
 
 
 
43
  # Config for page
44
  st.set_page_config(
45
- page_title= 'TSLA Bot',
46
- page_icon='',
47
  layout='wide',
48
  )
49
 
50
  with st.sidebar:
51
  # FourthBrain logo to sidebar
52
  fourthbrain_logo = Image.open('./images/fourthbrain_logo.png')
53
- st.image([fourthbrain_logo], width=300)
54
 
 
 
 
55
  # Date selection filters
56
  start_date_filter = st.date_input(
57
  'Start Date',
@@ -73,14 +82,21 @@ with st.sidebar:
73
 
74
  # Banner with TSLA and Reddit images
75
  tsla_logo = Image.open('./images/tsla_logo.png')
 
76
  reddit_logo = Image.open('./images/reddit_logo.png')
77
- st.image([tsla_logo, reddit_logo], width=200)
 
 
 
78
 
79
  # dashboard title
80
- st.title('TSLA Subreddit and Stock Price')
81
 
82
  ## dataframe filter
83
  # start date
 
 
 
84
  dfSentiment = dfSentiment[dfSentiment['timestamp'] >= datetime(start_date_filter.year, start_date_filter.month, start_date_filter.day)]
85
 
86
  # end date
@@ -200,4 +216,4 @@ for i in range(1, len(dfSentiment)-1):
200
 
201
  st.markdown('### Detailed Data View')
202
  st.dataframe(dfSentiment.iloc[:, 1:][0:i])
203
- time.sleep(1)
 
14
 
15
  # Read CSV file into pandas and extract timestamp data
16
  # dfSentiment = ### YOUR LINE OF CODE HERE
17
+ dfSentiment = pd.read_csv('final_sentiment_data.csv')
18
  dfSentiment['timestamp'] = [datetime.strptime(dt, '%Y-%m-%d') for dt in dfSentiment['timestamp'].tolist()]
19
 
20
  # Multi-select columns to build chart
21
  col_list = dfSentiment.columns.tolist()
22
 
23
+ r_ticker = re.compile(".*ticker")
24
+ ticker_cols = list(['FORD', 'TSLA'])
25
+
26
 
27
  r_sentiment = re.compile(".*sentiment")
28
  sentiment_cols = list(filter(r_sentiment.match, col_list))
 
43
  sentiment_cols = sentiment_cols + post_list
44
  stocks_cols = close_list + volume_list
45
 
46
+
47
+
48
+
49
  # Config for page
50
  st.set_page_config(
51
+ page_title= 'TSLA Stock Sentiment Analyzer with Reddit comments',
52
+ page_icon='🚙',
53
  layout='wide',
54
  )
55
 
56
  with st.sidebar:
57
  # FourthBrain logo to sidebar
58
  fourthbrain_logo = Image.open('./images/fourthbrain_logo.png')
59
+ st.image([fourthbrain_logo], width=200)
60
 
61
+ # Types of Stock
62
+ stock_ticker_select = st.selectbox('Select Stock Ticker', ticker_cols)
63
+
64
  # Date selection filters
65
  start_date_filter = st.date_input(
66
  'Start Date',
 
82
 
83
  # Banner with TSLA and Reddit images
84
  tsla_logo = Image.open('./images/tsla_logo.png')
85
+ ford_logo = Image.open('./images/ford_logo.png')
86
  reddit_logo = Image.open('./images/reddit_logo.png')
87
+
88
+ spotlight_logo = tsla_logo if stock_ticker_select == 'TSLA' else ford_logo
89
+
90
+ st.image([spotlight_logo, reddit_logo], width=150)
91
 
92
  # dashboard title
93
+ st.title(stock_ticker_select + ' Subreddit and Stock Price')
94
 
95
  ## dataframe filter
96
  # start date
97
+
98
+ dfSentiment = dfSentiment[dfSentiment['stock_ticker'] == stock_ticker_select]
99
+
100
  dfSentiment = dfSentiment[dfSentiment['timestamp'] >= datetime(start_date_filter.year, start_date_filter.month, start_date_filter.day)]
101
 
102
  # end date
 
216
 
217
  st.markdown('### Detailed Data View')
218
  st.dataframe(dfSentiment.iloc[:, 1:][0:i])
219
+ time.sleep(1)
final_sentiment_data.csv ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ,timestamp,counter,close,volume,sentiment_score,close_lag1,perc_change_close,sentiment_score_lag1,perc_change_sentiment,sentiment_SMA3mo,stock_ticker
2
+ 0,2022-03-01,298908,1099.56995,40225400,0.8757717551892263,932.0,0.1797960836909871,0.8744244989083738,0.0015407348290612,0.0,TSLA
3
+ 1,2022-04-01,204020,1145.44995,45377900,0.8448942852492379,1099.56995,0.0417254036453068,0.8757717551892263,-0.0352574398032701,0.8650301797822794,TSLA
4
+ 2,2022-05-01,394149,952.62,48324400,0.8563334928811902,1145.44995,-0.1683442825240858,0.8448942852492379,0.0135392176650571,0.8589998444398849,TSLA
5
+ 3,2022-06-01,78141,775.0,40931000,0.858559500975687,952.62,-0.186454199995801,0.8563334928811902,0.0025994640090594,0.8532624263687051,TSLA
6
+ 4,2022-07-01,56180,752.28998,33343700,0.8514925640708996,775.0,-0.0293032516129032,0.858559500975687,-0.0082311556703483,0.8554618526425922,TSLA
7
+ 0,2022-02-01,388531,1.74,90500,0.8581291195395944,0.0,inf,0.8901475716809757,-0.0359698247346975,0.0,FORD
8
+ 1,2022-03-01,596183,1.75,83500,0.8644258568745963,1.74,0.0057471264367816,0.8581291195395944,0.0073377504522632,0.8709008493650554,FORD
9
+ 2,2022-04-01,121680,1.92,79700,0.8672561851831583,1.75,0.0971428571428571,0.8644258568745963,0.0032742291152595,0.8632703871991163,FORD
10
+ 3,2022-05-01,148176,1.63,8700,0.8847598667655673,1.92,-0.1510416666666666,0.8672561851831583,0.0201828270371024,0.8721473029411073,FORD
11
+ 4,2022-06-01,56784,1.62,9600,0.8769357754633977,1.63,-0.0061349693251532,0.8847598667655673,-0.0088431806143877,0.8763172758040411,FORD
12
+ 5,2022-07-01,1620,1.61,9900,0.8834256099330055,1.62,-0.0061728395061728,0.8769357754633977,0.0074005812639794,0.8817070840539901,FORD
images/ford_logo.png ADDED