AI Personal Learning
and practical guidance

Rapidly Build Stock Analysis Intelligence Body Intelligence with Phidata AI

Quickly Build Stock Analysis Intelligence Body Intelligence Body-1 with Phidata AI

 

Information overload in equity research is real

A common challenge when evaluating the value of a stock is that of dealing with a large amount of information from multiple sources in order to make an informed investment decision.

Traditional methods include:

  • Collect financial data from various platforms.
  • Read multiple reports, news and other articles.
  • Build and maintain complex spreadsheet models.
  • Synthesize this information into actionable content.

Holding and managing all these inputs at once usually looks like this:


Quickly Build Stock Analysis Intelligence Body Intelligence Body-1 with Phidata AI

AI is known to be the most viable solution to handle large data sets easily and efficiently.

However, most of the publicly available Large Language Models (LLMs) are still unable to perform detailed in-depth analysis of real-time stock data with great accuracy.

  • ChatGPT cap (a poem) Claude There is a contextual date cutoff.
  • Perplexity Great for real-time information, but limited in analyzing tasks.
  • ChatGPT searches are still unsatisfactory.

For detailed research and stock analysis, we need something that is more precise and works well with structured datasets.

In fact, what if we could combine everything? What if we could utilize AI intelligences to navigate news, Google searches, financial datasets, and coding tasks all in one system?

A superb, always-on stock analyst.

 

Go to AI Intelligent Body Solutions

To solve this problem, I developed a system that coordinates multiple specialized AI intelligences, each dealing with specific aspects of stock analysis.

Quickly Build Stock Analysis Intelligence Body Intelligence Body-1 with Phidata AI

Intelligent Body Team

  1. Sentiment Analysis Intelligence (GPT-4o)
    • Handling news and market sentiment
    • Use Google search to gather recent developments
    • Provides sentiment scores and trend analysis
  2. Financial Analysis Intelligence (Claude 3.5)
    • Different intelligences for basic stock data and historical data
    • Analyzing company finances and indicators
    • Perform valuation calculations (DCF, publicly comparable companies, fundamental analysis)
    • Assessment of key performance indicators
  3. Quantitative Analytical Intelligence (Claude 3.5 Sonnet or Haiku)
    • Execute Python code for technical analysis
    • Processing large datasets and output from other intelligences
    • Generate visualizations and statistical insights
  4. Executive/Portfolio Manager Intelligence (Claude 3.5 Sonnet or Haiku)
    • Acts as a portfolio manager designed to synthesize data with optional routing.
    • Aggregate all information gathered by other instrumental intelligences and provide buy, sell or hold recommendations

Phidata: The Intelligent Body Builder

Quickly Build Stock Analysis Intelligence Body Intelligence Body-1 with Phidata AI

Phidata is a framework for AI intelligences that enables developers to:

  • Building Intelligence with Memory, Knowledge and External Connections
  • Building teams of intelligences that can work together
  • Monitor, evaluate and optimize intelligences

They also provide an intuitive and user-friendly user interface for intelligences, and users can test intelligences in a sandbox environment.

Phidata allows us to integrate several powerful tools right out of the box:

  • Yahoo Finance API for real-time price data and historical financial data
  • Google Search for News and Sentiment Analysis
  • Python tools for AI-guided code execution and quantitative analysis (use with caution)
  • Custom quantitative functions for data processing and visualization (optional)
    • Note: Code execution intelligences require tight control and strict hint engineering
    • Code intelligences may encounter multiple errors, such as recursive functions or saving and reading files

introduction (a subject)

Want to try it yourself? The full code is available at Google Colab NotebookFound in.

You will need:

  • API keys for OpenAI and Anthropic (we use different models for different intelligences, but you can choose a more unified workflow)
  • Phidata framework installed
  • Some basic Python knowledge for further study

Required Packages

!pip install phidata openai anthropic yfinance googlesearch-python pycountry -q

Instantiating Libraries and API Keys

## Libraries

from phi.agent.import Agent
from phi.model.openai import OpenAIChat
from phi.model.anthropic import Claude
from phi.tools.yfinance import YFinanceTools
from phi.tools.googlesearch import GoogleSearch

## API Keys

import requests

