Skip to main content

Portfolio Analytics

SEC API provides allocator-grade portfolio analytics: factor exposure analysis, attribution, hedge construction, optimization recommendations, stress testing, and model factor analysis.

Endpoints

Portfolio Analysis

Analyze factor exposures, attribution, and hedge suggestions for any portfolio:
curl -X POST "https://api.secapi.ai/v1/portfolio/analyze" \
  -H "x-api-key: $SECAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "holdings": [
      {"symbol": "AAPL", "weight": 0.25},
      {"symbol": "MSFT", "weight": 0.25},
      {"symbol": "GOOGL", "weight": 0.20},
      {"symbol": "AMZN", "weight": 0.15},
      {"symbol": "NVDA", "weight": 0.15}
    ]
  }'
Returns: factor exposures, attribution breakdown, concentration risks, and hedge suggestions.

Portfolio Attribution

Explain portfolio return through factor contributions:
curl -X POST "https://api.secapi.ai/v1/portfolio/attribution?response_mode=compact" \
  -H "x-api-key: $SECAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "holdings": [
      {"symbol": "AAPL", "weight": 0.30},
      {"symbol": "MSFT", "weight": 0.25},
      {"symbol": "NVDA", "weight": 0.20},
      {"symbol": "JPM", "weight": 0.15},
      {"symbol": "XOM", "weight": 0.10}
    ],
    "lookback": "6m",
    "category": "style"
  }'

Portfolio Hedge

Generate constrained hedge candidates for unwanted factor exposures:
curl -X POST "https://api.secapi.ai/v1/portfolio/hedge?response_mode=compact" \
  -H "x-api-key: $SECAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "holdings": [
      {"symbol": "AAPL", "weight": 0.35},
      {"symbol": "MSFT", "weight": 0.30},
      {"symbol": "NVDA", "weight": 0.20},
      {"symbol": "JPM", "weight": 0.15}
    ],
    "objective": "factor_neutral",
    "constraints": {"maxHedges": 3, "maxPositionWeight": 0.10}
  }'

Portfolio Optimization

Generate optimization recommendations for factor neutrality, hedging, or regime-awareness:
curl -X POST "https://api.secapi.ai/v1/portfolio/optimize" \
  -H "x-api-key: $SECAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "holdings": [{"symbol": "AAPL", "weight": 0.5}, {"symbol": "MSFT", "weight": 0.5}],
    "objective": "factor_neutral",
    "maxHedges": 3
  }'

Stress Testing

Run stress scenarios against factor and macro shocks:
curl -X POST "https://api.secapi.ai/v1/portfolio/stress-test" \
  -H "x-api-key: $SECAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "holdings": [{"symbol": "AAPL", "weight": 0.5}, {"symbol": "MSFT", "weight": 0.5}],
    "scenarioKey": "us_recession"
  }'

Model Portfolio Factor View

Drill into a model portfolio’s factor profile:
curl "https://api.secapi.ai/v1/model-portfolios/{id}/factor-view" \
  -H "x-api-key: $SECAPI_API_KEY"

Model Factor Analysis

Analyze Model Builder or ad hoc model holdings without first persisting a model portfolio:
curl -X POST "https://api.secapi.ai/v1/models/factor-analysis?response_mode=compact" \
  -H "x-api-key: $SECAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": {"id": "growth-quality-core", "label": "Growth Quality Core", "source": "model_builder"},
    "holdings": [
      {"symbol": "AAPL", "weight": 0.30},
      {"symbol": "MSFT", "weight": 0.25},
      {"symbol": "NVDA", "weight": 0.20},
      {"symbol": "GOOGL", "weight": 0.15},
      {"symbol": "AMZN", "weight": 0.10}
    ],
    "include": {"attribution": true, "hedge": true, "positionViews": true}
  }'

Use Cases

Factor Neutralization

Identify and hedge unwanted factor exposures in your portfolio.

Regime-Aware Rebalancing

Adjust portfolio weights based on the current macro regime.

Risk Budgeting

Allocate risk across factors and set concentration limits.

Hedge Construction

Generate hedge overlay recommendations with cost estimates.