> ## 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.

# Exchange Economy Analysis

> Analyze a 2-consumer, 2-good pure exchange economy. Computes aggregate endowments, excess demand at given prices, and verifies Walras's Law (that the value of excess demand is zero). Essential for understanding general equilibrium theory, Pareto efficiency, and the core of an economy. Use before finding equilibrium to analyze market conditions. [Tier: STANDARD, Credits: 2]



## OpenAPI

````yaml api-specs/economics.json post /quantlib/economics/equilibrium/exchange-economy
openapi: 3.1.0
info:
  title: FinceptQuantLib API - Economics
  description: >-
    Economics module endpoints for FinceptQuantLib API - general equilibrium,
    game theory, auctions, and utility functions
  version: 3.0.0
  contact:
    name: Fincept API Support
    url: https://fincept.in
servers:
  - url: https://api.fincept.in
    description: Fincept API Production Server
security:
  - APIKeyHeader: []
tags:
  - name: quantlib-economics
    description: >-
      Economics module - general equilibrium, game theory, auctions, and utility
      theory
    x-displayName: Economics
paths:
  /quantlib/economics/equilibrium/exchange-economy:
    post:
      tags:
        - quantlib-economics
      summary: Exchange Economy Analysis
      description: >-
        Analyze a 2-consumer, 2-good pure exchange economy. Computes aggregate
        endowments, excess demand at given prices, and verifies Walras's Law
        (that the value of excess demand is zero). Essential for understanding
        general equilibrium theory, Pareto efficiency, and the core of an
        economy. Use before finding equilibrium to analyze market conditions.
        [Tier: STANDARD, Credits: 2]
      operationId: exchange_economy_quantlib_economics_equilibrium_exchange_economy_post
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - endowments
                - alphas
              properties:
                endowments:
                  type: array
                  description: >-
                    Initial endowments for each consumer [[e1_good1, e1_good2],
                    [e2_good1, e2_good2]]
                  items:
                    type: array
                    items:
                      type: number
                      minimum: 0
                    minItems: 2
                    maxItems: 2
                  minItems: 2
                  maxItems: 2
                  example:
                    - - 10
                      - 5
                    - - 5
                      - 10
                alphas:
                  type: array
                  description: >-
                    Cobb-Douglas preference parameters for each consumer
                    [alpha1, alpha2]
                  items:
                    type: number
                    minimum: 0
                    maximum: 1
                  minItems: 2
                  maxItems: 2
                  example:
                    - 0.6
                    - 0.4
                prices:
                  type: array
                  description: >-
                    Prices to evaluate excess demand at [p1, p2]. If null, uses
                    [1.0, 1.0]
                  items:
                    type: number
                    minimum: 0
                  minItems: 2
                  maxItems: 2
                  example:
                    - 1
                    - 1
                  nullable: true
            example:
              endowments:
                - - 10
                  - 5
                - - 5
                  - 10
              alphas:
                - 0.6
                - 0.4
              prices:
                - 1
                - 1
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      aggregate_endowment:
                        type: array
                        description: >-
                          Total endowment in the economy [total_good1,
                          total_good2]
                        items:
                          type: number
                        example:
                          - 15
                          - 15
                      excess_demand:
                        type: array
                        description: >-
                          Excess demand at given prices [z1, z2]. Positive =
                          excess demand, negative = excess supply
                        items:
                          type: number
                        example:
                          - 3
                          - -3
                      walras_law_check:
                        type: number
                        description: >-
                          Value of excess demand (should be near zero by
                          Walras's Law: p·z = 0)
                        example: 0
                      prices_used:
                        type: array
                        description: Prices used for calculation
                        items:
                          type: number
                        example:
                          - 1
                          - 1
              example:
                success: true
                data:
                  aggregate_endowment:
                    - 15
                    - 15
                  excess_demand:
                    - 3
                    - -3
                  walras_law_check: 0
                  prices_used:
                    - 1
                    - 1
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '402':
          $ref: '#/components/responses/InsufficientTierError'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: array
                    items:
                      type: object
              example:
                detail:
                  - loc:
                      - body
                      - endowments
                    msg: field required
                    type: value_error.missing
      security:
        - APIKeyHeader: []
components:
  responses:
    UnauthorizedError:
      description: Authentication information is missing or invalid
      content:
        application/json:
          schema:
            type: object
            properties:
              detail:
                type: string
                example: Invalid API key
    InsufficientTierError:
      description: API tier insufficient for this endpoint
      content:
        application/json:
          schema:
            type: object
            properties:
              detail:
                type: string
                example: Endpoint requires Basic tier or higher
  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

````