> ## 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 Marginal VaR

> Calculates the rate of change in portfolio VaR for a small increase in position size. This is the derivative of VaR with respect to position weight, useful for understanding how sensitive portfolio risk is to changes in a specific position. Critical for dynamic hedging and position sizing decisions. [Tier: PRO, Credits: 5]



## OpenAPI

````yaml api-specs/risk.json post /quantlib/risk/var/marginal
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/marginal:
    post:
      tags:
        - quantlib-risk
      summary: Calculate Marginal VaR
      description: >-
        Calculates the rate of change in portfolio VaR for a small increase in
        position size. This is the derivative of VaR with respect to position
        weight, useful for understanding how sensitive portfolio risk is to
        changes in a specific position. Critical for dynamic hedging and
        position sizing decisions. [Tier: PRO, Credits: 5]
      operationId: marginal_var
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - portfolio_returns
                - new_position_returns
                - position_weight
              properties:
                portfolio_returns:
                  type: array
                  description: Historical returns of the existing portfolio
                  items:
                    type: number
                  example:
                    - 0.01
                    - -0.015
                    - 0.008
                new_position_returns:
                  type: array
                  description: Historical returns of the position being analyzed
                  items:
                    type: number
                  example:
                    - 0.02
                    - -0.025
                    - 0.012
                position_weight:
                  type: number
                  description: Current weight of the position in the portfolio
                  example: 0.1
                confidence:
                  type: number
                  example: 0.99
                  default: 0.99
            example:
              portfolio_returns:
                - 0.01
                - -0.018
                - 0.012
                - -0.006
                - 0.014
              new_position_returns:
                - 0.015
                - -0.028
                - 0.02
                - -0.01
                - 0.018
              position_weight: 0.2
              confidence: 0.95
      responses:
        '200':
          description: Successful marginal VaR calculation
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      marginal_var:
                        type: number
                        description: Marginal VaR - rate of change of portfolio VaR
                        example: 102350.5
              example:
                success: true
                data:
                  marginal_var: 102350.5
        '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

````