Build compliant investment portfolios with AI risk agent

AI multi-agent system that automates portfolio construction, compliance checking, and risk analysis for investment advisors

Build compliant investment portfolios with AI risk agentAI multi-agent system that automates portfolio construction, compliance checking, and risk analysis for investment advisorsBanking and securitiesRed Hat OpenShift AIRed Hat

This content is authored by Red Hat experts, but has not yet been tested on every supported configuration.

Build compliant investment portfolios with AI risk agent

AI multi-agent system that automates portfolio construction, compliance checking, and risk analysis for investment advisors

Table of contents

  1. Detailed description
  2. Requirements
  3. Deploy
  4. References
  5. Tags

Detailed description

The Challenge

Portfolio managers at asset management firms must build investment portfolios that satisfy each client's unique guidelines, meet risk tolerances, avoid prohibited securities, and hit return targets. Now multiply that across tens or hundreds of clients. The manual process — reading guideline documents, cross-referencing prohibited tickers, running risk calculations, and drafting client communications — is slow, error-prone, and does not scale.

Our Solution

An AI multi-agent system that automates the end-to-end portfolio construction workflow in two phases:

Phase 1 — Deterministic Pipeline:

  • Parses client investment guideline PDFs and extracts prohibited ticker symbols using an MLP classifier
  • Builds a compliant equal-weight equity portfolio from the S&P 100, excluding prohibited securities
  • Calculates 1-day parametric Value at Risk (VaR) at 99% confidence
  • Automatically retries portfolio construction if VaR exceeds the client's risk threshold (up to 10 attempts)
  • Drafts a client-ready summary email via the LLM

Phase 2 — Agentic Chat:

  • Interactive chat where the LLM can call portfolio and VaR tools to modify holdings and recalculate risk
  • Prohibited tickers from Phase 1 persist — the advisor cannot violate compliance constraints
  • VaR is automatically recalculated after every portfolio change

Our Solution Stack

AI/ML

  • LLM — powers email drafting, agentic chat reasoning, and tool selection (served via OpenShift AI model serving or any OpenAI-compatible endpoint). Tested with Llama 3.3 70B quantized.
  • scikit-learn MLP — classifies guideline sentences as prohibition-related to extract banned tickers.

Backend Services

  • Flask — REST API orchestrator + 3 specialized tool agents.
  • OpenAI Python SDK — LLM function calling for agentic chat.
  • yfinance — real-time market data for portfolio pricing and VaR calculation.

Frontend

  • React + Vite + TypeScript — two-tab UI for pipeline execution and portfolio chat.

Infrastructure

  • Podman/Docker Compose — local development.
  • Red Hat OpenShift + Helm — production deployment.
  • Optional: Knative — serverless agent auto-scaling.

Red Hat® OpenShift® AI

  • Model Serving (KServe) — serves the scikit-learn MLP classifier as an InferenceService (MLServer sklearn runtime, S3/MinIO storage).
  • NeMo Guardrails (TrustyAI) — input/output filtering that blocks sensitive data and off-topic requests.

Architecture diagrams

Phase 1: Deterministic Pipeline

The UI calls granular orchestrator endpoints in sequence, reimplementing the retry loop client-side for real-time progress feedback.

Figure 1: Deterministic pipeline — parse guidelines, build portfolio, calculate VaR with retry loop, draft email.

flowchart TD
  Start["User submits pipeline request"] --> G["1. Parse Guidelines PDF"]
  G -->|"prohibited tickers"| P["2. Build Portfolio"]
  P -->|"holdings"| V["3. Calculate VaR"]
  V --> Check{"VaR > max?"}
  Check -->|"Yes, up to 10x"| P
  Check -->|"No"| E["4. Draft Client Email via LLM"]
  E --> Done["Return results"]

Phase 2: Agentic Chat

The LLM selects from portfolio_equities, portfolio_replace_symbol, and value_at_risk tools. Guidelines are frozen — prohibited tickers cannot be overridden. VaR is recalculated automatically after every portfolio mutation.

Figure 2: Agentic chat — LLM selects tools to modify holdings and recalculate VaR while respecting frozen guidelines.

sequenceDiagram
  participant User
  participant UI
  participant Orchestrator
  participant LLM
  participant Tools as Portfolio/VaR Agents

  User->>UI: Chat message
  UI->>Orchestrator: POST /chat with message + context
  Orchestrator->>LLM: System prompt + tools
  LLM-->>Orchestrator: Tool call
  Orchestrator->>Tools: POST /tools/tool_name
  Tools-->>Orchestrator: Result
  Orchestrator->>LLM: Tool result
  LLM-->>Orchestrator: Final response
  Orchestrator-->>UI: Response + updated context
  UI-->>User: Display answer + refreshed portfolio outputs

