Spaces:
Sleeping
Sleeping
Update core/stock_analysis.py
Browse files- core/stock_analysis.py +88 -9
core/stock_analysis.py
CHANGED
@@ -69,26 +69,105 @@ def analyze_stock(ticker, llm):
|
|
69 |
news_docs = get_google_news_documents(f"Trending News for {ticker}", max_articles=10)
|
70 |
docs = web_docs + news_docs
|
71 |
|
72 |
-
prompt_template = """You are an expert Stock Market Trader
|
73 |
-
|
|
|
74 |
Context:
|
75 |
{input_documents}
|
76 |
-
|
77 |
Task:
|
78 |
-
Summarize the stock
|
79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
|
81 |
-
|
|
|
82 |
{{
|
83 |
"stock_summary": {{
|
84 |
"company_name": "",
|
85 |
"ticker": "",
|
86 |
"exchange": "",
|
87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
}},
|
89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
}}
|
91 |
-
```
|
92 |
"""
|
93 |
|
94 |
prompt = PromptTemplate.from_template(prompt_template)
|
|
|
69 |
news_docs = get_google_news_documents(f"Trending News for {ticker}", max_articles=10)
|
70 |
docs = web_docs + news_docs
|
71 |
|
72 |
+
prompt_template = """You are an expert Stock Market Trader specializing in stock market insights derived from fundamental analysis, analytical trends, profit-based evaluations, news indicators from different sites and detailed company financials.
|
73 |
+
Using your expertise, please analyze the stock based on the provided context below.
|
74 |
+
|
75 |
Context:
|
76 |
{input_documents}
|
77 |
+
|
78 |
Task:
|
79 |
+
Summarize the stock based on its historical and current data. Keep it CONCISE & BRIEF.
|
80 |
+
Evaluate the stock on the following parameters:
|
81 |
+
1. Company Fundamentals: Assess the stock's intrinsic value, growth potential, and financial health.
|
82 |
+
2. Current & Future Price Trends: Analyze historical price movements and current price trends.
|
83 |
+
3. News and Sentiment: Review recent news articles, press releases, and social media sentiment.
|
84 |
+
4. Red Flags: Identify any potential risks or warning signs.
|
85 |
+
5. Provide a rating for the stock on a scale of 1 to 10.
|
86 |
+
6. Advise if the stock is a good buy for the next 1,5, 10 weeks.
|
87 |
+
7. Suggest at what price we need to buy and hold or sell the stock
|
88 |
|
89 |
+
PROVIDE THE DETAILS based on just the FACTS present in the document
|
90 |
+
PROVIDE THE DETAILS IN an JSON Object. Stick to the below JSON object
|
91 |
{{
|
92 |
"stock_summary": {{
|
93 |
"company_name": "",
|
94 |
"ticker": "",
|
95 |
"exchange": "",
|
96 |
+
"description": "",
|
97 |
+
"current_price": "",
|
98 |
+
"market_cap": "",
|
99 |
+
"historical_performance": {{
|
100 |
+
"5_day": "",
|
101 |
+
"1_month": "",
|
102 |
+
"6_months": "",
|
103 |
+
"1_year": "",
|
104 |
+
"5_years": ""
|
105 |
+
}}
|
106 |
+
}},
|
107 |
+
"evaluation_parameters": {{
|
108 |
+
"company_fundamentals": {{
|
109 |
+
"assessment": "",
|
110 |
+
"key_metrics": {{
|
111 |
+
"pe_ratio": "",
|
112 |
+
"volume":"",
|
113 |
+
"revenue_growth_yoy": "",
|
114 |
+
"net_income_growth_yoy": "",
|
115 |
+
"eps_growth_yoy": "",
|
116 |
+
"dividend_yield": "",
|
117 |
+
"balance_sheet": "",
|
118 |
+
"return_on_capital": ""
|
119 |
+
}}
|
120 |
+
}},
|
121 |
+
"current_and_future_price_trends": {{
|
122 |
+
"assessment": "",
|
123 |
+
"historical_trends": "",
|
124 |
+
"current_trends": "",
|
125 |
+
"technical_analysis_notes": "",
|
126 |
+
"technical_indicators":""
|
127 |
+
}},
|
128 |
+
"news_and_sentiment": {{
|
129 |
+
"assessment": "",
|
130 |
+
"positive_sentiment": [
|
131 |
+
"",
|
132 |
+
"",
|
133 |
+
""
|
134 |
+
],
|
135 |
+
"negative_sentiment": [
|
136 |
+
"",
|
137 |
+
"",
|
138 |
+
""
|
139 |
+
]
|
140 |
+
}},
|
141 |
+
"red_flags": [
|
142 |
+
{{
|
143 |
+
"flag": "",
|
144 |
+
"details": ""
|
145 |
+
}},
|
146 |
+
{{
|
147 |
+
"flag": "",
|
148 |
+
"details": ""
|
149 |
+
}},
|
150 |
+
{{
|
151 |
+
"flag": "",
|
152 |
+
"details": ""
|
153 |
+
}}
|
154 |
+
]
|
155 |
+
}},
|
156 |
+
"overall_rating": {{
|
157 |
+
"rating": "ranging from 1 to 10, 1 being low rated, 10 being highly rated",
|
158 |
+
"justification": ""
|
159 |
}},
|
160 |
+
"investment_advice": {{
|
161 |
+
"next_1_weeks_outlook": "",
|
162 |
+
"next_5_weeks_outlook": "",
|
163 |
+
"next_10_weeks_outlook": "",
|
164 |
+
"price_action_suggestions": {{
|
165 |
+
"buy": "",
|
166 |
+
"hold": "",
|
167 |
+
"sell": ""
|
168 |
+
}}
|
169 |
+
}}
|
170 |
}}
|
|
|
171 |
"""
|
172 |
|
173 |
prompt = PromptTemplate.from_template(prompt_template)
|