Portfolios
NewUpdated
The chaos.portfolios namespace lets you create and manage investment portfolios — both manual (user-defined holdings) and automatic (wallet-tracked). Generate AI reports, refresh analytics, view transactions, and run AI analysis sessions.
import { Chaos } from '@chaoslabs/ai-sdk';
const chaos = new Chaos({ apiKey: process.env.CHAOS_API_KEY! });
// Create a manual portfolio with holdings
const portfolio = await chaos.portfolios.createManual({
name: 'DeFi Blue Chips',
holdings: [
{ symbol: 'ETH', quantity: 10, purchaseDate: 1704067200 },
{ symbol: 'AAVE', quantity: 50, purchaseDate: 1706745600, purchasePrice: 95 },
],
});
// List all portfolios
const { data, total } = await chaos.portfolios.list({ page: 1, limit: 20 });
// Get an AI-generated report
const report = await chaos.portfolios.report(portfolio.id);
// Ask AI about your portfolio
const session = await chaos.portfolios.analyse(portfolio.id, 'How is my portfolio performing?');Copy code
Open in Cursor
Open in VS Code
Open in v0
Open in Claude
Open in ChatGPT
Method Reference
| Method | HTTP | Endpoint | Returns |
|---|---|---|---|
createManual(params) | POST | /v1/portfolios/manual | Portfolio |
createAutomatic(params) | POST | /v1/portfolios/automatic | Portfolio |
list(params?) | GET | /v1/portfolios | PortfolioListResponse |
get(portfolioId) | GET | /v1/portfolios/{portfolioId} | Portfolio |
update(portfolioId, params) | PUT | /v1/portfolios/{portfolioId} | Portfolio |
delete(portfolioId) | DELETE | /v1/portfolios/{portfolioId} | void |
byType(portfolioType) | GET | /v1/portfolios/type/{portfolioType} | Portfolio[] |
report(portfolioId) | GET | /v1/portfolios/{portfolioId}/report | PortfolioReport |
refreshReport(portfolioId, force?) | POST | /v1/portfolios/{portfolioId}/report/refresh | RefreshReportResponse |
transactions(portfolioId) | GET | /v1/portfolios/{portfolioId}/transactions | PortfolioTransactions |
analyse(portfolioId, query?, clientRequestId?) | POST | /v1/portfolios/{portfolioId}/analyse | SessionData |
createSession(params) | POST | /v1/portfolio/sessions | SessionData |
analyze(params) | POST | /v1/portfolio/analyze | PortfolioWorkflowResponse |
Core Types
type PortfolioType = 'manual' | 'automatic';
interface PortfolioHolding {
symbol: string;
quantity: number;
purchaseDate: number; // Unix timestamp
purchasePrice?: number | null;
asset_type?: string | null;
}
interface CreateManualPortfolioParams {
name: string;
holdings: PortfolioHolding[];
}
interface CreateAutomaticPortfolioParams {
name: string;
wallet_address?: string;
chain?: string;
}
interface UpdatePortfolioParams {
name?: string;
}
interface Portfolio {
id: string;
name: string;
portfolioType: PortfolioType;
userId: string;
holdings?: PortfolioHolding[] | null;
wallets?: unknown[] | null;
createdAt: number;
updatedAt: number;
}
interface PortfolioListParams {
page?: number;
limit?: number;
portfolioIds?: string[];
}
interface PortfolioListResponse {
data: Portfolio[];
total: number;
}
interface PortfolioReport {
status: string;
retry_after?: number | null;
}
interface RefreshReportResponse {
taskId: string;
message: string;
retryAfter: number;
}
interface PortfolioTransactions {
transactions: unknown[];
}
interface CreatePortfolioSessionParams {
query: string;
workflow_id: string;
}
interface PortfolioWorkflowParams {
[key: string]: unknown;
}
interface PortfolioWorkflowResponse {
[key: string]: unknown;
}
interface SessionData {
sessionId: string;
userId: string;
createdAt: number;
updatedAt: number;
type: string;
workflowId: string;
workflowName: string;
title: string;
isBookmarked: boolean;
isPublished: boolean;
blocks: unknown[];
agentMessages: unknown[];
}Copy code
Open in Cursor
Open in VS Code
Open in v0
Open in Claude
Open in ChatGPT
Was this helpful?