mirror of
https://github.com/camel-ai/owl.git
synced 2026-03-22 14:07:17 +08:00
This submission introduces stock analysis use cases, which include the following main components: 1. Added SEC toolset (` sec_tools. py `) for retrieving and analyzing 10-K and 10-Q files from the SEC database. 2. Add an SEC agent (` sec_agent. py `) to generate a comprehensive analysis report of the company's SEC documents. 3. Provide sample reports (Alibaba_investment.analysis.md and Google_investment.analysis.md) to demonstrate complete stock investment analysis. 4. Add environment variable templates (`. env. template `) and `. gitignore ` files to ensure the security of project configuration. 5. Add the 'run. py' script to run the stock analysis agent and generate reports. These changes provide a complete solution for stock investment analysis, supporting the entire process from data acquisition to report generation. feat: Add stock analysis agent and related documents and example files This submission includes the implementation code of the stock analysis agent, Chinese and English README documents, example files (including Apple's investment analysis report and chat records), and required dependencies for the project. These changes provide a complete stock analysis tool for the project, helping users generate detailed stock analysis reports. chore: Delete useless. gitkeep files Clean up. gitkeep files that are no longer needed in the project to keep the codebase clean
76 lines
3.1 KiB
Python
76 lines
3.1 KiB
Python
|
|
import os
|
|
from camel.agents.chat_agent import ChatAgent
|
|
from pydantic import BaseModel
|
|
from typing import List
|
|
from camel.agents import ChatAgent
|
|
from camel.models import ModelFactory
|
|
from camel.types import ModelPlatformType, ModelType
|
|
from tools.sec_tools import SECToolkit
|
|
from camel.toolkits import FunctionTool
|
|
from prompts import get_sec_system_prompt
|
|
|
|
def create_sec_agent() -> ChatAgent:
|
|
# Define the model, here in this case we use gpt-4o-mini
|
|
model = ModelFactory.create(
|
|
model_platform=ModelPlatformType.OPENAI_COMPATIBLE_MODEL,
|
|
model_type="glm-4-flash",
|
|
api_key=os.getenv("ZHIPUAI_API_KEY"),
|
|
url=os.getenv("ZHIPUAI_API_BASE_URL"),
|
|
model_config_dict={"temperature": 0},
|
|
)
|
|
# Create agent with structured output
|
|
agent = ChatAgent(
|
|
system_message=get_sec_system_prompt(),
|
|
model=model,
|
|
tools = [
|
|
*SECToolkit().get_tools()
|
|
]
|
|
)
|
|
return agent
|
|
|
|
def get_sec_summary_for_company(company_stock_name: str) -> str:
|
|
r"""Retrieve and analyze SEC filing information for a specified company and generate a comprehensive analysis report.
|
|
|
|
This function retrieves relevant documents from the SEC database using the company's stock symbol,
|
|
analyzes key financial metrics, business developments, risk conditions, market position,
|
|
and generates a structured analysis report.
|
|
|
|
Args:
|
|
company_stock_name (str): Company stock symbol (e.g., 'AAPL' for Apple Inc.)
|
|
|
|
Returns:
|
|
str: A comprehensive analysis report containing:
|
|
- Key financial metrics from quarterly and annual reports
|
|
- Important business developments, risks, and market position
|
|
- Management discussion and strategic plans
|
|
- Material changes in operations and financial conditions
|
|
- Important regulatory disclosures and compliance matters
|
|
|
|
The report is formatted as structured text, limited to 10,000 words,
|
|
highlighting information most relevant and impactful to investors.
|
|
"""
|
|
|
|
# Define Summary Prompt
|
|
usr_msg = f"""Please search and analyze the SEC filings for {company_stock_name} and provide a comprehensive summary report. The report should:
|
|
|
|
1. Include key financial metrics and performance indicators from recent quarterly and annual reports
|
|
2. Highlight significant business developments, risks, and market position
|
|
3. Analyze management's discussion and strategic initiatives
|
|
4. Note any material changes in operations or financial condition
|
|
5. Summarize important regulatory disclosures and compliance matters
|
|
|
|
Please structure the analysis in a clear, concise manner and limit the total response to no more than 10,000 words. Focus on the most relevant and impactful information for investors."""
|
|
|
|
# Sending the message to the agent
|
|
agent = create_sec_agent()
|
|
response = agent.step(usr_msg)
|
|
|
|
# Check the response (just for illustrative purpose)
|
|
# print(agent.memory.get_context())
|
|
return response.msgs[0].content
|
|
|
|
get_sec_summary_for_company_tool = FunctionTool(get_sec_summary_for_company)
|
|
|
|
if __name__ == "__main__":
|
|
get_sec_summary_for_company("GOOG") |