from google.colab import userdata
OPENAI_API_KEY = userdata.get('OPENAI_API_KEY')
ANTHROPIC_API_KEY = userdata.get('ANTHROPIC_API_KEY')

import os
os.environ["OPENAI_API_KEY"] = OPENAI_API_KEY
os.environ["ANTHROPIC_API_KEY"] = ANTHROPIC_API_KEY

 

Defining an Intelligence - Sentiment Analysis Example

# Sentiment Analysis Agent

sentiment_agent = Agent(
name="Sentiment Analysis Agent",

name="Sentiment Analysis Agent", role="Search and interpret news articles", model=OpenAIChat(id="gpt-4o"),
## define the tools for the Agent's use
tools=[GoogleSearch(), YFinanceTools(company_news=True)], instructions=[[GoogleSearch(), YFinanceTools(company_news=True)], instructions=["Search and interpret news articles", model=OpenAIChat(id="gpt-4o"), ##
instructions=[

"Provide sentiment scores from 1 (negative) to 10 (positive) with reasoning and sources.", "Cite your sources.
"Cite your sources. Be specific, crtical and provide relevant links."
]," "Show_tool_calls
show_tool_calls=True,
show_tool_calls=True, markdown=True, )
)

 

Defining an Intelligence - Basic Stock Information Example

# Financial Analyst Agent

basic_stock_agent = Agent(
name="Basic Financial Data Agent",
name="Basic Financial Data Agent", role="Retrieve basic company financial data and expertly interpret trends and data using a rigourously analytical approach", model=Claude(id="claude-3-5-sonnet-latest", 1
model=Claude(id="claude-3-5-sonnet-latest"), ## swapped claude for gpt-4o
## define the tools for the Agent's use
tools=[YFinanceTools(stock_price=True, company_info=True, stock_fundamentals=True, analyst_recommendations=True)],
instructions=[
"Retrieve stock prices, analyst recommendations, and key summarized financial data.",
"Focus on company funamentals and trends, presenting the data in tables with key insights."
],, "Show_tool_calls
show_tool_calls=True,
show_tool_calls=True, markdown=True, )
)

Users have the option to add more intelligences based on their unique needs, including visual intelligences and other formats

Building Your Intelligent Body Team

With just a few lines of code, we can build a powerful multi-intelligence system with specific roles that can collaboratively analyze stocks.

agent_team Acting as a conductor, selecting the right workflow of intelligences and ensuring that each intelligence contributes its insights and that the final output is well-structured, data-driven and easy to understand

agent_team = Agent(
model=Claude(id="claude-3-5-sonnet-latest"), team=[sentiment_agent, basic_stock_agent], ## Add more Agents here if desired.
team=[sentiment_agent, basic_stock_agent], ## Add more Agents here if desired.
instructions=[
"Combine the expertise of all the agents part of your team to provide a cohesive, highly analytical and well-supported response", "Always include references and dates for
"Always include references and dates for all data points and sources. Your context is current as of [insert date here]"
"Present data in structured tables for clarity, ensuring all conclusions are data-driven." "Explain the methodlogy and methodology.
"Explain the methodlogy and always determine a BUY, SELL, or HOLD recommendation."
].
show_tool_calls=True,
show_tool_calls=True, markdown=True, )
)

 

Start chatting with your team of intelligences 🤖

You are now ready to start querying your Smartbody team! Here's what the sample prompts and output look like:

Example Tip:

agent_team.print_response(
"Perform a public comparable companies analysis for CALM Cal Maine Foods. Identify it's main competitors and market positioning. assess each comp in a Assess each comp in a structured table format",
stream=True
)

 

Sample Output:

(formatted data)

### Public Comparable Company Analysis: Cal-Maine Foods (CALM)

##### **Corporate Overview**

| Company Name | Stock Symbol | Market Capitalization ($) | Primary Business Direction | Egg Production Focus |
| ---------------------- | ---------- | ------------- | ---------------- | -------------- |
| Cal-Maine Foods | CALM | $4.96B | Focus on Egg Production | Core Business |
| Post Holdings | POST | $6.66B | Packaged Foods | Secondary Business |
| Tyson Foods | TSN | $20.65B | Meat and food products | Marginal business lines |
| Vital Farms | VITL | $1.64B | Free Range Eggs | Focused Segments |
| Seaboard Corporation | SEB | $2.34B | Diversified Conglomerates | Edge Business Lines |

