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

# Get compression history for a stock

> Get historical volatility compression events for a stock.

## Response Data

Returns daily compression snapshots including:
- ATR compression ratio (ATR3/ATR14)
- Bollinger Band width percentile
- NR7 and Inside Day signals
- VCP contraction count
- Composite compression score (0-100)
- AN-01 `detailed_vcp`: versioned legs/pivots/levels when a detector provider supplies them,
  otherwise an explicit `unavailable` object. Summary counts never synthesize geometry.

## Compression Score Calculation

Aligned with confluence_scorer.go volatility_setup:
- VCP Pattern (+4 points): ATR ratio < 0.50 AND contractions >= 2
- NR7 (+3 points): Narrowest range in 7 days
- BB Squeeze (+3 points): BB width percentile < 20

Max 10 points, scaled to 0-100.

## Query Parameters

- **days**: Number of days to look back (default: 30, max: 365)

## Performance Target

<300ms response time.



## OpenAPI

````yaml /api/openapi.json get /api/graph/v1/stocks/{symbol}/compression
openapi: 3.1.0
info:
  title: Sequency Graph API
  description: >

    # Sequency Graph-Native Trading API


    Graph-native API for trading intelligence, built on FalkorDB.


    ## Features


    - **Screener**: Filter stocks using graph-native queries with relationship
    expansion

    - **Stock Detail**: Complete stock context with all relationships

    - **Confluence Scoring**: Setup quality assessment with weighted components

    - **Strategy Matching**: Find matching options strategies via graph
    traversal

    - **Market Context**: Current market-wide context for trading decisions


    ## Data Sources


    All data is sourced from the FalkorDB knowledge graph, populated by:

    - Pattern detector (Go) - Technical indicators, patterns

    - Graph sync service - Levels, volume profiles, news, day classification
  version: 1.0.0
servers: []
security: []
paths:
  /api/graph/v1/stocks/{symbol}/compression:
    get:
      tags:
        - Compression
      summary: Get compression history for a stock
      description: >-
        Get historical volatility compression events for a stock.


        ## Response Data


        Returns daily compression snapshots including:

        - ATR compression ratio (ATR3/ATR14)

        - Bollinger Band width percentile

        - NR7 and Inside Day signals

        - VCP contraction count

        - Composite compression score (0-100)

        - AN-01 `detailed_vcp`: versioned legs/pivots/levels when a detector
        provider supplies them,
          otherwise an explicit `unavailable` object. Summary counts never synthesize geometry.

        ## Compression Score Calculation


        Aligned with confluence_scorer.go volatility_setup:

        - VCP Pattern (+4 points): ATR ratio < 0.50 AND contractions >= 2

        - NR7 (+3 points): Narrowest range in 7 days

        - BB Squeeze (+3 points): BB width percentile < 20


        Max 10 points, scaled to 0-100.


        ## Query Parameters


        - **days**: Number of days to look back (default: 30, max: 365)


        ## Performance Target


        <300ms response time.
      operationId: get_compression_history_api_graph_v1_stocks__symbol__compression_get
      parameters:
        - name: symbol
          in: path
          required: true
          schema:
            type: string
            title: Symbol
        - name: days
          in: query
          required: false
          schema:
            type: integer
            maximum: 365
            minimum: 1
            title: Days
            description: Lookback period in days
            default: 30
          description: Lookback period in days
      responses:
        '200':
          description: Compression history with events and stats
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CompressionHistoryResponse'
        '404':
          description: Stock not found
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '504':
          description: Query timeout
