HomeAdvanced module creation

Building Our Financial Analyst Agent

Welcome to the heart of our course!

In this module, we'll build a sophisticated financial analysis agent module using Naptha's agent architecture.

The run.py file is the default entry point that will be used when the module run is initiated so all our major agent logic will be implemented here. The run function therein can instantiate a class (e.g. an agent class) or call a function.

Understanding Agent Architecture

Before we write any code, let's explore how our agent system works. Imagine you're a financial analyst working with a team:

  • One team member gathers raw financial data
  • Another researches market trends
  • A third compiles everything into clear reports
Core Development Diagram 2

Building the Data Pipeline

The foundation of any useful financial analysis report is solid data. We will be using the yfinance library which we installed earlier to fetch financial data for our financial analyst agent module.

Let's build our data gathering system:

This function creates a comprehensive financial profile for each company provided. Think of it as gathering all the documents a human analyst would need to start their analysis.

Agent Roles and Responsibilities

Our agent system mirrors this human workflow through specialized AI agents working together. To achieve this, we will use CrewAI allowing our team of agents collaborate just like a human team would.

Let's examine each agent's role:

Notice how each agent has a specific role, just like specialists in a real financial team.

Coordinating the Analysis

Now comes the exciting part - coordinating our agent team. We use a task-based approach:

This orchestration is crucial - it ensures our agents work together effectively, building on each other's insights just like a real analysis team would.

Handling Results

Understanding how to process and present our analysis results is crucial:

Note how we set verbose=True in our setup. This will allow us to see the internal workings of each task as it is executed.

Final Version

Schema Definition (schema.py)
Main Implementation (run.py)

Phew! That was a lot of code.

Let's take a moment to reflect on what we've accomplished and in the next lesson, we'll watch our financial analyst agent in action. How exciting!

Next Steps

In the next module, we'll explore:

  • Testing our Financial Analyst Agent module locally with and without Naptha local node
  • Deploying to Naptha Hub
  • Handling real-world scenarios

Try experimenting with different analysis configurations before moving on. The more you understand how the pieces fit together, the better prepared you'll be for deployment.