Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -27,6 +27,9 @@ from GoogleNews import GoogleNews
|
|
| 27 |
from bs4 import BeautifulSoup
|
| 28 |
import requests
|
| 29 |
from urllib.parse import urlparse, urlunparse
|
|
|
|
|
|
|
|
|
|
| 30 |
st.set_page_config(layout="wide")
|
| 31 |
|
| 32 |
GOOGLE_API_KEY=os.environ['GOOGLE_API_KEY']
|
|
@@ -453,6 +456,26 @@ if activities == "Symbol Analysis":
|
|
| 453 |
st.text(res["output_text"])
|
| 454 |
elif activities=="News Sentiment":
|
| 455 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 456 |
|
| 457 |
if st.button("Get Live Updates..."):
|
| 458 |
url1 = f"https://economictimes.indiatimes.com/markets/stocks/news"
|
|
@@ -533,6 +556,9 @@ elif activities=="News Sentiment":
|
|
| 533 |
parsed_data = json.loads(raw_text)
|
| 534 |
top_picks = parsed_data.get("top_picks", [])
|
| 535 |
|
|
|
|
|
|
|
|
|
|
| 536 |
|
| 537 |
# Layout
|
| 538 |
for stock in top_picks:
|
|
|
|
| 27 |
from bs4 import BeautifulSoup
|
| 28 |
import requests
|
| 29 |
from urllib.parse import urlparse, urlunparse
|
| 30 |
+
from stock_vector_db import StockVectorDB
|
| 31 |
+
from datetime import datetime
|
| 32 |
+
|
| 33 |
st.set_page_config(layout="wide")
|
| 34 |
|
| 35 |
GOOGLE_API_KEY=os.environ['GOOGLE_API_KEY']
|
|
|
|
| 456 |
st.text(res["output_text"])
|
| 457 |
elif activities=="News Sentiment":
|
| 458 |
|
| 459 |
+
# Initialize DB
|
| 460 |
+
db = StockVectorDB(index_path="vector_index", log_path="vector_log.json")
|
| 461 |
+
|
| 462 |
+
log_df = pd.DataFrame(db.log_data)
|
| 463 |
+
if log_df.empty:
|
| 464 |
+
st.write("No log")
|
| 465 |
+
else:
|
| 466 |
+
log_df["date"] = pd.to_datetime(log_df["date"])
|
| 467 |
+
|
| 468 |
+
with st.sidebar.expander("🕒 History Filters"):
|
| 469 |
+
selected_date = st.date_input("Pick a date", value=datetime.now().date())
|
| 470 |
+
filtered = log_df[log_df["date"] == pd.to_datetime(selected_date)]
|
| 471 |
+
|
| 472 |
+
st.write(f"Found {len(filtered)} entries on {selected_date}")
|
| 473 |
+
for _, row in filtered.iterrows():
|
| 474 |
+
st.markdown(f"**{row['company']} ({row['ticker']})** — {row['sentiment']} → {row['action']}")
|
| 475 |
+
st.caption(f"Reason: {row['reason']}")
|
| 476 |
+
|
| 477 |
+
|
| 478 |
+
|
| 479 |
|
| 480 |
if st.button("Get Live Updates..."):
|
| 481 |
url1 = f"https://economictimes.indiatimes.com/markets/stocks/news"
|
|
|
|
| 556 |
parsed_data = json.loads(raw_text)
|
| 557 |
top_picks = parsed_data.get("top_picks", [])
|
| 558 |
|
| 559 |
+
# Save LLM output to FAISS DB
|
| 560 |
+
today = datetime.now()
|
| 561 |
+
db.store_top_picks(top_picks, today)
|
| 562 |
|
| 563 |
# Layout
|
| 564 |
for stock in top_picks:
|