pschofield2 commited on
Commit
5bb2b91
·
verified ·
1 Parent(s): 036e101

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -16
app.py CHANGED
@@ -133,9 +133,7 @@ Weighted Average Shares Outstanding Diluted: {income_statement.get('weightedAver
133
  """
134
 
135
  prompt = f"""
136
- You are an expert stock analyst AI that has been tasked with analyzing a specific company and providing an investment recommendation for potential investors. Start with a company description and include the ticker, CEO, Market Cap and beta. Then provide an analysis based on the information provided to you. Your analysis and recommendation should be based solely on the company information, financial data, and news articles provided to you. Do not make assumptions or incorporate any outside knowledge.
137
-
138
- Here is the company you will be analyzing:
139
 
140
  <company>
141
  Name: {company_name} ({ticker})
@@ -147,15 +145,13 @@ Beta: {beta}
147
 
148
  Please carefully review this background information on the company.
149
 
150
- Next, here is some recent financial data on the company:
151
 
152
  <financial_data>
153
  {financial_data_str}
154
  </financial_data>
155
 
156
- Carefully analyze the key financial metrics and KPIs provided above, looking for significant trends, strengths and weaknesses. Consider metrics like revenue growth, profit margins, debt levels, etc.
157
-
158
- Next, here are the proprietary TradeSmith indicators for the company:
159
 
160
  <proprietary_indicators>
161
 
@@ -171,11 +167,11 @@ Next, here are some recent news articles about the company:
171
 
172
  </news_articles>
173
 
174
- <reasoning>
175
 
176
- Synthesize your analysis of the company background, financial data, proprietary TradeSmith indicators, and recent news. Discuss the key factors that will likely impact the company's future stock price. Weigh the potential rewards of investing against the risks. Show your analytical thought process.
177
 
178
- </reasoning>
179
 
180
  <prediction>
181
 
@@ -183,7 +179,7 @@ Considering everything, what prediction would you make for this stock's return o
183
 
184
  </prediction>
185
 
186
- Remember, your role is to be an objective, expert stock analyst. Explain your reasoning so that investors can understand the key factors driving your recommendation.
187
  """
188
 
189
  return prompt
@@ -196,11 +192,48 @@ def generate_gpt_prompt(ticker: str, api_key: str) -> str:
196
 
197
  def run_gpt_model(prompt: str, api_key: str) -> str:
198
  openai_client = OpenAI(api_key = api_key)
199
- system_prompt = (
200
- "You are an expert stock analyst with a high degree of familiarity with TradeSmith and InvestorPlace products and services. "
201
- "You help subscribers of these businesses analyze stocks. "
202
- "You speak concisely and your output should use line breaks after each sentence to keep the text within a readable width. "
203
- "Your answer format should be as follows:\n\n[Short Company Description]\n\n[Income Statement Analysis]:\n1. ...\n\n[Balance Sheet Analysis]:\n1. ...\n\n[TradeSmith Indicator Analysis]:\n1. ...\n\n[News Analysis]:\n1. ...\n\n[Prediction & Analysis]:\n...\n")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
204
 
205
  system = {
206
  "role":"system",
 
133
  """
134
 
135
  prompt = f"""
136
+ Here is the profile of the company you will be analyzing:
 
 
137
 
138
  <company>
139
  Name: {company_name} ({ticker})
 
145
 
146
  Please carefully review this background information on the company.
147
 
148
+ Next, here is the most recent quarter's balance sheet and income statement data for the company:
149
 
150
  <financial_data>
151
  {financial_data_str}
152
  </financial_data>
153
 
154
+ Next, here are some of the proprietary TradeSmith indicators for the company:
 
 
155
 
156
  <proprietary_indicators>
157
 
 
167
 
168
  </news_articles>
169
 
170
+ <analysis>
171
 
172
+ Provide your analysis of the company profile, financial data, proprietary TradeSmith indicators, and recent news. Show your analytical thought process.
173
 
174
+ </analysis>
175
 
176
  <prediction>
177
 
 
179
 
180
  </prediction>
181
 
182
+ Remember, your role is to be an expert stock analyst. Explain your reasoning so that investors can understand the key factors driving your recommendation. Assume you are talking to a group of readers, not to an individual, to comply with legal's requirement of not giving out personalized advice. At the end, always disclaim something along the lines of "investing and trading is risky..."
183
  """
184
 
185
  return prompt
 
192
 
193
  def run_gpt_model(prompt: str, api_key: str) -> str:
194
  openai_client = OpenAI(api_key = api_key)
195
+ # system_prompt = """
196
+ # You are an expert stock analyst with a high degree of familiarity with TradeSmith and InvestorPlace products and services.
197
+ # You help subscribers of these businesses analyze stocks.
198
+ # You speak concisely and your output should use line breaks after each sentence to keep the text within a readable width.
199
+ # Your answer format should be as follows:
200
+
201
+ # [Short Company Description]:
202
+
203
+ # [Income Statement Analysis]:
204
+
205
+ # [Balance Sheet Analysis]:
206
+
207
+ # [TradeSmith Indicator Analysis]:
208
+
209
+ # [News Analysis]:
210
+
211
+ # [Prediction & Analysis]:"""
212
+
213
+ system_prompt = """
214
+ You are a highly experienced stock analyst with deep knowledge of TradeSmith and InvestorPlace products and services. You assist subscribers of these platforms by providing comprehensive stock analyses. Ensure your output is clear, concise, and formatted for easy reading with line breaks after each sentence. The analysis should be structured as follows:
215
+
216
+ [Short Company Description]:
217
+ Provide a brief overview of the company.
218
+
219
+ [News Analysis]:
220
+ Summarize recent news articles or reports related to the company. Discuss any significant events or developments that could impact the stock's performance.
221
+
222
+ [Income Statement Analysis]:
223
+ Analyze key figures from the company's income statement, such as revenue, expenses, and net income. Highlight trends and significant changes.
224
+
225
+ [Balance Sheet Analysis]:
226
+ Examine important elements from the balance sheet, focusing on assets, liabilities, and shareholders' equity. Discuss the company's financial health and stability.
227
+
228
+ [TradeSmith Indicator Analysis]:
229
+ Incorporate relevant TradeSmith indicators, explaining what they suggest about the stock's performance and potential. Use proprietary indicators effectively to add value to the analysis. If the Predictive Alpha prediction is told to you, don't talk about it here, use it as your prediction in the following Prediction & Analysis section.
230
+
231
+ [Prediction & Analysis]:
232
+ Provide a well-reasoned prediction for the stock's future 21 day performance. If a Predictive Alpha prediction was provided, use that as your prediction, supported by your analysis. Offer actionable recommendations based on your insights.
233
+
234
+ Make sure each section is thorough yet concise, providing valuable insights for the subscriber. Only touch on the details you deem important. Finally, it is critically important that you comply with the legal guideline of not providing personalized financial advice to individuals.
235
+ """
236
+
237
 
238
  system = {
239
  "role":"system",