##### **Comparison of financial metrics**

| Metrics | CALM | POST | TSN | VITL | SEB |
| ----------------------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | --------
| Price/Earnings Ratio (P/E Ratio) | 11.59 | 16.11 | 13.80 | 31.31 | N/A |
| Earnings Per Share (EPS) | $8.73 | $5.64 | $2.25 | $1.12 | -$5.30 | Revenue Growth (YoY) | $5.30 | $2.25 | $1.12 | -$5.30
| Revenue Growth (Y/Y) | 71.1% | Volatility | Medium | High | Volatility | Gross Margin (Gross Margin)
| Gross Margin (Gross Margin) | 28.02% | 15-20% | 12-15% | 25-30% | Volatility |

---

### **Cal-Maine Foods' competitive position**

##### **Unique Advantages**

1. Market leadership in egg production
2. Diversified product portfolio
3. Strong regional distribution network
4. Focus on specialty egg segments
5. Solid financial performance

##### **Key differentiating characteristics**

* **Brands** : Egg-Land's Best, Land O' Lakes, Farmhouse Eggs
* **Product range** : Conventional, Organic, Free Range, Pastured Eggs
* **Geographic Coverage**: Southwest, Southeast, Midwest, Northeast and Mid-Atlantic regions

---

### **Marketing Recommendations**

##### **Comprehensive Assessment**

* **Cal-Maine Foods** is the most specialized in egg production
* Strong financial metrics compared to diversified competitors
* Potential for continued growth in the specialty egg market segment

##### **INVESTMENT RECOMMENDATION:** **Strong Buy**

* Solid fundamentals
* Market leadership position
* Ability to adapt to consumer trends
* Attractive valuation compared to peers

---

**Note** : The above analysis is based on current market data and may be adjusted as the market changes. Please always conduct personal due diligence before making investment decisions.

That's it. You are building your personal stock analyst to help you enhance your investment process.

Real-world results

Testing the system on various stocks has shown promising results:

  • Cost reduction: The need for multiple financial database subscriptions can be eliminated by automatically aggregating data
  • Research efficiency: Reduces stock research time and can handle multiple companies at once, thus expanding coverage without adding staff
  • competitive analysis: Quickly generate peer comparisons and industry positioning
  • financial analysis: Reduces reliance on junior analysts for data collection, allowing them to focus on higher-value analysis
  • Multi-model support: Plug in Claude, GPT, Groq, HF models, or whatever LLM provider best suits your needs!

⚠️ Limitations

Although powerful, the system still has some limitations:

  • Limited ability to analyze data beyond LLM training deadlines
  • Reliance on external APIs for data quality and availability
  • Higher computational costs when using other tools and intelligences
  • Need precise tips on engineering
  • Complex decisions still require human oversight

🛠️ Potential Enhancements

Future enhancements may include:

  • Other Data Sources and APIs
  • More complex inter-intelligence communication
  • Enhanced visualization and code execution capabilities
  • Machine Learning Models for Pattern Recognition

reach a verdict

This multi-intelligence system is an important step forward in automating financial analysis and is free for everyone to use. By combining the strengths of different AI models and tools, we can create more powerful and comprehensive analytical workflows.

Remember: while AI can greatly enhance our analytical capabilities, it should be used as a complement to, not a substitute for, human judgment in investment decisions.

Disclaimer: This post is for educational purposes only and should not be considered financial advice. Always do your own research before making investment decisions.

May not be reproduced without permission:Chief AI Sharing Circle " Rapidly Build Stock Analysis Intelligence Body Intelligence with Phidata AI

Chief AI Sharing Circle

Chief AI Sharing Circle specializes in AI learning, providing comprehensive AI learning content, AI tools and hands-on guidance. Our goal is to help users master AI technology and explore the unlimited potential of AI together through high-quality content and practical experience sharing. Whether you are an AI beginner or a senior expert, this is the ideal place for you to gain knowledge, improve your skills and realize innovation.

Contact Us
en_USEnglish