components:
  schemas:
    CompressionHistoryResponse:
      properties:
        symbol:
          type: string
          title: Symbol
          description: Stock ticker symbol
        events:
          items:
            $ref: '#/components/schemas/CompressionEvent'
          type: array
          title: Events
          description: Historical compression events (newest first)
        stats:
          $ref: '#/components/schemas/CompressionStats'
          description: Aggregated statistics for the period
        detailed_vcp:
          $ref: '#/components/schemas/DetailedVCPPattern'
          description: AN-01 typed detector detail or explicit unavailable state
      type: object
      required:
        - symbol
        - stats
        - detailed_vcp
      title: CompressionHistoryResponse
      description: Response for compression history endpoint.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    CompressionEvent:
      properties:
        symbol:
          type: string
          title: Symbol
          description: Stock ticker symbol
        trade_date:
          type: string
          format: date
          title: Trade Date
          description: Trade date (YYYY-MM-DD)
        atr_3:
          anyOf:
            - type: number
            - type: 'null'
          title: Atr 3
          description: 3-period ATR
        atr_14:
          anyOf:
            - type: number
            - type: 'null'
          title: Atr 14
          description: 14-period ATR (reference)
        atr_compression_ratio:
          anyOf:
            - type: number
            - type: 'null'
          title: Atr Compression Ratio
          description: 'Legacy: ATR(3) / ATR(14). Prefer range_vs_atr_14.'
        range_vs_atr_14:
          anyOf:
            - type: number
            - type: 'null'
          title: Range Vs Atr 14
          description: Today's range / daily ATR(14) — replaces atr_compression_ratio
        bb_width:
          anyOf:
            - type: number
            - type: 'null'
          title: Bb Width
          description: (BB_Upper - BB_Lower) / BB_Middle * 100
        bb_width_percentile:
          anyOf:
            - type: number
              maximum: 100
              minimum: 0
            - type: 'null'
          title: Bb Width Percentile
          description: BB width percentile vs trailing 20 days (0-100)
        daily_range:
          anyOf:
            - type: number
            - type: 'null'
          title: Daily Range
          description: High - Low for the day
        range_to_atr:
          anyOf:
            - type: number
            - type: 'null'
          title: Range To Atr
          description: Today's range / ATR(14)
        is_nr7:
          type: boolean
          title: Is Nr7
          description: Narrowest range in 7 days
          default: false
        is_inside_day:
          type: boolean
          title: Is Inside Day
          description: Range inside yesterday's range
          default: false
        vcp_contraction_count:
          type: integer
          title: Vcp Contraction Count
          description: Number of tightening pivots (2-4 ideal per Minervini)
          default: 0
        compression_score:
          anyOf:
            - type: number
              maximum: 100
              minimum: 0
            - type: 'null'
          title: Compression Score
          description: >-
            Composite score 0-100 (VCP: +4, NR7: +3, BB Squeeze: +3, max 10
            scaled to 100)
        compression_level:
          anyOf:
            - $ref: '#/components/schemas/CompressionLevel'
            - type: 'null'
          description: >-
            Classification: extreme (>=80), high (60-79), moderate (40-59), low
            (20-39), none (<20)
        close_price:
          anyOf:
            - type: number
            - type: 'null'
          title: Close Price
          description: Closing price
        volume:
          anyOf:
            - type: integer
            - type: 'null'
          title: Volume
          description: Daily volume
        relative_volume:
          anyOf:
            - type: number
            - type: 'null'
          title: Relative Volume
          description: RVOL (volume vs 20-day avg)
        computed_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Computed At
          description: When this event was computed
      type: object
      required:
        - symbol
        - trade_date
      title: CompressionEvent
      description: |-
        Daily volatility compression snapshot for a stock.

        Stored in TimescaleDB with 1-year retention.
        Graph storage (FalkorDB) retains 90 days.
    CompressionStats:
      properties:
        symbol:
          type: string
          title: Symbol
          description: Stock ticker symbol
        period_days:
          type: integer
          title: Period Days
          description: Number of days analyzed
        nr7_count:
          type: integer
          title: Nr7 Count
          description: Number of NR7 days in period
          default: 0
        inside_day_count:
          type: integer
          title: Inside Day Count
          description: Number of inside days in period
          default: 0
        total_events:
          type: integer
          title: Total Events
          description: Total compression events in period
          default: 0
        avg_compression_ratio:
          anyOf:
            - type: number
            - type: 'null'
          title: Avg Compression Ratio
          description: Average ATR compression ratio over period
        min_compression_ratio:
          anyOf:
            - type: number
            - type: 'null'
          title: Min Compression Ratio
          description: Minimum (most compressed) ratio
        max_compression_ratio:
          anyOf:
            - type: number
            - type: 'null'
          title: Max Compression Ratio
          description: Maximum (least compressed) ratio
        avg_compression_score:
          anyOf:
            - type: number
            - type: 'null'
          title: Avg Compression Score
          description: Average composite compression score
        trend_direction:
          type: string
          enum:
            - compressing
            - expanding
            - stable
          title: Trend Direction
          description: Volatility trend based on recent vs earlier period comparison
          default: stable
      type: object
      required:
        - symbol
        - period_days
      title: CompressionStats
      description: Aggregated compression statistics for a symbol over a period.
    DetailedVCPPattern:
      properties:
        schema_version:
          type: string
          const: an01-v1
          title: Schema Version
        detector_version:
          type: string
          minLength: 1
          title: Detector Version
        producer:
          $ref: '#/components/schemas/VCPProducer'
        symbol:
          type: string
          minLength: 1
          pattern: ^[A-Z][A-Z0-9.-]*$
          title: Symbol
        interval:
          type: string
          const: 1d
          title: Interval
        market_session:
          type: string
          const: regular
          title: Market Session
        computed_at:
          type: string
          format: date-time
          title: Computed At
        finality:
          type: string
          enum:
            - finalized
            - provisional
          title: Finality
        status:
          type: string
          enum:
            - complete
            - partial
            - unavailable
          title: Status
        confidence:
          anyOf:
            - type: number
              maximum: 1
              minimum: 0
            - type: 'null'
          title: Confidence
        legs:
          items:
            $ref: '#/components/schemas/VCPContractionLeg'
          type: array
          title: Legs
        breakout:
          anyOf:
            - $ref: '#/components/schemas/VCPObservedLevel'
            - type: 'null'
        invalidation:
          anyOf:
            - $ref: '#/components/schemas/VCPObservedLevel'
            - type: 'null'
        evidence:
          items:
            $ref: '#/components/schemas/VCPEvidence'
          type: array
          title: Evidence
        missing_fields:
          items:
            type: string
          type: array
          title: Missing Fields
        unavailable_reason:
          anyOf:
            - $ref: '#/components/schemas/VCPUnavailableReason'
            - type: 'null'
      additionalProperties: false
      type: object
      required:
        - schema_version
        - detector_version
        - producer
        - symbol
        - interval
        - market_session
        - computed_at
        - finality
        - status
      title: DetailedVCPPattern
      description: >-
        Versioned, evidence-bound detailed VCP result for the stock compression
        route.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    CompressionLevel:
      type: string
      enum:
        - extreme
        - high
        - moderate
        - low
        - none
      title: CompressionLevel
      description: |-
        Compression level classification based on composite score.

        Score thresholds (aligned with confluence_scorer.go):
        - extreme: >= 80
        - high: 60-79
        - moderate: 40-59
        - low: 20-39
        - none: < 20
    VCPProducer:
      properties:
        id:
          type: string
          const: pattern-detector:vcp
          title: Id
        kind:
          type: string
          const: deterministic
          title: Kind
        version:
          type: string
          minLength: 1
          title: Version
      additionalProperties: false
      type: object
      required:
        - id
        - kind
        - version
      title: VCPProducer
    VCPContractionLeg:
      properties:
        id:
          type: string
          minLength: 1
          title: Id
        ordinal:
          type: integer
          minimum: 1
          title: Ordinal
        start_pivot:
          $ref: '#/components/schemas/VCPPivot'
        end_pivot:
          anyOf:
            - $ref: '#/components/schemas/VCPPivot'
            - type: 'null'
        range:
          anyOf:
            - type: number
              exclusiveMinimum: 0
            - type: 'null'
          title: Range
        contraction_ratio:
          anyOf:
            - type: number
              maximum: 1
              exclusiveMinimum: 0
            - type: 'null'
          title: Contraction Ratio
        volume:
          anyOf:
            - $ref: '#/components/schemas/VCPVolumeBehavior'
            - type: 'null'
        missing_fields:
          items:
            type: string
            enum:
              - end_pivot
              - range
              - contraction_ratio
              - volume
          type: array
          title: Missing Fields
      additionalProperties: false
      type: object
      required:
        - id
        - ordinal
        - start_pivot
        - end_pivot
        - volume
      title: VCPContractionLeg
    VCPObservedLevel:
      properties:
        id:
          type: string
          minLength: 1
          title: Id
        kind:
          type: string
          enum:
            - breakout
            - invalidation
          title: Kind
        price:
          type: number
          exclusiveMinimum: 0
          title: Price
        pivot_id:
          type: string
          minLength: 1
          title: Pivot Id
        evidence_id:
          type: string
          minLength: 1
          title: Evidence Id
      additionalProperties: false
      type: object
      required:
        - id
        - kind
        - price
        - pivot_id
        - evidence_id
      title: VCPObservedLevel
    VCPEvidence:
      properties:
        id:
          type: string
          minLength: 1
          title: Id
        kind:
          type: string
          const: source_bar
          title: Kind
        time:
          type: string
          format: date-time
          title: Time
        source_revision:
          type: integer
          minimum: 1
          title: Source Revision
        pivot_id:
          type: string
          minLength: 1
          title: Pivot Id
      additionalProperties: false
      type: object
      required:
        - id
        - kind
        - time
        - source_revision
        - pivot_id
      title: VCPEvidence
    VCPUnavailableReason:
      properties:
        code:
          type: string
          enum:
            - detail_not_persisted
            - detector_no_result
            - detector_error
            - invalid_detector_payload
          title: Code
        message:
          type: string
          minLength: 1
          title: Message
      additionalProperties: false
      type: object
      required:
        - code
        - message
      title: VCPUnavailableReason
    VCPPivot:
      properties:
        id:
          type: string
          minLength: 1
          title: Id
        role:
          type: string
          enum:
            - high
            - low
          title: Role
        time:
          type: string
          format: date-time
          title: Time
        price:
          type: number
          exclusiveMinimum: 0
          title: Price
        source_revision:
          type: integer
          minimum: 1
          title: Source Revision
        evidence_id:
          type: string
          minLength: 1
          title: Evidence Id
      additionalProperties: false
      type: object
      required:
        - id
        - role
        - time
        - price
        - source_revision
        - evidence_id
      title: VCPPivot
    VCPVolumeBehavior:
      properties:
        ratio:
          type: number
          minimum: 0
          title: Ratio
        behavior:
          type: string
          enum:
            - dry_up
            - flat
            - expanding
          title: Behavior
      additionalProperties: false
      type: object
      required:
        - ratio
        - behavior
      title: VCPVolumeBehavior

````