# Financial Advisor (Go)

## Overview

The Financial Advisor is a team of specialized AI agents that assists human financial advisors. This project is a Go implementation of the Financial Advisor agent, demonstrating how to build multi-agent systems using the Go Agent Development Kit.

1.  **Data Analyst Agent**: This agent is responsible for creating in-depth and current market analysis reports for specific stock tickers. It achieves this by repeatedly using Google Search to find a predetermined amount of unique, recent (within a given timeframe), and insightful information. The agent focuses on gathering both SEC filings and broader market intelligence via Google Search tool, which it then uses to compile a structured report based solely on the collected data.

2.  **Trading Analyst Agent**: This agent's task is to develop and describe at least five different trading strategies. It does this by carefully reviewing the comprehensive market analysis provided by the Data Analyst Agent. Each proposed strategy must be customized to match the user's declared risk tolerance and intended investment duration.

3.  **Execution Agent**: This agent creates a thorough and well-justified plan for implementing a given trading strategy. The plan must be carefully adjusted to fit the user's risk tolerance, investment timeframe, and preferred methods of execution. The output will be detailed and fact-based, examining the best approaches and specific timing for initiating, maintaining, adding to, partially selling, and completely exiting investment positions.

4.  **Risk Evaluation Agent**: This agent's role is to produce a detailed and reasoned analysis of the risks associated with a specific trading strategy and its execution plan. This analysis needs to be precisely aligned with the user's stated risk tolerance, investment period, and execution preferences. The output will be rich in factual analysis, clearly outlining all identified risks and suggesting concrete, actionable steps to lessen their impact.

**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.

This is not an offer to buy or sell any security. Investment decisions should not be made based solely on the information provided here. Financial markets are subject to risks, and past performance is not indicative of future results. You should conduct your own thorough research and consult with a qualified independent financial advisor before making any investment decisions.

By using this tool and reviewing these strategies, you acknowledge that you understand this disclaimer and agree that Google and its affiliates are not liable for any losses or damages arising from your use of or reliance on this information.

## Agent Details

The key features of the Financial Advisor include:

| Feature | Description |
| --- | --- |
| **Interaction Type** | Conversational |
| **Complexity**  | Medium |
| **Agent Type**  | Multi Agent |
| **Components**  | Tools: built-in Google Search |
| **Vertical**  | Financial |


### Agent architecture:

This diagram shows the detailed architecture of the agents and tools used
to implement this workflow.

(Architecture diagram for the Go implementation will be added here)

## Setup and Installation

1.  **Prerequisites**

    *   Go 1.19+
    *   A project on Google Cloud Platform
    *   Google Cloud CLI
        *   For installation, please follow the instruction on the official
            [Google Cloud website](https://cloud.google.com/sdk/docs/install).

2.  **Installation**

    ```bash
    # Clone this repository.
    git clone https://github.com/google/adk-samples.git
    cd adk-samples/go/agents/financial-advisor
    # Install dependencies
    go mod tidy
    ```

3.  **Configuration**

    *   Set up Google Cloud credentials.

        *   You may set the following environment variables in your shell, or in
            a `.env` file instead.

        ```bash
        export GOOGLE_GENAI_USE_VERTEXAI=true
        export GOOGLE_CLOUD_PROJECT=<your-project-id>
        export GOOGLE_CLOUD_LOCATION=<your-project-location>
        export GEMINI_API_KEY=<your-api-key>
        ```

    *   (Optional) Authenticate your GCloud account.

        ```bash
        gcloud auth application-default login
        gcloud auth application-default set-quota-project $GOOGLE_CLOUD_PROJECT
        ```

## Running the Agent

You can run the agent using the following command:

```bash
# GUI
go run main.go web api webui
```

or

```bash
# CLI
go run .
```

This will start a local server. You can then interact with the agent through a web interface or by making API calls.

### Example Interaction

Below is an example interaction with the Financial Advisor. Note that the exact output
of the agent may be different every time.

```
User: who are you

I am the financial coordinator agent. My role is to guide you through a structured process to receive financial advice. I work with specialized subagents to help you:

Analyze a market ticker.
Develop trading strategies based on your risk profile and investment goals.
Define an optimal plan for executing those strategies.
Evaluate the overall risk of the proposed plan.
How can I help you start this process today? For example, we could begin by analyzing a market ticker.

User: APPL

It looks like there might be a typo in the ticker symbol. Did you mean "AAPL" for Apple Inc.?

Once you confirm the correct ticker symbol, I will start the first step by calling the data_analyst subagent to gather comprehensive market data analysis for it.

User: correct

Okay, great. I will now call the data_analyst subagent to gather comprehensive market data analysis for the ticker symbol AAPL (Apple Inc.).

This analysis will include information like historical performance, key financial ratios, and relevant news sentiment, forming the foundation for our next steps.
```

## Customization

1.  **Enhance Data_Analyst Module Search Capabilities**: Integrate with specialized stock data repositories (APIs, databases) to provide more in-depth market data.
2.  **Implement Diverse Analyst Personas**: Create different agent personas with role-based access to data and tools for more tailored analysis.
3.  **Refine Prompt Engineering**: Continuously iterate on prompts to improve the precision and relevance of the AI's responses.
