Harelkarni commited on
Commit
53c15f8
1 Parent(s): f8a411e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -6
app.py CHANGED
@@ -6,9 +6,9 @@ import matplotlib.pyplot as plt
6
  import requests
7
  import json
8
 
9
-
10
  url_sentiment = "https://yaakovy-fin-proj-docker.hf.space/ticker/"
11
-
12
 
13
 
14
  def get_max_sentiment(row):
@@ -21,7 +21,6 @@ def get_max_sentiment(row):
21
  return 'pos'
22
 
23
 
24
-
25
  def get_sentiment_data(stock_info):
26
  symbol = stock_info.info['symbol']
27
  url_sentiment_with_ticker = f"{url_sentiment}{symbol}"
@@ -51,8 +50,7 @@ def print_sentiment_summery(df) :
51
  st.dataframe(df_sentiment, hide_index =True )
52
  return df_sentiment
53
 
54
-
55
- print(df_new.to_string())
56
 
57
  def print_stock_info(stock_info):
58
  stock_info_html = get_stock_info_from_html(stock_info.info)
@@ -71,6 +69,7 @@ def print_stock_info(stock_info):
71
 
72
  def get_stock_info_from_html(stock_info):
73
  si = stock_info
 
74
  text = (f"<b>Comp. Name: </b> {si['longName']}, {si['city']}, {si.get('state', '')} {si['country']} <br>"
75
  f"<b>Web site: </b> <a href=\"{si['website']}\">{si['website']}</a> <br>"
76
  f"<b>Stock Price: </b> {si['currentPrice']} {str(si['financialCurrency'])}")
@@ -86,7 +85,33 @@ def plot_graph(stock_info):
86
  plt.title(f"{name} Stock Price")
87
  return plt
88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  st.set_page_config(page_title="Senty Sense")
 
90
  st.markdown(
91
  """
92
  <style>
@@ -103,7 +128,6 @@ st.markdown(
103
 
104
 
105
  st.title('_SentySense_') #PriceProphet, Sentyment, Trendsetter Bullseye
106
-
107
  par1 = "Our stock market platform gives you real-time data, historical insights, and in-depth news to help you make informed investment decisions."
108
  st.write(par1, unsafe_allow_html=True)
109
 
@@ -145,4 +169,9 @@ with st.spinner('Wait for it...'):
145
  df = print_sentiment(stock_info)
146
  st.write('Sentiment summery')
147
  print_sentiment_summery(df)
 
 
 
 
 
148
 
 
6
  import requests
7
  import json
8
 
9
+ url_stocks = "https://financialmodelingprep.com/api/v3/stock/list?apikey="
10
  url_sentiment = "https://yaakovy-fin-proj-docker.hf.space/ticker/"
11
+ url_timeGpt = "https://ofirmatzlawi-fin-proj-docker-1.hf.space/ticker/"
12
 
13
 
14
  def get_max_sentiment(row):
 
21
  return 'pos'
22
 
23
 
 
24
  def get_sentiment_data(stock_info):
25
  symbol = stock_info.info['symbol']
26
  url_sentiment_with_ticker = f"{url_sentiment}{symbol}"
 
50
  st.dataframe(df_sentiment, hide_index =True )
51
  return df_sentiment
52
 
53
+
 
54
 
55
  def print_stock_info(stock_info):
56
  stock_info_html = get_stock_info_from_html(stock_info.info)
 
69
 
70
  def get_stock_info_from_html(stock_info):
71
  si = stock_info
72
+
73
  text = (f"<b>Comp. Name: </b> {si['longName']}, {si['city']}, {si.get('state', '')} {si['country']} <br>"
74
  f"<b>Web site: </b> <a href=\"{si['website']}\">{si['website']}</a> <br>"
75
  f"<b>Stock Price: </b> {si['currentPrice']} {str(si['financialCurrency'])}")
 
85
  plt.title(f"{name} Stock Price")
86
  return plt
87
 
88
+
89
+
90
+ def print_timeGpt(stock_info):
91
+ symbol = stock_info.info['symbol']
92
+ url_timeGpt_with_ticker = f"{url_timeGpt}{symbol}"
93
+ response = requests.get(url_timeGpt_with_ticker)
94
+ if response.status_code == 200:
95
+ json_data = json.loads(response.json())
96
+ #st.write(json_data)
97
+ json_data = json.loads(response.json())
98
+
99
+ data = json_data["data"]
100
+ converted_data = []
101
+
102
+ for row in data:
103
+ converted_data.append({"Date": row[0], "TimeGPT": row[1]})
104
+
105
+ df = pd.DataFrame(converted_data)
106
+ st.dataframe(df)
107
+ return df
108
+ else:
109
+ return
110
+
111
+
112
+
113
  st.set_page_config(page_title="Senty Sense")
114
+
115
  st.markdown(
116
  """
117
  <style>
 
128
 
129
 
130
  st.title('_SentySense_') #PriceProphet, Sentyment, Trendsetter Bullseye
 
131
  par1 = "Our stock market platform gives you real-time data, historical insights, and in-depth news to help you make informed investment decisions."
132
  st.write(par1, unsafe_allow_html=True)
133
 
 
169
  df = print_sentiment(stock_info)
170
  st.write('Sentiment summery')
171
  print_sentiment_summery(df)
172
+ st.write('Prediction')
173
+ print_timeGpt(stock_info)
174
+
175
+
176
+
177