Update app.py
Browse files
app.py
CHANGED
@@ -19,6 +19,8 @@ from tradingview_ta import TA_Handler, Interval
|
|
19 |
import yfinance as yf
|
20 |
from datetime import datetime, timedelta
|
21 |
from newsapi import NewsApiClient
|
|
|
|
|
22 |
|
23 |
st.set_page_config(layout="wide")
|
24 |
|
@@ -211,21 +213,33 @@ if ticker_user!="":
|
|
211 |
|
212 |
with col2:
|
213 |
st.subheader("π Summary")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
st.dataframe(analysis_summary.summary, use_container_width=True)
|
215 |
|
216 |
# --- Row 2: Oscillators + Moving Averages ---
|
217 |
-
col3, col4 = st.columns(2)
|
218 |
-
with col3:
|
219 |
-
|
220 |
-
|
221 |
|
222 |
-
with col4:
|
223 |
-
|
224 |
-
|
225 |
|
226 |
-
# --- Row 3: Indicators ---
|
227 |
-
st.subheader("π Indicators")
|
228 |
-
st.dataframe(analysis_summary.indicators, use_container_width=True)
|
229 |
|
230 |
url = "https://api.chart-img.com/v2/tradingview/advanced-chart"
|
231 |
api_key = "l0iUFRSeqC9z7nDPTd1hnafPh2RrdcEy6rl6tNqV"
|
@@ -254,7 +268,6 @@ if ticker_user!="":
|
|
254 |
llm_chain = LLMChain(llm=llm,prompt=llm_prompt)
|
255 |
stuff_chain = StuffDocumentsChain(llm_chain=llm_chain,document_variable_name="input_documents")
|
256 |
|
257 |
-
st.write(stuff_chain.input_keys)
|
258 |
# res = stuff_chain.invoke(docs)
|
259 |
res = stuff_chain.invoke({"input_documents": docs})
|
260 |
#create the humanmassage propmt templete with the image file
|
@@ -271,7 +284,7 @@ if ticker_user!="":
|
|
271 |
|
272 |
# st.write(message.content)
|
273 |
# st.write(res["output_text"])
|
274 |
-
data = res["output_text"]
|
275 |
# Header Info
|
276 |
st.markdown(f"### {data['stock_summary']['company_name']} ({data['stock_summary']['ticker']}) | {data['stock_summary']['exchange']}")
|
277 |
st.markdown(f"**Description**: {data['stock_summary']['description']}")
|
|
|
19 |
import yfinance as yf
|
20 |
from datetime import datetime, timedelta
|
21 |
from newsapi import NewsApiClient
|
22 |
+
import json
|
23 |
+
import altair as alt
|
24 |
|
25 |
st.set_page_config(layout="wide")
|
26 |
|
|
|
213 |
|
214 |
with col2:
|
215 |
st.subheader("π Summary")
|
216 |
+
# Create bar chart with Altair
|
217 |
+
chart = alt.Chart(analysis_summary.summary).mark_bar().encode(
|
218 |
+
x=alt.X('RECOMMENDATION', sort=['BUY', 'NEUTRAL', 'SELL']), # order if needed
|
219 |
+
y='Count',
|
220 |
+
color='RECOMMENDATION'
|
221 |
+
).properties(
|
222 |
+
width=400,
|
223 |
+
height=300,
|
224 |
+
title="Recommendation Counts"
|
225 |
+
)
|
226 |
+
|
227 |
+
st.altair_chart(chart, use_container_width=True)
|
228 |
st.dataframe(analysis_summary.summary, use_container_width=True)
|
229 |
|
230 |
# --- Row 2: Oscillators + Moving Averages ---
|
231 |
+
# col3, col4 = st.columns(2)
|
232 |
+
# with col3:
|
233 |
+
# st.subheader("βοΈ Oscillator Analysis")
|
234 |
+
# st.dataframe(analysis_summary.oscillators, use_container_width=True)
|
235 |
|
236 |
+
# with col4:
|
237 |
+
# st.subheader("π Moving Averages")
|
238 |
+
# st.dataframe(analysis_summary.moving_averages, use_container_width=True)
|
239 |
|
240 |
+
# # --- Row 3: Indicators ---
|
241 |
+
# st.subheader("π Indicators")
|
242 |
+
# st.dataframe(analysis_summary.indicators, use_container_width=True)
|
243 |
|
244 |
url = "https://api.chart-img.com/v2/tradingview/advanced-chart"
|
245 |
api_key = "l0iUFRSeqC9z7nDPTd1hnafPh2RrdcEy6rl6tNqV"
|
|
|
268 |
llm_chain = LLMChain(llm=llm,prompt=llm_prompt)
|
269 |
stuff_chain = StuffDocumentsChain(llm_chain=llm_chain,document_variable_name="input_documents")
|
270 |
|
|
|
271 |
# res = stuff_chain.invoke(docs)
|
272 |
res = stuff_chain.invoke({"input_documents": docs})
|
273 |
#create the humanmassage propmt templete with the image file
|
|
|
284 |
|
285 |
# st.write(message.content)
|
286 |
# st.write(res["output_text"])
|
287 |
+
data = json.loads(res["output_text"])
|
288 |
# Header Info
|
289 |
st.markdown(f"### {data['stock_summary']['company_name']} ({data['stock_summary']['ticker']}) | {data['stock_summary']['exchange']}")
|
290 |
st.markdown(f"**Description**: {data['stock_summary']['description']}")
|