> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fincept.in/llms.txt
> Use this file to discover all available pages before exploring further.

# Calculate Component VaR

> Calculates the contribution of each portfolio component (asset or risk factor) to total portfolio VaR. This decomposition helps identify which positions drive portfolio risk and enables better risk budgeting decisions. Essential for risk attribution and portfolio optimization. [Tier: PRO, Credits: 5]



## OpenAPI

````yaml api-specs/risk.json post /quantlib/risk/var/component
openapi: 3.1.0
info:
  title: FinceptQuantLib API - Risk Module
  description: >-
    Professional-grade risk management endpoints including Value at Risk (VaR),
    stress testing, copulas, extreme value theory (EVT), XVA calculations,
    sensitivities, and portfolio hedging. Part of the Pro Tier (5 credits per
    request).
  version: 3.0.0
  contact:
    name: Fincept API Support
    url: https://fincept.in
    email: support@fincept.in
servers:
  - url: https://api.fincept.in
    description: Fincept API Production Server
security:
  - APIKeyHeader: []
tags:
  - name: quantlib-risk
    description: Risk Management Module - Pro Tier (5 credits/request)
    x-displayName: Risk
paths:
  /quantlib/risk/var/component:
    post:
      tags:
        - quantlib-risk
      summary: Calculate Component VaR
      description: >-
        Calculates the contribution of each portfolio component (asset or risk
        factor) to total portfolio VaR. This decomposition helps identify which
        positions drive portfolio risk and enables better risk budgeting
        decisions. Essential for risk attribution and portfolio optimization.
        [Tier: PRO, Credits: 5]
      operationId: component_var
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - returns_by_factor
                - weights
              properties:
                returns_by_factor:
                  type: object
                  description: >-
                    Dictionary mapping factor/asset names to their historical
                    return arrays
                  additionalProperties:
                    type: array
                    items:
                      type: number
                  example:
                    equities:
                      - 0.01
                      - -0.02
                      - 0.015
                    bonds:
                      - 0.005
                      - -0.003
                      - 0.004
                weights:
                  type: object
                  description: Portfolio weights for each factor (must sum to 1.0)
                  additionalProperties:
                    type: number
                  example:
                    equities: 0.6
                    bonds: 0.4
                confidence:
                  type: number
                  description: Confidence level for VaR calculation
                  example: 0.99
                  default: 0.99
                portfolio_value:
                  type: number
                  description: Total portfolio value
                  example: 1000000
                  default: 1000000
            example:
              returns_by_factor:
                US_equities:
                  - 0.012
                  - -0.018
                  - 0.025
                  - -0.008
                  - 0.015
                EU_bonds:
                  - 0.003
                  - -0.002
                  - 0.004
                  - -0.001
                  - 0.002
                commodities:
                  - 0.02
                  - -0.03
                  - 0.015
                  - -0.012
                  - 0.018
              weights:
                US_equities: 0.5
                EU_bonds: 0.3
                commodities: 0.2
              confidence: 0.95
              portfolio_value: 10000000
      responses:
        '200':
          description: Successful component VaR calculation
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    description: Component VaR for each factor
                    additionalProperties:
                      type: number
                    example:
                      US_equities: 125000
                      EU_bonds: 35000
                      commodities: 78000
              example:
                success: true
                data:
                  US_equities: 125000
                  EU_bonds: 35000
                  commodities: 78000
                  total_var: 238000
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '402':
          $ref: '#/components/responses/InsufficientCreditsError'
        '422':
          $ref: '#/components/responses/ValidationError'
components:
  responses:
    UnauthorizedError:
      description: Authentication information is missing or invalid
      content:
        application/json:
          schema:
            type: object
            properties:
              detail:
                type: string
                example: Invalid API key
    InsufficientCreditsError:
      description: Insufficient API credits for this request
      content:
        application/json:
          schema:
            type: object
            properties:
              detail:
                type: string
                example: Insufficient credits. This endpoint requires 5 credits.
    ValidationError:
      description: Request validation error
      content:
        application/json:
          schema:
            type: object
            properties:
              detail:
                type: array
                items:
                  type: object
                  properties:
                    loc:
                      type: array
                      items:
                        type: string
                    msg:
                      type: string
                    type:
                      type: string
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: X-API-Key
      description: >-
        API key for authentication. Get your key at
        https://api.fincept.in/auth/register

````