Katkat

Design a Governed Agent for Portfolio Rebalancing

MillenniumData Scientist · Technical Screen

Last updated

Design an autonomous, LLM- or ML-driven portfolio rebalancing agent integrated with deterministic guardrails, pre-trade compliance checks, and audit logging. The design must guarantee safety, idempotency, strict separation of concerns, and full state reconstructibility.

Scenario

At a multi-strategy hedge fund, portfolio managers oversee hundreds of sub-portfolios comprising equities, futures, and FX derivatives. You are tasked with designing an AI-driven Portfolio Rebalancing Agent. The agent continuously monitors target asset allocations, market drift, macro signals, and alpha model outputs, generating candidate orders to rebalance positions.

Because generative agents can hallucinate or produce sub-optimal trades under market anomalies, no model-generated trade instruction may execute directly. Every action must pass through deterministic validation services (hard risk limits, mandate compliance, regulatory constraints, and human-in-the-loop approvals) before routing to execution management systems (EMS).

Requirements

Functional Requirements

  • Agent Proposal Engine: Ingest target weights, current positions, and market feeds to generate structured rebalancing plans (candidate orders with ticker, direction, notional/shares, and order type).
  • Deterministic Governance & Authorization Gateways:
    • Fresh-state check (ensure prices, positions, and cash balances have not drifted past tolerance since generation).
    • Entitlements and fund mandate checks (e.g., restricted lists, leverage ceilings, max sector exposure).
    • Hard pre-trade risk checks (VaR limits, drawdown caps, liquidity limits).
    • Escalation policy for human approval (e.g., trades exceeding 5% ADV or $10M notional).
  • Execution & Idempotency: Guarantee exactly-once execution semantics even under network retries or component failures.
  • Auditability & Compliance: Maintain an immutable, replayable audit trail capturing the exact prompt/context, tool outputs, governance decisions, risk snapshots, and human authorizations.

Non-Functional Requirements

  • Scale: 5,000 active portfolios, up to 100,000 candidate orders evaluated during rebalancing windows.
  • Latency: End-to-end validation and routing within under 500 ms for automated paths; sub-second updates for human-approval dashboards.
  • Confidentiality: Prevent cross-pod alpha leakage and protect non-public trading intent.

What Your Design Should Cover

  1. Architecture & Typed Orchestration: Component breakdown (Agent, State Store, Policy Engine, Order Router) using structured interfaces (e.g., Pydantic/Protobuf) rather than unstructured text.
  2. Validation Pipeline: Sequence of deterministic checks between candidate order generation and execution.
  3. Concurrency & Fresh-State Verification: Handling race conditions when market data updates between plan generation and execution.
  4. Data Model & Audit Schema: Schema for trade proposals, validation logs, and reconstructable event sourcing.
  5. Security & Information Barriers: Guarding proprietary alpha models and portfolio positions.

Hints

Hint 1

Decouple the probabilistic generation of trade proposals from deterministic authorization by treating the agent purely as a proposal generator with zero direct execution privileges.

Hint 2

Use optimistic concurrency control with position and market-data version tokens to detect stale state before authorization.

Hint 3

Store all inputs, intermediate tool outputs, deterministic rule evaluations, and cryptographic hashes of models/prompts in an append-only event log to satisfy reconstructability.

Follow-up questions

  • How does your architecture handle market data changes that occur while a human approver is reviewing a multi-million-dollar rebalance proposal?
  • If the agent proposes a basket of 50 interdependent trades and three fail hard risk checks, how does your system handle partial execution vs. whole-basket invalidation?
  • How would you detect and mitigate 'adversarial' or hallucinatory prompt injection if the agent ingests external market news or corporate filings to inform rebalancing?