Update app.py
Browse files
app.py
CHANGED
@@ -67,7 +67,7 @@ def get_google_news_documents(query: str, max_articles: int = 10, timeout: int =
|
|
67 |
Returns:
|
68 |
List[Document]: Parsed article content as LangChain Document objects.
|
69 |
"""
|
70 |
-
st.caption(f"Fetching articles for query: '{query}'")
|
71 |
|
72 |
googlenews = GoogleNews(lang="en")
|
73 |
# Set time range to last `days` days
|
@@ -138,6 +138,95 @@ if activities == "Symbol Analysis":
|
|
138 |
|
139 |
|
140 |
if ticker_user!="":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
url1 = f"https://www.google.com/finance/quote/{ticker_user}:NSE?hl=en"
|
142 |
url2 = f"https://in.tradingview.com/symbols/NSE-{ticker_user}/"
|
143 |
url3 = f"https://in.tradingview.com/symbols/NSE-{ticker_user}/news/"
|
@@ -253,91 +342,7 @@ if activities == "Symbol Analysis":
|
|
253 |
}}
|
254 |
"""
|
255 |
|
256 |
-
# st.sidebar.subheader('Prompt')
|
257 |
-
# user_prompt = st.sidebar.text_area("Enter Prompt",llm_prompt_template)
|
258 |
-
#https://huggingface.co/spaces/pradeepodela/Stock-Analyser/blob/main/app.py
|
259 |
-
interval = Interval.INTERVAL_1_DAY
|
260 |
-
analysis_summary = get_tradingview_analysis(
|
261 |
-
symbol=ticker_user,
|
262 |
-
exchange="NSE",
|
263 |
-
screener="india",
|
264 |
-
interval=interval,
|
265 |
-
)
|
266 |
-
|
267 |
-
# st.title("Analysis Summary")
|
268 |
-
# st.dataframe(analysis_summary.summary)
|
269 |
-
# query = f"{ticker_user} stock"
|
270 |
-
|
271 |
-
details = {
|
272 |
-
"symbol": ticker_user,
|
273 |
-
"exchange": "NSE",
|
274 |
-
"screener": "india",
|
275 |
-
"interval": interval,
|
276 |
-
}
|
277 |
-
# st.title("Details")
|
278 |
-
# st.dataframe(details)
|
279 |
-
|
280 |
-
# st.title("Oscillator Analysis")
|
281 |
-
# st.dataframe(analysis_summary.oscillators)
|
282 |
-
|
283 |
-
# st.title("Moving Averages")
|
284 |
-
# st.dataframe(analysis_summary.moving_averages)
|
285 |
-
|
286 |
-
# st.title("Summary")
|
287 |
-
# st.dataframe(analysis_summary.summary)
|
288 |
-
|
289 |
-
# st.title("Indicators")
|
290 |
-
# st.dataframe(analysis_summary.indicators)
|
291 |
-
|
292 |
-
# Page Title
|
293 |
-
st.subheader(f"π Stock Analysis: :red[{ticker_user} : {interval}] ({details['exchange']})")
|
294 |
|
295 |
-
# --- Row 1: Details + Summary ---
|
296 |
-
# col1, col2 = st.columns([1, 3])
|
297 |
-
# with col1:
|
298 |
-
# st.write(analysis_summary.summary)
|
299 |
-
summary= analysis_summary.summary
|
300 |
-
BUY_PER = (summary['BUY']/(summary['BUY'] + summary['SELL']+ summary['NEUTRAL']))*100
|
301 |
-
st.markdown(f"##### RECOMMENDATION : :red[{summary['RECOMMENDATION']}] | BUY CONFIDENCE %: :red[{round(BUY_PER,2)}]")
|
302 |
-
|
303 |
-
# --- Row 2: Oscillators + Moving Averages ---
|
304 |
-
# col3, col4 = st.columns(2)
|
305 |
-
# with col3:
|
306 |
-
# st.subheader("βοΈ Oscillator Analysis")
|
307 |
-
# st.dataframe(analysis_summary.oscillators, use_container_width=True)
|
308 |
-
|
309 |
-
# with col4:
|
310 |
-
# st.subheader("π Moving Averages")
|
311 |
-
# st.dataframe(analysis_summary.moving_averages, use_container_width=True)
|
312 |
-
|
313 |
-
# # --- Row 3: Indicators ---
|
314 |
-
# st.subheader("π Indicators")
|
315 |
-
# st.dataframe(analysis_summary.indicators, use_container_width=True)
|
316 |
-
|
317 |
-
# url = "https://api.chart-img.com/v2/tradingview/advanced-chart"
|
318 |
-
# api_key = "l0iUFRSeqC9z7nDPTd1hnafPh2RrdcEy6rl6tNqV"
|
319 |
-
# headers = {
|
320 |
-
# "x-api-key": api_key,
|
321 |
-
# "content-type": "application/json"
|
322 |
-
# }
|
323 |
-
# data = {
|
324 |
-
# "height": 400,
|
325 |
-
# "theme": "light",
|
326 |
-
# "interval": "1D",
|
327 |
-
# "session": "extended",
|
328 |
-
# "symbol": f"NSE:{ticker_user}"
|
329 |
-
# }
|
330 |
-
|
331 |
-
# response = requests.post(url, headers=headers, json=data)
|
332 |
-
|
333 |
-
# if response.status_code == 200:
|
334 |
-
# with open("chart_t1.jpg", "wb") as f:
|
335 |
-
# f.write(response.content)
|
336 |
-
# with col2:
|
337 |
-
# st.image("chart_t1.jpg", caption='')
|
338 |
-
# else:
|
339 |
-
# st.warning(f"Failed to retrieve image. Status code: {response.status_code}")
|
340 |
-
# st.warning("Response:", response.text)
|
341 |
|
342 |
google_docs = get_google_news_documents(f"Trending News for {ticker_user}", max_articles=10)
|
343 |
docs.extend(google_docs)
|
@@ -551,3 +556,14 @@ elif activities=="News Sentiment":
|
|
551 |
|
552 |
else:
|
553 |
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
Returns:
|
68 |
List[Document]: Parsed article content as LangChain Document objects.
|
69 |
"""
|
70 |
+
st.sidebar.caption(f"Fetching articles for query: '{query}'")
|
71 |
|
72 |
googlenews = GoogleNews(lang="en")
|
73 |
# Set time range to last `days` days
|
|
|
138 |
|
139 |
|
140 |
if ticker_user!="":
|
141 |
+
|
142 |
+
|
143 |
+
# st.sidebar.subheader('Prompt')
|
144 |
+
# user_prompt = st.sidebar.text_area("Enter Prompt",llm_prompt_template)
|
145 |
+
#https://huggingface.co/spaces/pradeepodela/Stock-Analyser/blob/main/app.py
|
146 |
+
interval = Interval.INTERVAL_1_DAY
|
147 |
+
analysis_summary = get_tradingview_analysis(
|
148 |
+
symbol=ticker_user,
|
149 |
+
exchange="NSE",
|
150 |
+
screener="india",
|
151 |
+
interval=interval,
|
152 |
+
)
|
153 |
+
|
154 |
+
# st.title("Analysis Summary")
|
155 |
+
# st.dataframe(analysis_summary.summary)
|
156 |
+
# query = f"{ticker_user} stock"
|
157 |
+
|
158 |
+
details = {
|
159 |
+
"symbol": ticker_user,
|
160 |
+
"exchange": "NSE",
|
161 |
+
"screener": "india",
|
162 |
+
"interval": interval,
|
163 |
+
}
|
164 |
+
# st.title("Details")
|
165 |
+
# st.dataframe(details)
|
166 |
+
|
167 |
+
# st.title("Oscillator Analysis")
|
168 |
+
# st.dataframe(analysis_summary.oscillators)
|
169 |
+
|
170 |
+
# st.title("Moving Averages")
|
171 |
+
# st.dataframe(analysis_summary.moving_averages)
|
172 |
+
|
173 |
+
# st.title("Summary")
|
174 |
+
# st.dataframe(analysis_summary.summary)
|
175 |
+
|
176 |
+
# st.title("Indicators")
|
177 |
+
# st.dataframe(analysis_summary.indicators)
|
178 |
+
|
179 |
+
# Page Title
|
180 |
+
st.subheader(f"π Stock Analysis: :red[{ticker_user} : {interval}] ({details['exchange']})")
|
181 |
+
|
182 |
+
# --- Row 1: Details + Summary ---
|
183 |
+
# col1, col2 = st.columns([1, 3])
|
184 |
+
# with col1:
|
185 |
+
# st.write(analysis_summary.summary)
|
186 |
+
summary= analysis_summary.summary
|
187 |
+
BUY_PER = (summary['BUY']/(summary['BUY'] + summary['SELL']+ summary['NEUTRAL']))*100
|
188 |
+
st.markdown(f"##### RECOMMENDATION : :red[{summary['RECOMMENDATION']}] | BUY CONFIDENCE %: :red[{round(BUY_PER,2)}]")
|
189 |
+
|
190 |
+
# --- Row 2: Oscillators + Moving Averages ---
|
191 |
+
# col3, col4 = st.columns(2)
|
192 |
+
# with col3:
|
193 |
+
# st.subheader("βοΈ Oscillator Analysis")
|
194 |
+
# st.dataframe(analysis_summary.oscillators, use_container_width=True)
|
195 |
+
|
196 |
+
# with col4:
|
197 |
+
# st.subheader("π Moving Averages")
|
198 |
+
# st.dataframe(analysis_summary.moving_averages, use_container_width=True)
|
199 |
+
|
200 |
+
# # --- Row 3: Indicators ---
|
201 |
+
# st.subheader("π Indicators")
|
202 |
+
# st.dataframe(analysis_summary.indicators, use_container_width=True)
|
203 |
+
|
204 |
+
# url = "https://api.chart-img.com/v2/tradingview/advanced-chart"
|
205 |
+
# api_key = "l0iUFRSeqC9z7nDPTd1hnafPh2RrdcEy6rl6tNqV"
|
206 |
+
# headers = {
|
207 |
+
# "x-api-key": api_key,
|
208 |
+
# "content-type": "application/json"
|
209 |
+
# }
|
210 |
+
# data = {
|
211 |
+
# "height": 400,
|
212 |
+
# "theme": "light",
|
213 |
+
# "interval": "1D",
|
214 |
+
# "session": "extended",
|
215 |
+
# "symbol": f"NSE:{ticker_user}"
|
216 |
+
# }
|
217 |
+
|
218 |
+
# response = requests.post(url, headers=headers, json=data)
|
219 |
+
|
220 |
+
# if response.status_code == 200:
|
221 |
+
# with open("chart_t1.jpg", "wb") as f:
|
222 |
+
# f.write(response.content)
|
223 |
+
# with col2:
|
224 |
+
# st.image("chart_t1.jpg", caption='')
|
225 |
+
# else:
|
226 |
+
# st.warning(f"Failed to retrieve image. Status code: {response.status_code}")
|
227 |
+
# st.warning("Response:", response.text)
|
228 |
+
|
229 |
+
|
230 |
url1 = f"https://www.google.com/finance/quote/{ticker_user}:NSE?hl=en"
|
231 |
url2 = f"https://in.tradingview.com/symbols/NSE-{ticker_user}/"
|
232 |
url3 = f"https://in.tradingview.com/symbols/NSE-{ticker_user}/news/"
|
|
|
342 |
}}
|
343 |
"""
|
344 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
345 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
346 |
|
347 |
google_docs = get_google_news_documents(f"Trending News for {ticker_user}", max_articles=10)
|
348 |
docs.extend(google_docs)
|
|
|
556 |
|
557 |
else:
|
558 |
pass
|
559 |
+
|
560 |
+
# Add copyright line at the bottom
|
561 |
+
st.markdown(
|
562 |
+
"""
|
563 |
+
<hr>
|
564 |
+
<p style="text-align:center; font-size:12px; color:gray;">
|
565 |
+
© 2025 RAJAT RANJAN. All rights reserved.
|
566 |
+
</p>
|
567 |
+
""",
|
568 |
+
unsafe_allow_html=True
|
569 |
+
)
|