StockBud.io Portfolio Schema
Schema for portfolio data structures used in StockBud.io trading system
💼 StockBud.io Portfolio Schema
Version: 1.0.0
Schema for portfolio data structures used in StockBud.io trading system
Overview
This schema defines 4 data structures:
Position- Individual position within a portfolio...Portfolio- Complete portfolio structure...PortfolioInsight- AI-generated portfolio insight or analysis...PortfolioTarget- Target portfolio allocation generated by AI strategies...
Definitions
Position
Individual position within a portfolio
Properties
| Property | Type | Required | Description |
|---|---|---|---|
symbol | string | ✓ | Stock symbol |
quantity | number | ✓ | Position quantity (can be fractional) |
market_value | number | ✓ | Current market value of position |
cost_basis | number | ✓ | Total cost basis of position |
unrealized_pnl | number | Unrealized profit/loss | |
realized_pnl | number | Realized profit/loss | |
side | enum: 'long', 'short' | ✓ | Position side |
average_entry_price | number | Average entry price | |
current_price | number | Current market price | |
weight | number | Position weight as percentage of portfolio | |
sector | string | Sector classification | |
last_update | string | Last position update timestamp |
TypeScript
Portfolio
Complete portfolio structure
Properties
| Property | Type | Required | Description |
|---|---|---|---|
account_id | string | ✓ | Unique account identifier |
account_type | enum: 'paper', 'live' | Account type | |
account_value | number | ✓ | Total account value |
cash_balance | number | ✓ | Available cash balance |
buying_power | number | Current buying power | |
day_trade_buying_power | number | Day trading buying power | |
equity | number | Total equity value | |
portfolio_value | number | Total portfolio value including cash | |
positions | Array<Position> | ✓ | Array of current positions |
daily_pnl | number | Daily profit/loss | |
total_pnl | number | Total profit/loss | |
margin_used | number | Amount of margin currently used | |
maintenance_margin | number | Required maintenance margin | |
last_sync | string | Last synchronization timestamp | |
created_at | string | Portfolio creation timestamp | |
updated_at | string | Last update timestamp |
TypeScript
PortfolioInsight
AI-generated portfolio insight or analysis
Properties
| Property | Type | Required | Description |
|---|---|---|---|
type | enum: 'risk_analysis', 'performance_analysis', 'diversification_analysis', 'sector_allocation', 'position_sizing', 'rebalancing_suggestion', 'market_opportunity', 'risk_warning' | ✓ | Type of insight |
severity | enum: 'low', 'medium', 'high', 'critical' | ✓ | Severity level of the insight |
confidence | number | ✓ | Confidence level of the insight (0-1) |
title | string | ✓ | Brief insight title |
message | string | ✓ | Detailed insight message |
recommendations | Array<string> | List of actionable recommendations | |
affected_symbols | Array<string> | Symbols affected by this insight | |
data | object | Additional data supporting the insight | |
timestamp | string | Insight generation timestamp | |
expires_at | string | When this insight expires |
TypeScript
PortfolioTarget
Target portfolio allocation generated by AI strategies
Properties
| Property | Type | Required | Description |
|---|---|---|---|
strategy_name | string | ✓ | Name of the strategy that generated this target |
target_weights | object | ✓ | Target weights by symbol |
cash_target | number | Target cash allocation | |
rebalance_threshold | number | Threshold for triggering rebalancing | |
confidence | number | Confidence in this target allocation | |
risk_score | number | Risk score of target portfolio (0-10) | |
expected_return | number | Expected annual return | |
expected_volatility | number | Expected annual volatility | |
rationale | string | Explanation of the target allocation | |
generated_at | string | ✓ | Target generation timestamp |
valid_until | string | Target validity expiration |