KrishGoyani commited on
Commit
083e314
·
verified ·
1 Parent(s): 13325e2

Upload 2 files

Browse files
Files changed (2) hide show
  1. stock_analysis_agents.py +72 -0
  2. stock_analysis_tasks.py +93 -0
stock_analysis_agents.py ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from crewai import Agent
2
+ import os
3
+ from tools.calculator_tools import CalculatorTools
4
+ from tools.search_tools import SearchTools
5
+ from tools.sec_tools import SECTools
6
+ from tools.browser_tools import BrowserTools
7
+ from langchain_google_genai import ChatGoogleGenerativeAI
8
+ from langchain.tools.yahoo_finance_news import YahooFinanceNewsTool
9
+
10
+ class StockAnalysisAgents():
11
+ def __init__(self) -> None:
12
+ self.Gemini = ChatGoogleGenerativeAI(model="gemini-1.5-flash",
13
+ api_key = os.getenv("GOOGLE_API_KEY"))
14
+ def financial_analyst(self):
15
+ return Agent(
16
+ role='The Best Financial Analyst',
17
+ goal="""Impress all customer with your financial data
18
+ and market trends analysis""",
19
+ backstory="""The most seasoned financial analyst with
20
+ lots of expertise in stock market analysis and investment
21
+ strategies that is working for a super important customer.""",
22
+ verbose=True,
23
+ llm=self.Gemini,
24
+ tools=[
25
+ BrowserTools.scrape_and_summarize_website,
26
+ SearchTools.search_internet,
27
+ CalculatorTools.calculate,
28
+ SECTools.search_10q,
29
+ SECTools.search_10k
30
+ ]
31
+ )
32
+
33
+ def research_analyst(self):
34
+ return Agent(
35
+ role='Staff Research Analyst',
36
+ goal="""Being the best at gather, interpret data and amaze
37
+ your customer with it""",
38
+ backstory="""Known as the BEST research analyst, you're
39
+ skilled in sifting through news, company announcements,
40
+ and market sentiments. Now you're working on super
41
+ important customer""",
42
+ verbose=True,
43
+ llm=self.Gemini,
44
+ tools=[
45
+ BrowserTools.scrape_and_summarize_website,
46
+ SearchTools.search_internet,
47
+ SearchTools.search_news,
48
+ YahooFinanceNewsTool(),
49
+ SECTools.search_10q,
50
+ SECTools.search_10k
51
+ ]
52
+ )
53
+
54
+ def investment_advisor(self):
55
+ return Agent(
56
+ role='Private Investment Advisor',
57
+ goal="""Impress your customes with full analyses over stocks
58
+ and completer investment recommendations""",
59
+ backstory="""You're the most experienced investment advisor
60
+ and you combine various analytical insights to formulate
61
+ strategic investment advice. You are now working for
62
+ a super importat customer you need to impress.""",
63
+ verbose=True,
64
+ llm=self.Gemini,
65
+ tools=[
66
+ BrowserTools.scrape_and_summarize_website,
67
+ SearchTools.search_internet,
68
+ SearchTools.search_news,
69
+ CalculatorTools.calculate,
70
+ YahooFinanceNewsTool()
71
+ ]
72
+ )
stock_analysis_tasks.py ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from crewai import Task
2
+ from textwrap import dedent
3
+
4
+ class StockAnalysisTasks():
5
+ def research(self, agent, company):
6
+ return Task(description=dedent(f"""
7
+ Collect and summarize recent news articles, press
8
+ releases, and market analyses related to the stock and
9
+ its industry.
10
+ Pay special attention to any significant events, market
11
+ sentiments, and analysts' opinions. Also include upcoming
12
+ events like earnings and others.
13
+
14
+ Your final answer MUST be a report that include a
15
+ comprehensive summary of the latest news, any notable
16
+ shifts in market sentiment, and potential impacts on
17
+ the stock.
18
+ Also make sure to return the stock ticker.
19
+
20
+ {self.__tip_section()}
21
+
22
+ Make sure to use the most recent data as possible.
23
+
24
+ Selected company by the customer: {company}
25
+ """),
26
+ agent=agent
27
+ )
28
+
29
+ def financial_analysis(self, agent):
30
+ return Task(description=dedent(f"""
31
+ Conduct a thorough analysis of the stock's financial
32
+ health and market performance.
33
+ This includes examining key financial metrics such as
34
+ P/E ratio, EPS growth, revenue trends, and
35
+ debt-to-equity ratio.
36
+ Also, analyze the stock's performance in comparison
37
+ to its industry peers and overall market trends.
38
+
39
+ Your final report MUST expand on the summary provided
40
+ but now including a clear assessment of the stock's
41
+ financial standing, its strengths and weaknesses,
42
+ and how it fares against its competitors in the current
43
+ market scenario.{self.__tip_section()}
44
+
45
+ Make sure to use the most recent data as possible.
46
+ """),
47
+ agent=agent
48
+ )
49
+
50
+ def filings_analysis(self, agent):
51
+ return Task(description=dedent(f"""
52
+ Analyze the latest 10-Q and 10-K filings from EDGAR for
53
+ the stock in question.
54
+ Focus on key sections like Management's Discussion and
55
+ Analysis, financial statements, insider trading activity,
56
+ and any disclosed risks.
57
+ Extract relevant data and insights that could influence
58
+ the stock's future performance.
59
+
60
+ Your final answes must be an expanded report that now
61
+ also highlights significant findings from these filings,
62
+ including any red flags or positive indicators for
63
+ your customer.
64
+ {self.__tip_section()}
65
+ """),
66
+ agent=agent
67
+ )
68
+
69
+ def recommend(self, agent):
70
+ return Task(description=dedent(f"""
71
+ Review and synthesize the analyses provided by the
72
+ Financial Analyst and the Research Analyst.
73
+ Combine these insights to form a comprehensive
74
+ investment recommendation.
75
+
76
+ You MUST Consider all aspects, including financial
77
+ health, market sentiment, and qualitative data from
78
+ EDGAR filings.
79
+
80
+ Make sure to include a section that shows insider
81
+ trading activity, and upcoming events like earnings.
82
+
83
+ Your final answer MUST be a recommendation for your
84
+ customer should be a full super detailed report, providing a
85
+ clear investment stance and strategy with supporting evidence.
86
+ Make it pretty and well formated for your customer.
87
+ {self.__tip_section()}
88
+ """),
89
+ agent=agent
90
+ )
91
+
92
+ def __tip_section(self):
93
+ return "If you do your BEST WORK, I'll give you a $10,000 commision!"