eaglelandsonce commited on
Commit
3b4e93b
1 Parent(s): c055605

Upload 2 files

Browse files
Files changed (2) hide show
  1. stock_analysis_agents.py +66 -0
  2. stock_analysis_tasks.py +93 -0
stock_analysis_agents.py ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from crewai import Agent
2
+
3
+ from tools.browser_tools import BrowserTools
4
+ from tools.calculator_tools import CalculatorTools
5
+ from tools.search_tools import SearchTools
6
+ from tools.sec_tools import SECTools
7
+
8
+ from langchain.tools.yahoo_finance_news import YahooFinanceNewsTool
9
+
10
+ class StockAnalysisAgents():
11
+ def financial_analyst(self):
12
+ return Agent(
13
+ role='The Best Financial Analyst',
14
+ goal="""Impress all customers with your financial data
15
+ and market trends analysis""",
16
+ backstory="""The most seasoned financial analyst with
17
+ lots of expertise in stock market analysis and investment
18
+ strategies that is working for a super important customer.""",
19
+ verbose=True,
20
+ tools=[
21
+ BrowserTools.scrape_and_summarize_website,
22
+ SearchTools.search_internet,
23
+ CalculatorTools.calculate,
24
+ SECTools.search_10q,
25
+ SECTools.search_10k
26
+ ]
27
+ )
28
+
29
+ def research_analyst(self):
30
+ return Agent(
31
+ role='Staff Research Analyst',
32
+ goal="""Being the best at gather, interpret data and amaze
33
+ your customer with it""",
34
+ backstory="""Known as the BEST research analyst, you're
35
+ skilled in sifting through news, company announcements,
36
+ and market sentiments. Now you're working on a super
37
+ important customer""",
38
+ verbose=True,
39
+ tools=[
40
+ BrowserTools.scrape_and_summarize_website,
41
+ SearchTools.search_internet,
42
+ SearchTools.search_news,
43
+ YahooFinanceNewsTool(),
44
+ SECTools.search_10q,
45
+ SECTools.search_10k
46
+ ]
47
+ )
48
+
49
+ def investment_advisor(self):
50
+ return Agent(
51
+ role='Private Investment Advisor',
52
+ goal="""Impress your customers with full analyses over stocks
53
+ and completer investment recommendations""",
54
+ backstory="""You're the most experienced investment advisor
55
+ and you combine various analytical insights to formulate
56
+ strategic investment advice. You are now working for
57
+ a super important customer you need to impress.""",
58
+ verbose=True,
59
+ tools=[
60
+ BrowserTools.scrape_and_summarize_website,
61
+ SearchTools.search_internet,
62
+ SearchTools.search_news,
63
+ CalculatorTools.calculate,
64
+ YahooFinanceNewsTool()
65
+ ]
66
+ )
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 includes 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 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 answer 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. It should be a full super detailed report, providing a
85
+ clear investment stance and strategy with supporting evidence.
86
+ Make it pretty and well formatted 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!"