S
StockBud Docs

JSON Schemas

Type-safe data structures for StockBud.io

📐 JSON Schemas

StockBud uses JSON Schema (Draft-07) for data validation across all components. These schemas define the structure of portfolios, trades, market data, and more.

All schemas are available in kb_catalog/schemas/ and can be used for TypeScript type generation.

Schema Catalog

SchemaDescription
💼 PortfolioPositions, portfolio insights, and allocation targets
📈 TradingOrders, trades, signals, and strategies
🏛️ Market DataQuotes, OHLCV bars, options, and news
🔌 MCP ServerTool definitions, requests, and responses
🤖 AI AgentsPersonas, memory, and behavioral patterns
📊 MetricsPerformance tracking and analytics
⚙️ ConfigurationSystem config and deployment settings
🔔 NotificationsAlerts, templates, and preferences

Using Schemas

TypeScript Type Generation

Generate TypeScript types from our JSON schemas:

# Using json-schema-to-typescript
npx json-schema-to-typescript \
  -i kb_catalog/schemas/*.json \
  -o types/

Python Validation

import json
import jsonschema
 
# Load the schema
with open('kb_catalog/schemas/portfolio.json') as f:
    schema = json.load(f)
 
# Validate your data
portfolio_data = {
    "account_id": "abc123",
    "account_value": 125000.00,
    "cash_balance": 25000.00,
    "positions": []
}
 
jsonschema.validate(portfolio_data, schema)
print("✅ Valid portfolio data!")

OpenAPI Integration

Reference schemas in your OpenAPI spec:

components:
  schemas:
    Portfolio:
      $ref: './kb_catalog/schemas/portfolio.json#/definitions/Portfolio'
    Position:
      $ref: './kb_catalog/schemas/portfolio.json#/definitions/Position'

Schema Versioning

All schemas follow semantic versioning:

Version PartWhen to Update
MajorBreaking changes (removed fields, type changes)
MinorNew optional fields, new definitions
PatchBug fixes, description updates

Current version: 1.0.0

Data Flow

Market Data ──► Trading Signals ──► Orders ──► Trades
     │               │                │          │
     ▼               ▼                ▼          ▼
Portfolios ◄── Positions ◄────────────────────────┘


AI Analysis ──► Insights ──► Notifications

Contributing

Found an issue with a schema? Submit a PR to kb_catalog/schemas/ with your proposed changes.

⚠️ Schema changes may break existing integrations. Always increment the version appropriately and document changes.

On this page