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

# Peers Analysis

> Generate an AI-powered peer comparison analysis for a stock. Compares the company against its sector peers on valuation, performance, and fundamentals. This endpoint uses async job processing.

Generate an AI-powered peer comparison analysis for a stock. Compares the company against its sector peers on valuation, performance, and fundamentals.

## How It Works

This endpoint uses **async job processing**:

1. **Submit Request**: POST with a stock symbol
2. **Receive Job ID**: Get a job ID and polling URL immediately
3. **Poll for Status**: Check `/v1/jobs/{job_id}` until status is `completed`
4. **Get Analysis**: The completed job contains a narrative peer comparison

<Note>
  Analysis typically takes 30-60 seconds.
</Note>

## Query Parameters

| Parameter | Type   | Required | Description                         |
| --------- | ------ | -------- | ----------------------------------- |
| `symbol`  | string | Yes      | Stock symbol (e.g., `AAPL`, `MSFT`) |

## Response (202 Accepted)

```json theme={null}
{
  "job_id": "stock-66afc3d6-0409-4aa5-bb2d-be34e38efadb",
  "status": "pending",
  "symbol": "AAPL.O",
  "check_url": "/v1/jobs/stock-66afc3d6-0409-4aa5-bb2d-be34e38efadb",
  "estimated_duration_seconds": 60,
  "message": "Peers analysis started for AAPL.O."
}
```

## Completed Response

When the job completes, `GET /v1/jobs/{job_id}` returns:

```json theme={null}
{
  "job_id": "stock-66afc3d6-...",
  "status": "completed",
  "result": {
    "symbol": "AAPL.O",
    "analysis": "Apple trades at a premium 32x PE multiple while generating an exceptional 171% ROE that dwarfs every peer except Ubiquiti's niche operation, yet the stock sits down 6% year-to-date as investors question growth sustainability in a maturing smartphone market. The company's $3.7 trillion market cap represents more than half the combined value of all technology hardware peers, supported by an EV/EBITDA of 24.6x that reflects consistent cash generation but signals limited upside at current valuations. While competitors like Western Digital surge 44% and Dell climbs 28% on AI infrastructure plays, Apple's ecosystem moat and services expansion provide defensive qualities that justify the valuation premium, though the current Hold consensus suggests analysts see limited catalysts for near-term outperformance."
  }
}
```

## Result Fields

| Field      | Description                                                                                                                         |
| ---------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| `symbol`   | Resolved RIC                                                                                                                        |
| `analysis` | AI-generated narrative comparing the stock against its sector peers on valuation, performance, returns, and competitive positioning |

## Example

```bash theme={null}
curl -X POST "https://api.chicago.global/v1/peers-analysis?symbol=AAPL" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

```javascript theme={null}
const response = await fetch(
  'https://api.chicago.global/v1/peers-analysis?symbol=AAPL',
  {
    method: 'POST',
    headers: { 'Authorization': `Bearer ${API_KEY}` }
  }
);

const { job_id, check_url } = await response.json();

const interval = setInterval(async () => {
  const status = await fetch(
    `https://api.chicago.global${check_url}`,
    { headers: { 'Authorization': `Bearer ${API_KEY}` } }
  ).then(r => r.json());

  if (status.status === 'completed') {
    clearInterval(interval);
    console.log(status.result.analysis);
  } else if (status.status === 'failed') {
    clearInterval(interval);
    console.error('Failed:', status.error);
  }
}, 5000);
```


## OpenAPI

````yaml POST /v1/peers-analysis
openapi: 3.1.0
info:
  title: Parallax API
  description: >-
    Financial data and portfolio analytics API. Analyze portfolios with
    multi-currency support, rebalancing, and comprehensive metrics.
  version: 1.0.0
servers:
  - url: https://api.chicago.global
security:
  - bearerAuth: []
paths:
  /v1/peers-analysis:
    post:
      tags:
        - Analysis
      summary: Peers Analysis
      description: >-
        Generate an AI-powered peer comparison analysis for a stock. Compares
        the company against its sector peers on valuation, performance, and
        fundamentals. This endpoint uses async job processing.
      operationId: peersAnalysis
      parameters:
        - name: symbol
          in: query
          required: true
          description: Stock symbol (e.g., AAPL, MSFT)
          schema:
            type: string
          example: AAPL
      responses:
        '202':
          description: Job created successfully. Poll the check_url for results.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnalysisJobResponse'
              example:
                job_id: stock-66afc3d6-0409-4aa5-bb2d-be34e38efadb
                status: pending
                symbol: AAPL.O
                check_url: /v1/jobs/stock-66afc3d6-0409-4aa5-bb2d-be34e38efadb
                estimated_duration_seconds: 60
                message: Peers analysis started for AAPL.O.
        '401':
          description: Unauthorized - Invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    AnalysisJobResponse:
      type: object
      properties:
        job_id:
          type: string
          description: Unique job identifier
        status:
          type: string
          enum:
            - pending
          description: Initial job status
        symbol:
          type: string
          description: Stock symbol being analyzed
        check_url:
          type: string
          description: URL to poll for job status
        estimated_duration_seconds:
          type: integer
          description: Estimated processing time in seconds
        message:
          type: string
          description: Human-readable status message
    Error:
      type: object
      properties:
        detail:
          type: string
          description: Error message
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: API key passed as Bearer token

````