Portfolio Management
Persona
Role: Full-stack developer at a registered investment advisory (RIA) firm (60 employees, 3 billion AUM) building an internal portfolio management tool.
Each client relationship team operates as a separate tenant, maintaining independent portfolio data and trading activity. The firm needs a unified view of holdings and rebalancing activity while ensuring that client-level data access is restricted to authorized advisors.
Business Problem
Portfolio managers spend hours each week manually comparing current allocations against target models, identifying drift, and generating trade lists for rebalancing. Holdings data lives in custodian reports, target allocations in spreadsheets, and trade confirmations in email. This scenario builds a portfolio management platform where holdings, target allocations, and rebalancing trades are tracked in a single system with real-time drift visibility.
Four-Step Application
This scenario works best as a four-step, human-in-the-loop application. The existing object model already gives this scenario a strong delivery backbone through Portfolio, Holding, and RebalanceOrder.
- Mission metric focus: faster cycle time, better compliance quality, and stronger revenue or loss performance.
- Human + AI pattern: Each step combines structured workflow data with chat assistance, background generation, document understanding, and accessible interaction patterns when they improve the experience.
Step 1. Capture demand and context
- Goal: Make it easy for the user to start the Portfolio Management journey with complete, trusted context.
- Required data: Portfolio context such as name, owner, strategy, and targetAllocation.
- AI support: Use chat to guide intake, generate clearer prompts, create accessible summaries, and assist with voice or vision-led capture when a form alone is not the best experience. EAI can support structured intake, chat workflows, and document-centred capture today; richer native multimodal capture may still need workflow extensions or connected services.
- Business impact: Improve completion rate, reduce first-touch effort, and raise customer or staff confidence in the UX from the very first interaction.
- EAI delivery: Model the intake as tenant-isolated object types and resources, then use actions, chat workflows, and document indexing or classification to keep the initial record complete and usable.
Step 2. Prepare the decision
- Goal: Turn the captured context into the next best action for Portfolio Management without forcing the human reviewer to assemble the case manually.
- Required data: Portfolio state and history; Holding fields such as asset, quantity, costBasis, and currentValue.
- AI support: Run background summarisation, extraction, classification, recommendation drafting, and answer generation so a reviewer sees a prepared case instead of raw fragments. EAI delivers the structured records and AI workflow hooks for this today; specialised scoring engines, external rules, or advanced reasoning controls may still need integration work.
- Business impact: Reduce cycle time, improve quality and consistency, and protect the mission-critical metric before the case moves into execution.
- EAI delivery: Link records across the scenario, persist decision state as resources, and use workflow actions plus chat assistance to keep humans in control while AI prepares the work.
Step 3. Execute and collaborate
- Goal: Coordinate the actual work, handoffs, approvals, and user updates needed to deliver the service or outcome.
- Required data: Holding actions such as updateValuation; RebalanceOrder fields such as trades, status, proposedDate, and executedDate.
- AI support: Draft replies, produce work packets, monitor exceptions in the background, and surface the next action for each operator. EAI can orchestrate tenant-isolated records, actions, chats, and document workflows today; deeper system-to-system automation may require additional connectors or workflow capability.
- Business impact: Increase operator productivity, reduce rework across handoffs, and improve service consistency across the application journey.
- EAI delivery: Use linked object types, actions, resource updates, and workflow-triggered AI assistance so the team can execute in one model instead of splitting work across disconnected tools.
Step 4. Resolve, explain, and improve
- Goal: Close the loop with a clear outcome, an understandable explanation, and feedback that improves the next case.
- Required data: final status, outcome, audit history, and follow-up signals across Portfolio, Holding, and RebalanceOrder.
- AI support: Generate outcome summaries, customer-friendly answers, compliance-ready notes, management insights, and accessible follow-up content. EAI can store outcome records and support answer generation today, while richer proactive agents, advanced analytics, or channel-specific accessibility features may need additional product capability.
- Business impact: Increase trust, quality, and measurable business value through faster cycle time, better compliance quality, and stronger revenue or loss performance.
- EAI delivery: Keep the full audit trail in structured resources, use AI workflows to explain outcomes, and feed the resulting signals into future product, service, and operational improvement work.
EAI Platform Support By Step
EAI provides the safe service boundary for Portfolio Management through Object Types, tenant-scoped resources, document processing, chat workflows, and CLI verification. For this scenario, the main records are Portfolio, Holding, and RebalanceOrder.
| Process step | What EAI provides | Calling pattern |
|---|---|---|
| Step 1. Capture demand and context | Tenant-scoped intake resources for Portfolio context such as name, owner, strategy, and targetAllocation. Object Type validation, starter forms, optional document intake, and chat-guided capture keep the first record complete. | Define fields in src/eai.config/object-types.ts, run eai types validate and eai types seed, create initial Portfolio records with useResources('Portfolio') or eai resources create Portfolio, and keep browser calls behind /api/eai/.... |
| Step 2. Prepare the decision | Linked resource queries over Portfolio state and history; Holding fields such as asset, quantity, costBasis, and currentValue. Search, schema checks, document classification or RAG indexing, and chat summaries turn raw context into a prepared decision. | Use useResources('Portfolio') list/query/search patterns, verify shape with eai resources schema, use useDocuments().upload/classify/ragIndex, eai docs upload, eai docs classify, and eai docs index where supporting material exists, and send decision-support prompts through useChat(workflowId, 'chat') or eai chat send. |
| Step 3. Execute and collaborate | Resource updates and actions for Holding actions such as updateValuation; RebalanceOrder fields such as trades, status, proposedDate, and executedDate. Status changes, assignments, notes, generated work packets, and chat support keep humans in control during execution. | Model actions in the Object Type code, call client.resources.executeAction(type, id, action) or the app hook equivalent, update records through the app service layer, and verify with eai resources get/list/query. |
| Step 4. Resolve, explain, and improve | Outcome resources for final status, outcome, audit history, and follow-up signals across Portfolio, Holding, and RebalanceOrder. Audit-friendly links, indexed final documents, reporting snapshots, and answer generation make the result explainable and reusable. | Persist outcomes as resources, index final material with eai docs index or useDocuments().ragIndex, send explanation prompts with useChat or eai chat stream, and use eai resources aggregate/search for reporting checks. |
Prompt, Code, And Service Pattern Mapping
The Object Type code example on this page is the implementation contract for the EAI platform services. eai-gofer should read that code as the source of truth for which resource, document, and chat calls belong in the app.
Use this prompt shape when asking eai-gofer or another coding agent to implement the scenario:
Use the EAI App Template. Model Portfolio Management with Object Types for Portfolio, Holding, RebalanceOrder. Use useResources for records and actions, useDocuments for uploads/classification/RAG where documents appear, useChat for workflow assistance, and verify with eai types/resources/docs/chat commands. Use eai publicapi only when no named command covers the required platform call.
| Scenario artifact | How it maps to EAI service calls |
|---|---|
| Four-step process | Step 1 becomes resource creation, Step 2 becomes resource query/search plus optional document or chat preparation, Step 3 becomes resource update/action calls, and Step 4 becomes outcome persistence plus explanation/reporting calls. |
| Object Type definitions | eai types validate, eai types seed, and eai resources schema make the model available and checkable before UI work starts. |
| Properties and indexes | Fields become useResources payloads, filters, list views, and eai resources create/list/query/search checks. Indexed fields should support lookup and triage, not duplicate canonical records. |
| Links between Object Types | Relationships become linked-resource UI, timeline context, and audit trails that app code loads through resource queries rather than separate bespoke stores. |
| Actions and status fields | Workflow buttons and operator transitions call resource action/update helpers, then verify state with eai resources get/list/query. |
| Document and chat prompts | Prompts should call the platform documents and chat patterns: useDocuments().upload/classify/ragIndex, eai docs upload, eai docs classify, and eai docs index for documents, and useChat, eai chat send, or eai chat stream for conversational assistance. |
Object Types
| Name | Key Properties | Links | Actions |
|---|---|---|---|
| Portfolio | name (text), owner (text), strategy (select: growth, balanced, income, aggressive), targetAllocation (text), inceptionDate (date) | one-to-many → Holding, one-to-many → RebalanceOrder | setTargetAllocation |
| Holding | asset (text), quantity (number), costBasis (number), currentValue (number), assetClass (select: equity, fixed-income, cash, alternative) | many-to-one → Portfolio | updateValuation |
| RebalanceOrder | trades (text), status (select: proposed, approved, executing, completed, cancelled), proposedDate (date), executedDate (date), totalValue (number) | many-to-one → Portfolio | executeRebalance |
CLI Workflow
-
Scaffold the project
eai init portfolio-management -
Authenticate and pull environment
eai logineai env pull --include-secretsIf you are an external developer, see [Configuration](/docs/configuration) for login and local environment setup. -
Define your Object Types
Create the Portfolio, Holding, and RebalanceOrder types in
src/eai.config/object-types.ts(see code example below). -
Validate the type definitions
eai types validateTenant: portfolio-management✔ Portfolio — 5 props, 2 links, 1 action✔ Holding — 5 props, 1 link, 1 action✔ RebalanceOrder — 5 props, 1 link, 1 action✔ All Object Types are valid -
Seed types to the platform
eai types seed -
Create a sample portfolio and holdings
eai resources create Portfolio --data '{"name": "Chen Family Trust", "owner": "David Chen", "strategy": "balanced", "targetAllocation": "60% equity, 30% fixed-income, 10% cash", "inceptionDate": "2024-06-15"}'eai resources create Holding --data '{"asset": "VTI - Vanguard Total Stock Market ETF", "quantity": 450, "costBasis": 95200, "currentValue": 108450, "assetClass": "equity"}'eai resources create Holding --data '{"asset": "BND - Vanguard Total Bond Market ETF", "quantity": 620, "costBasis": 45260, "currentValue": 44640, "assetClass": "fixed-income"}' -
List portfolio holdings
eai resources list Holding -
Start local development
eai dev
Code Example
// src/eai.config/object-types.ts
export const objectTypes = {
'portfolio-management': [
{
name: 'Portfolio',
displayName: 'Portfolio',
description: 'An investment portfolio with target allocation and strategy designation',
properties: [
{ name: 'name', type: 'text' as const, required: true, indexed: true },
{ name: 'owner', type: 'text' as const, required: true, indexed: true },
{
name: 'strategy', type: 'select' as const, required: true,
options: [
{ label: 'Growth', value: 'growth' },
{ label: 'Balanced', value: 'balanced' },
{ label: 'Income', value: 'income' },
{ label: 'Aggressive', value: 'aggressive' },
],
},
{ name: 'targetAllocation', type: 'text' as const, required: true },
{ name: 'inceptionDate', type: 'date' as const, required: true },
],
linkTypes: [
{ name: 'holdings', targetObjectType: 'Holding', cardinality: 'one-to-many' as const },
{ name: 'rebalanceOrders', targetObjectType: 'RebalanceOrder', cardinality: 'one-to-many' as const },
],
actions: [
{
name: 'setTargetAllocation',
displayName: 'Set Target Allocation',
description: 'Update the portfolio target allocation model for rebalancing',
inputs: [
{ name: 'targetAllocation', type: 'text' as const, required: true },
{ name: 'strategy', type: 'select' as const, required: true },
],
},
],
status: 'published' as const,
},
{
name: 'Holding',
displayName: 'Holding',
description: 'A position in an asset held within a portfolio',
properties: [
{ name: 'asset', type: 'text' as const, required: true, indexed: true },
{ name: 'quantity', type: 'number' as const, required: true },
{ name: 'costBasis', type: 'number' as const, required: true },
{ name: 'currentValue', type: 'number' as const, required: true },
{
name: 'assetClass', type: 'select' as const, required: true,
options: [
{ label: 'Equity', value: 'equity' },
{ label: 'Fixed Income', value: 'fixed-income' },
{ label: 'Cash', value: 'cash' },
{ label: 'Alternative', value: 'alternative' },
],
},
],
linkTypes: [
{ name: 'portfolio', targetObjectType: 'Portfolio', cardinality: 'many-to-one' as const },
],
actions: [
{
name: 'updateValuation',
displayName: 'Update Valuation',
description: 'Refresh the current market value for this holding',
inputs: [
{ name: 'currentValue', type: 'number' as const, required: true },
],
},
],
status: 'published' as const,
},
{
name: 'RebalanceOrder',
displayName: 'Rebalance Order',
description: 'A set of proposed trades to realign a portfolio with its target allocation',
properties: [
{ name: 'trades', type: 'text' as const, required: true },
{
name: 'status', type: 'select' as const, required: true,
defaultValue: 'proposed',
options: [
{ label: 'Proposed', value: 'proposed' },
{ label: 'Approved', value: 'approved' },
{ label: 'Executing', value: 'executing' },
{ label: 'Completed', value: 'completed' },
{ label: 'Cancelled', value: 'cancelled' },
],
},
{ name: 'proposedDate', type: 'date' as const, required: true },
{ name: 'executedDate', type: 'date' as const, required: false },
{ name: 'totalValue', type: 'number' as const, required: true },
],
linkTypes: [
{ name: 'portfolio', targetObjectType: 'Portfolio', cardinality: 'many-to-one' as const },
],
actions: [
{
name: 'executeRebalance',
displayName: 'Execute Rebalance',
description: 'Approve and execute the proposed rebalancing trades',
inputs: [
{ name: 'approvedBy', type: 'text' as const, required: true },
{ name: 'executionNotes', type: 'text' as const, required: false },
],
},
],
status: 'published' as const,
},
],
};
Key Takeaways
- Drift-aware rebalancing: Portfolio target allocations are stored alongside current holdings, enabling automated drift detection and trade list generation through the
executeRebalanceaction. - Cost basis tracking: Every Holding records cost basis and current value, supporting unrealized gain/loss calculations critical for tax-aware portfolio management.
- Approval workflow for trades: RebalanceOrder progresses through proposed, approved, and executing stages, ensuring that no trades are executed without proper authorization -- a regulatory requirement for advisory firms.
- Team-level access control: Each client relationship team operates in its own tenant, so advisors only see portfolios they are authorized to manage, enforced at the platform level rather than in application logic.