rajat5ranjan commited on
Commit
5f1836d
·
verified ·
1 Parent(s): e04c223

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -47
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","ADANIENT")
23
-
24
- url1 = f"https://www.google.com/finance/quote/{ticker_user}:NSE?hl=en"
25
- url2 = f"https://in.tradingview.com/symbols/NSE-{ticker_user}/"
26
-
27
- loader = WebBaseLoader([url1,url2])
28
- docs = loader.load()
29
-
30
- gemini_embeddings = GoogleGenerativeAIEmbeddings(model="models/embedding-001")
31
-
32
- llm = ChatGoogleGenerativeAI(model="gemini-pro",google_api_key = GOOGLE_API_KEY)
33
-
34
- st.divider()
35
- # llm_prompt_template = """You are an expert Stock Market Trader for stock market insights based on fundamental, analytical, profit based and company financials.
36
- # Based on the context below
37
- # {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"""
38
-
39
- 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.
40
-
41
- Context:
42
- {context}
43
-
44
- Task:
45
- Summarize the stock based on its historical and current data.
46
- Evaluate the stock on the following parameters:
47
- 1. Company Fundamentals: Assess the stock's intrinsic value, growth potential, and financial health.
48
- 2. Current & Future Price Trends: Analyze historical price movements and current price trends.
49
- 3. News and Sentiment: Review recent news articles, press releases, and social media sentiment.
50
- 4. Red Flags: Identify any potential risks or warning signs.
51
- 5. Provide a rating for the stock on a scale of 1 to 10.
52
- 6. Advise if the stock is a good buy for the next 2 weeks.
53
- 7. Suggest at what price we need to buy and hold or sell
54
- """
55
-
56
- st.sidebar.subheader('Prompt')
57
- user_prompt = st.sidebar.text_area("Enter Prompt",llm_prompt_template)
58
-
59
- llm_prompt = PromptTemplate.from_template(user_prompt)
60
-
61
- llm_chain = LLMChain(llm=llm,prompt=llm_prompt)
62
- stuff_chain = StuffDocumentsChain(llm_chain=llm_chain,document_variable_name="context")
63
-
64
-
65
- res = stuff_chain.invoke(docs)
66
-
67
-
68
- st.write(res["output_text"])
 
 
 
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`