A modular, multi-agent AI system for financial analysis, strategy generation, and risk evaluation, built with Google ADK and Gemini API.
This project is designed to be extensible for both stateless and stateful (database-backed) agent workflows.
If you wish to persist user sessions, analysis results, or agent state, you can connect your own database (e.g., PostgreSQL, MySQL, SQLite).
Database connection details are managed via environment variables in your .env file.
By default, the agent does not require a database to run, but you can add one for advanced use cases such as logging, analytics, or persistent memory.
AI/
├── .env
├── .env.example
├── README.md
├── requirements.txt
├── MODELS/
│ ├── __init__.py # Model constants (REASONING_MODEL, etc.)
│ └── models_list.py # Model listing/scraping utilities
├── configs/
│ └── settings.py # (Optional) App/database config
├── logs/
│ ├── __init__.py # Marks logs as a package
│ ├── logger.py # Logging setup utilities
│ └── financial_advisor/
│ ├── financial_advisor.log # Main agent log
│ ├── event.log # Event log
│ ├── request.log # Request log
│ └── response.log # Response log
│── financial_advisor/
│ ├── __init__.py
│ ├── agent.py # Root orchestrator agent
│ ├── prompt.py
│ ├── main.py
│ └── sub_agents/
│ ├── __init__.py
│ ├── data_analyst.py
│ ├── trading_analyst.py
│ ├── execution_analyst.py
│ ├── risk_analyst.py
│ └── news_analyst.py
-
Location: All logging utilities are in
logs/logger.py. -
Log File: All logs are stored in a single file:
logs/financial_advisor/financial_advisor.log.- This log contains all info, errors, events, requests, responses, and token usage for both the main agent and all sub-agents.
-
Logger Setup:
logs/logger.pyprovides the function:setup_logger(agent_name): Main logger for the agent and sub-agents.
- All logging is routed through this logger.
-
Usage Example:
from logs.logger import setup_logger logger = setup_logger("financial_advisor") logger.info("Agent started.") logger.info("REQUEST: ...") logger.info("RESPONSE: ...") logger.info("ADK_EVENT: ...") # Token usage is included in ADK_EVENT logs.
-
Log Directory Creation:
The logger utility will automatically create thelogs/financial_advisor/directory if it does not exist. -
Sub-agent Logging:
Insub_agents/__init__.py, helper functions (log_subagent_call,log_event,log_request,log_response) are provided to standardize logging across all sub-agents, and all use the main logger.
The Financial Advisor is a team of specialized AI agents that assists human financial advisors.
- Data Analyst Agent: Creates in-depth and current market analysis reports for specific stock tickers using Google Search and other data sources.
- Trading Analyst Agent: Develops and describes at least five different trading strategies tailored to the user's risk tolerance and investment duration.
- Execution Agent: Creates a thorough plan for implementing a given trading strategy, adjusted to the user's preferences.
- Risk Evaluation Agent: Produces a detailed analysis of the risks associated with a specific trading strategy and its execution plan.
Legal Disclaimer and User Acknowledgment
Important Disclaimer: For Educational and Informational Purposes Only.
The information and trading strategy outlines provided by this tool, including any analysis, commentary, or potential scenarios, are generated by an AI model and are for educational and informational purposes only. They do not constitute, and should not be interpreted as, financial advice, investment recommendations, endorsements, or offers to buy or sell any securities or other financial instruments.
Google and its affiliates make no representations or warranties of any kind, express or implied, about the completeness, accuracy, reliability, suitability, or availability with respect to the information provided. Any reliance you place on such information is therefore strictly at your own risk.
- Python 3.11+
- Poetry (for dependency management and packaging): Poetry installation
- You do NOT need a Google Cloud Platform project or Google Cloud CLI if you are using the Gemini API with an API key.
- You only need a Google API key from https://aistudio.google.com/app/apikey.
- No other credentials or cloud setup are required for API key usage.
# Clone this repository.
# Install the package and dependencies.
poetry install- Copy
.env.exampleto.envand add your API keys:GOOGLE_API_KEY=your-google-api-key-here ALPHA_VANTAGE_API_KEY=your-alpha-vantage-api-key-here - If you want to use a database, add your database credentials to
.envas well. - Never commit your real
.envfile to git. - Do NOT set GOOGLE_GENAI_USE_VERTEXAI or any Google Cloud credentials unless you want to use Vertex AI.
- You do NOT need to run
gcloud auth application-default loginor set up ADC for API key usage.
To run your agent using the ADK web server, use the following command from your project root:
adk web agents/financial_advisor- This will start a local web server (default: http://localhost:8000).
- You can interact with your agent via the web UI or API.
- Replace
agents/financial_advisorwith the path to your agent module if different.
Streaming:
- ADK web UI and API support streaming responses by default. When you interact with your agent via the web interface (http://localhost:8000), responses are streamed as they are generated.
Hot Reload (Auto-reload):
- By default,
adk webwill not automatically reload your agent when you change the source code. - To enable auto-reload (hot reload) during development, use the
--reloadflag:
adk web agents/financial_advisor --reload-
With
--reload, the server will watch your source files and automatically restart when you make changes. This allows you to edit your code and see changes without manually stopping and starting the server. -
In
financial_advisor/__init__.py:from . import agent import MODEL
Note:
- Some changes (like adding new dependencies) may still require a manual restart.
- For production, do not use
--reload.
- In `financial_advisor/agent.py` (or any submodule):
```python
import MODELS
- In
financial_advisor:import MODELS print("Financial Advisor Agent initialized with models:") print(f"Reasoning Model: {MODELS.REASONING_MODEL}") print(f"Flash Model: {MODELS.FLASH_MODEL}") print(f"Text-to-Speech Model: {MODELS.TEXT_TO_SPEECH_MODEL}") print(f"Audio Dialog Model: {MODELS.AUDIO_DIALOG_MODEL}")
This setup ensures that MODELS is always available to your agent and sub-agents, and you can print or use it anywhere in the financial_advisor package.
- Ensure your
.envis present and contains your API keys. - If you see errors about missing credentials, make sure you are not setting any Google Cloud/Vertex variables and are only using
GOOGLE_API_KEY. - Check logs for connection errors or misconfiguration.
- Add or modify sub-agents in
agents/financial_advisor/sub_agents/. - Update model names/IDs in
MODELS/__init__.py. - Adjust prompts and workflow in
agents/financial_advisor/prompt.pyandagent.py.