See it in action

Deploy locally with make deploy-local and open the UI at http://localhost:8080, or deploy to OpenShift with make deploy-cluster and open the route (see Usage). Explore the pipeline and chat tabs.

Requirements

NOTE: This quickstart assumes a large language model is already deployed in your environment. Guidance for deploying models is available in the References section.

Minimum hardware requirements

Application:

  • CPU: 2 vCPU (request) / 4 vCPU (limit)
  • Memory: 4 GiB (request) / 8 GiB (limit)
  • Storage: 10 GiB
  • Optional: GPU — required if you plan to deploy your own model on OpenShift AI, for deployment refer to References.

Minimum software requirements

OpenShift Cluster Deployment

  • Red Hat OpenShift AI 2.25.0 or later (for model serving)
  • Helm 3.0.0 or later
  • oc CLI (for OpenShift)
  • LLM Model Server — Red Hat OpenShift AI model serving (vLLM) recommended, or any OpenAI-compatible endpoint.

Local Development Requirements

  • Podman and Podman Compose (or Docker and Docker Compose)
  • Make (for running deployment commands)

Required user permissions

Local Development

  • Permission to run containers via Podman or Docker
  • Access to local ports: 5000, 7001, 7002, 7003, 8080

OpenShift Cluster Deployment

  • Authenticated to the OpenShift cluster (oc login)
  • Permission to create or access a namespace/project

Deploy

Quick Start - OpenShift Deployment

  1. Clone the repository:
git clone https://github.com/rh-ai-quickstart/portfolio-manager-agent.git
cd portfolio-manager-agent
  1. Deploy to OpenShift:
make deploy-cluster
  1. Get the UI URL:
oc get route ui -n portfolio-manager-agent -o jsonpath='https://{.spec.host}'

This reads your .env file (if present) and passes any non-empty OPENAI_* values to Helm, so the UI starts with LLM connection settings pre-filled.

To deploy with serverless (Knative) agents:

helm upgrade --install portfolio-manager-agent deploy/helm \
  -n portfolio-manager-agent --create-namespace \
  --set serverless.enabled=true

Quick Start - Local Development

1. Clone and Setup Repository

git clone https://github.com/rh-ai-quickstart/portfolio-manager-agent.git
cd portfolio-manager-agent

2. Configure Environment Variables

cp .env.example .env

Edit .env with your LLM configuration:

OPENAI_API_ENDPOINT=https://your-llm-host/v1   # OpenAI-compatible endpoint (include /v1)
OPENAI_API_TOKEN=sk-your-api-key                # API key for the endpoint
OPENAI_MODEL=llama-3-3-70b-instruct-w8a8        # Model name

Tip: For enterprise deployments, we recommend using Red Hat OpenShift AI model serving to host your LLM with built-in GPU support, autoscaling, and enterprise security.

3. Start All Services

make deploy-local
# equivalent to: podman compose -f deploy/local/compose.yml up -d --build
Service URL
UI http://localhost:8080
Orchestrator API http://localhost:5000

Usage

Open the UI at http://localhost:8080 (local) or the OpenShift route:

oc get route ui -n portfolio-manager-agent -o jsonpath='https://{.spec.host}'

If you created a .env file, the LLM endpoint, API key, and model are loaded automatically. Otherwise, expand Connection settings to enter them manually.

Tab 1 — Portfolio Setup:

  1. Set the Investment guidelines URL, Portfolio value, Number of symbols, and Max VaR.
  2. Click Run pipeline. A live progress log shows each step: guidelines parsing, portfolio construction (with VaR retry loop), and email drafting.
  3. On success, results appear in Portfolio outputs and the chat tab unlocks.

Tab 2 — Discuss Portfolio:

  • Chat about the portfolio — the LLM can call tools to swap holdings, rebuild the portfolio, or recalculate VaR.
  • Portfolio outputs refresh automatically when the context changes.

Delete

Stop Local Deployment

podman compose -f deploy/local/compose.yml down

Delete from OpenShift

helm uninstall portfolio-manager-agent -n portfolio-manager-agent

References

Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat Documentation

Legal Notice

Theme

© 2026 Red Hat
Back to top