Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update stock analysis #72

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions stock_analysis/stock_analysis_agents.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
from crewai import Agent
from crewai_tools import ScrapeWebsiteTool

from tools.browser_tools import BrowserTools
from tools.calculator_tools import CalculatorTools
from tools.search_tools import SearchTools
from tools.sec_tools import SECTools

from langchain.tools.yahoo_finance_news import YahooFinanceNewsTool
from langchain.chat_models import ChatOpenAI

class StockAnalysisAgents():
llm_chatgpt3 = ChatOpenAI(model='gpt-3.5-turbo')
llm_chatgpt4 = ChatOpenAI(model='gpt-4')
scrape_and_summarize_website = ScrapeWebsiteTool()

def financial_analyst(self):
return Agent(
role='The Best Financial Analyst',
Expand All @@ -17,8 +23,9 @@ def financial_analyst(self):
lots of expertise in stock market analysis and investment
strategies that is working for a super important customer.""",
verbose=True,
llm=self.llm_chatgpt3,
tools=[
BrowserTools.scrape_and_summarize_website,
self.scrape_and_summarize_website,
SearchTools.search_internet,
CalculatorTools.calculate,
SECTools.search_10q,
Expand All @@ -36,8 +43,9 @@ def research_analyst(self):
and market sentiments. Now you're working on a super
important customer""",
verbose=True,
llm=self.llm_chatgpt3,
tools=[
BrowserTools.scrape_and_summarize_website,
self.scrape_and_summarize_website,
SearchTools.search_internet,
SearchTools.search_news,
YahooFinanceNewsTool(),
Expand All @@ -56,8 +64,9 @@ def investment_advisor(self):
strategic investment advice. You are now working for
a super important customer you need to impress.""",
verbose=True,
llm=self.llm_chatgpt3,
tools=[
BrowserTools.scrape_and_summarize_website,
self.scrape_and_summarize_website,
SearchTools.search_internet,
SearchTools.search_news,
CalculatorTools.calculate,
Expand Down
34 changes: 21 additions & 13 deletions stock_analysis/stock_analysis_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,20 @@ def research(self, agent, company):
sentiments, and analysts' opinions. Also include upcoming
events like earnings and others.

Your final answer MUST be a report that includes a
comprehensive summary of the latest news, any notable
shifts in market sentiment, and potential impacts on
the stock.
Also make sure to return the stock ticker.

{self.__tip_section()}

Make sure to use the most recent data as possible.

Selected company by the customer: {company}
"""),
expected_output = dedent(f"""
Your final answer MUST be a report that includes a
comprehensive summary of the latest news, any notable
shifts in market sentiment, and potential impacts on
the stock.
Also make sure to return the stock ticker.
"""),
agent=agent
)

Expand All @@ -35,15 +37,17 @@ def financial_analysis(self, agent):
debt-to-equity ratio.
Also, analyze the stock's performance in comparison
to its industry peers and overall market trends.

{self.__tip_section()}
"""),
expected_output = dedent(f"""
Your final report MUST expand on the summary provided
but now including a clear assessment of the stock's
financial standing, its strengths and weaknesses,
and how it fares against its competitors in the current
market scenario.{self.__tip_section()}
market scenario.

Make sure to use the most recent data possible.
"""),
"""),
agent=agent
)

Expand All @@ -56,13 +60,14 @@ def filings_analysis(self, agent):
and any disclosed risks.
Extract relevant data and insights that could influence
the stock's future performance.

{self.__tip_section()}
"""),
expected_output = dedent(f"""
Your final answer must be an expanded report that now
also highlights significant findings from these filings,
including any red flags or positive indicators for
your customer.
{self.__tip_section()}
"""),
"""),
agent=agent
)

Expand All @@ -80,12 +85,15 @@ def recommend(self, agent):
Make sure to include a section that shows insider
trading activity, and upcoming events like earnings.


{self.__tip_section()}
"""),
expected_output = dedent(f"""
Your final answer MUST be a recommendation for your
customer. It should be a full super detailed report, providing a
clear investment stance and strategy with supporting evidence.
Make it pretty and well formatted for your customer.
{self.__tip_section()}
"""),
"""),
agent=agent
)

Expand Down