Build compliant investment portfolios with AI risk agent
AI multi-agent system that automates portfolio construction, compliance checking, and risk analysis for investment advisors
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 Copy linkLink copied!
AI multi-agent system that automates portfolio construction, compliance checking, and risk analysis for investment advisors
Table of contents Copy linkLink copied!
Detailed description Copy linkLink copied!
The Challenge Copy linkLink copied!
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 Copy linkLink copied!
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 Copy linkLink copied!
AI/ML Copy linkLink copied!
- 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 Copy linkLink copied!
- 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 Copy linkLink copied!
- React + Vite + TypeScript — two-tab UI for pipeline execution and portfolio chat.
Infrastructure Copy linkLink copied!
- Podman/Docker Compose — local development.
- Red Hat OpenShift + Helm — production deployment.
- Optional: Knative — serverless agent auto-scaling.
Red Hat® OpenShift® AI Copy linkLink copied!
- 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 Copy linkLink copied!
Phase 1: Deterministic Pipeline Copy linkLink copied!
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 Copy linkLink copied!
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 Copy linkLink copied!
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 Copy linkLink copied!
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 Copy linkLink copied!
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 Copy linkLink copied!
OpenShift Cluster Deployment Copy linkLink copied!
- 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 Copy linkLink copied!
- Podman and Podman Compose (or Docker and Docker Compose)
- Make (for running deployment commands)
Required user permissions Copy linkLink copied!
Local Development Copy linkLink copied!
- Permission to run containers via Podman or Docker
- Access to local ports:
5000,7001,7002,7003,8080
OpenShift Cluster Deployment Copy linkLink copied!
- Authenticated to the OpenShift cluster (
oc login) - Permission to create or access a namespace/project
Deploy Copy linkLink copied!
Quick Start - OpenShift Deployment Copy linkLink copied!
- Clone the repository:
git clone https://github.com/rh-ai-quickstart/portfolio-manager-agent.git
cd portfolio-manager-agent
- Deploy to OpenShift:
make deploy-cluster
- 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 Copy linkLink copied!
1. Clone and Setup Repository Copy linkLink copied!
git clone https://github.com/rh-ai-quickstart/portfolio-manager-agent.git
cd portfolio-manager-agent
2. Configure Environment Variables Copy linkLink copied!
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 Copy linkLink copied!
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 Copy linkLink copied!
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:
- Set the Investment guidelines URL, Portfolio value, Number of symbols, and Max VaR.
- Click Run pipeline. A live progress log shows each step: guidelines parsing, portfolio construction (with VaR retry loop), and email drafting.
- 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 Copy linkLink copied!
Stop Local Deployment Copy linkLink copied!
podman compose -f deploy/local/compose.yml down
Delete from OpenShift Copy linkLink copied!
helm uninstall portfolio-manager-agent -n portfolio-manager-agent