Update app.py
Browse files
app.py
CHANGED
@@ -19,53 +19,56 @@ GOOGLE_API_KEY=os.environ['GOOGLE_API_KEY']
|
|
19 |
|
20 |
st.title('Stock Market Insights')
|
21 |
|
22 |
-
ticker_user = st.text_input("Enter Ticker"
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
|
|
|
|
|
|
69 |
|
70 |
# If there is no environment variable set for the API key, you can pass the API
|
71 |
# key to the parameter `google_api_key` of the `GoogleGenerativeAIEmbeddings`
|
|
|
19 |
|
20 |
st.title('Stock Market Insights')
|
21 |
|
22 |
+
ticker_user = st.text_input("Enter Ticker")
|
23 |
+
|
24 |
+
|
25 |
+
submit = st.button('Search')
|
26 |
+
if submit:
|
27 |
+
url1 = f"https://www.google.com/finance/quote/{ticker_user}:NSE?hl=en"
|
28 |
+
url2 = f"https://in.tradingview.com/symbols/NSE-{ticker_user}/"
|
29 |
+
|
30 |
+
loader = WebBaseLoader([url1,url2])
|
31 |
+
docs = loader.load()
|
32 |
+
|
33 |
+
gemini_embeddings = GoogleGenerativeAIEmbeddings(model="models/embedding-001")
|
34 |
+
|
35 |
+
llm = ChatGoogleGenerativeAI(model="gemini-pro",google_api_key = GOOGLE_API_KEY)
|
36 |
+
|
37 |
+
st.divider()
|
38 |
+
# llm_prompt_template = """You are an expert Stock Market Trader for stock market insights based on fundamental, analytical, profit based and company financials.
|
39 |
+
# Based on the context below
|
40 |
+
# {context}, Summarize the stock based on Historical data based on fundamental, price, news, sentiment , any red flags and suggest rating of the Stock in a 1 to 10 Scale"""
|
41 |
+
|
42 |
+
llm_prompt_template = """You are an expert Stock Market Trader specializing in stock market insights derived from fundamental analysis, analytical trends, profit-based evaluations, and detailed company financials. Using your expertise, please analyze the stock based on the provided context below.
|
43 |
+
|
44 |
+
Context:
|
45 |
+
{context}
|
46 |
+
|
47 |
+
Task:
|
48 |
+
Summarize the stock based on its historical and current data.
|
49 |
+
Evaluate the stock on the following parameters:
|
50 |
+
1. Company Fundamentals: Assess the stock's intrinsic value, growth potential, and financial health.
|
51 |
+
2. Current & Future Price Trends: Analyze historical price movements and current price trends.
|
52 |
+
3. News and Sentiment: Review recent news articles, press releases, and social media sentiment.
|
53 |
+
4. Red Flags: Identify any potential risks or warning signs.
|
54 |
+
5. Provide a rating for the stock on a scale of 1 to 10.
|
55 |
+
6. Advise if the stock is a good buy for the next 2 weeks.
|
56 |
+
7. Suggest at what price we need to buy and hold or sell
|
57 |
+
"""
|
58 |
+
|
59 |
+
st.sidebar.subheader('Prompt')
|
60 |
+
user_prompt = st.sidebar.text_area("Enter Prompt",llm_prompt_template)
|
61 |
+
|
62 |
+
llm_prompt = PromptTemplate.from_template(user_prompt)
|
63 |
+
|
64 |
+
llm_chain = LLMChain(llm=llm,prompt=llm_prompt)
|
65 |
+
stuff_chain = StuffDocumentsChain(llm_chain=llm_chain,document_variable_name="context")
|
66 |
+
|
67 |
+
|
68 |
+
res = stuff_chain.invoke(docs)
|
69 |
+
|
70 |
+
|
71 |
+
st.write(res["output_text"])
|
72 |
|
73 |
# If there is no environment variable set for the API key, you can pass the API
|
74 |
# key to the parameter `google_api_key` of the `GoogleGenerativeAIEmbeddings`
|