# GENERATED by release/make_public_openapi.py from docs/openapi.yaml: edit that file, then re-run.
openapi: 3.1.0
info:
  title: Option Valley hosted evaluation API
  version: 1.0.0
  summary: Option Valley, powered by Riptide. Exact implied volatility, Greeks to any order, American exercise and
    SVI surfaces over HTTPS, for evaluation and small volumes.
  description: 'Invite-only. Every request needs an API key in the `x-api-key` header (issued per customer; ask

    samario@riptidecompute.com or your Riptide contact). Production workloads run the self-hosted library on your
    own

    machines (see the quick start); the hosted API is for evaluation and small volumes.


    **Data you may send.** Your key was issued against a data attestation: delayed, end-of-day or synthetic inputs,

    or real-time OPRA-derived quotes only with OPRA''s approval reference on file. Riptide supplies no market data.


    **Privacy.** Request and response bodies are never logged or stored. The only record kept is the metering per

    key and UTC day (request count, quote count, compute milliseconds). Errors are logged as a type and a route,

    never with inputs.


    **Arrays.** POST bodies are JSON objects of equal-length numeric arrays; a scalar is broadcast to the common

    length. Non-finite results (NaN: no volatility reproduces the price) are returned as `null`.


    **Certificates.** Any POST accepts `"certificate": true`; the response then carries a signed reproducibility

    certificate (hosted certificate key) covering exactly that computation. Verify it with

    `python -m optionvalley.verify` (see certificates.html).


    **Limits.** Evaluation keys: 10 requests/s (burst 20), 100,000 requests per month. Small-volume keys: 40

    requests/s (burst 80), 2,000,000 requests per month. Every key: at most 100,000 quotes per request and

    20,000,000 quotes per UTC day; per-route caps are listed below. A WAF limits each IP to 1,000 requests per

    5 minutes and applies AWS managed rule sets. Over a limit: HTTP 429.

    '
  contact:
    name: Option Valley support
    email: samario@riptidecompute.com
  license:
    name: Proprietary. Use under the Option Valley evaluation agreement or licence.
servers:
- url: https://{apiId}.execute-api.us-east-1.amazonaws.com/live
  description: Live stage (the API id is sent with your key)
  variables:
    apiId:
      default: your-api-id
security:
- apiKey: []
tags:
- name: implied volatility
- name: pricing
- name: greeks
- name: surfaces
- name: account
paths:
  /v1/iv/european:
    post:
      tags:
      - implied volatility
      summary: European (Black) implied volatility on the forward
      description: price is the undiscounted option price on the forward (market price divided by the discount factor).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
              - $ref: '#/components/schemas/Common'
              - type: object
                required:
                - price
                - F
                - K
                - T
                - is_call
                properties:
                  price:
                    $ref: '#/components/schemas/Numbers'
                  F:
                    $ref: '#/components/schemas/Numbers'
                  K:
                    $ref: '#/components/schemas/Numbers'
                  T:
                    $ref: '#/components/schemas/Numbers'
                  is_call:
                    $ref: '#/components/schemas/Flags'
                  greeks:
                    type: boolean
                    default: false
                    description: delta, gamma, vega, volga, vanna, dV_dT of the undiscounted Black price
            example:
              price:
              - 10.45
              - 5.57
              F: 100
              K:
              - 100
              - 110
              T: 0.5
              is_call: 1
              greeks: true
      responses:
        '200':
          $ref: '#/components/responses/Sigma'
        '400':
          $ref: '#/components/responses/Error'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/Limited'
  /v1/iv/european/spot:
    post:
      tags:
      - implied volatility
      summary: European implied volatility from spot inputs
      description: F = S e^{(r - q) T}, D = e^{-rT} computed by the engine; r and q continuously compounded.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
              - $ref: '#/components/schemas/Common'
              - $ref: '#/components/schemas/SpotQuote'
              - type: object
                properties:
                  greeks:
                    type: boolean
                    default: false
      responses:
        '200':
          $ref: '#/components/responses/Sigma'
        '400':
          $ref: '#/components/responses/Error'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/Limited'
  /v1/iv/american:
    post:
      tags:
      - implied volatility
      summary: American implied volatility (at most 20,000 quotes per request)
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
              - $ref: '#/components/schemas/Common'
              - $ref: '#/components/schemas/SpotQuote'
              - $ref: '#/components/schemas/AmericanOptions'
              - type: object
                properties:
                  greeks:
                    type: boolean
                    default: false
                    description: vega, volga, ultima at the solution
      responses:
        '200':
          $ref: '#/components/responses/Sigma'
        '400':
          $ref: '#/components/responses/Error'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/Limited'
  /v1/price/american:
    post:
      tags:
      - pricing
      summary: American prices (at most 50,000 per request)
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
              - $ref: '#/components/schemas/Common'
              - $ref: '#/components/schemas/AmericanOptions'
              - type: object
                required:
                - S
                - K
                - T
                - r
                - q
                - sigma
                - is_call
                properties:
                  S:
                    $ref: '#/components/schemas/Numbers'
                  K:
                    $ref: '#/components/schemas/Numbers'
                  T:
                    $ref: '#/components/schemas/Numbers'
                  r:
                    $ref: '#/components/schemas/Numbers'
                  q:
                    $ref: '#/components/schemas/Numbers'
                  sigma:
                    $ref: '#/components/schemas/Numbers'
                  is_call:
                    $ref: '#/components/schemas/Flags'
                  greeks:
                    type: boolean
                    default: false
                    description: vega, volga
      responses:
        '200':
          description: Prices
          content:
            application/json:
              schema:
                allOf:
                - $ref: '#/components/schemas/Meta'
                - type: object
                  properties:
                    price:
                      $ref: '#/components/schemas/NullableNumbers'
                    greeks:
                      type: object
                      additionalProperties:
                        $ref: '#/components/schemas/NullableNumbers'
        '400':
          $ref: '#/components/responses/Error'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/Limited'
  /v1/greeks/european:
    post:
      tags:
      - greeks
      summary: Every partial derivative of the Black-Scholes price up to a total order
      description: Variables in order S, sigma, T, r, q, K; nvars differentiates in the first nvars of them. n x
        C(nvars + order, order) must stay at or under 5,000,000.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
              - $ref: '#/components/schemas/Common'
              - $ref: '#/components/schemas/Contract'
              - type: object
                properties:
                  nvars:
                    type: integer
                    minimum: 1
                    maximum: 6
                    default: 5
                  order:
                    type: integer
                    minimum: 0
                    maximum: 8
                    default: 2
      responses:
        '200':
          description: Derivatives, option-major; derivatives[i][m] is the derivative for monomial m
          content:
            application/json:
              schema:
                allOf:
                - $ref: '#/components/schemas/Meta'
                - type: object
                  properties:
                    variables:
                      type: array
                      items:
                        type: string
                    monomials:
                      type: array
                      items:
                        type: array
                        items:
                          type: integer
                    derivatives:
                      type: array
                      items:
                        $ref: '#/components/schemas/NullableNumbers'
        '400':
          $ref: '#/components/responses/Error'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/Limited'
  /v1/greeks/named:
    post:
      tags:
      - greeks
      summary: The named Greek set (European 20, American 17; at most 5,000 American per request)
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
              - $ref: '#/components/schemas/Common'
              - $ref: '#/components/schemas/Contract'
              - type: object
                properties:
                  american:
                    type: boolean
                    default: false
                    description: 'true: kind is is_call (1 call, 0 put)'
                  accuracy:
                    type: string
                    enum:
                    - accurate
                    - fast
                    - high
                    default: accurate
      responses:
        '200':
          description: Greeks by name (calendar-time decays for theta, charm, veta, color)
          content:
            application/json:
              schema:
                allOf:
                - $ref: '#/components/schemas/Meta'
                - type: object
                  properties:
                    american:
                      type: boolean
                    greeks:
                      type: object
                      additionalProperties:
                        $ref: '#/components/schemas/NullableNumbers'
        '400':
          $ref: '#/components/responses/Error'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/Limited'
  /v1/surface/svi:
    post:
      tags:
      - surfaces
      summary: Raw SVI fits per expiry, with a calendar-arbitrage check
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
              - $ref: '#/components/schemas/Common'
              - type: object
                required:
                - expiries
                properties:
                  expiries:
                    type: array
                    minItems: 1
                    maxItems: 500
                    items:
                      type: object
                      required:
                      - k
                      - iv
                      - T
                      properties:
                        k:
                          $ref: '#/components/schemas/NumberArray'
                          description: log-moneyness ln(K/F)
                        iv:
                          $ref: '#/components/schemas/NumberArray'
                        T:
                          type: number
                        weights:
                          $ref: '#/components/schemas/NumberArray'
      responses:
        '200':
          description: One fit per expiry, in request order
          content:
            application/json:
              schema:
                allOf:
                - $ref: '#/components/schemas/Meta'
                - type: object
                  properties:
                    fits:
                      type: array
                      items:
                        type: object
                        properties:
                          a:
                            type:
                            - number
                            - 'null'
                          b:
                            type:
                            - number
                            - 'null'
                          rho:
                            type:
                            - number
                            - 'null'
                          m:
                            type:
                            - number
                            - 'null'
                          s:
                            type:
                            - number
                            - 'null'
                          rmse:
                            type:
                            - number
                            - 'null'
                            description: weighted RMSE in implied volatility
                          min_g:
                            type:
                            - number
                            - 'null'
                            description: smallest Gatheral g(k); < 0 = butterfly arbitrage
                          evals:
                            type: integer
                          status:
                            type: integer
                            description: 0 converged, 1 iteration limit, -1 too few points
                    calendar_violations_on_grid:
                      type: integer
        '400':
          $ref: '#/components/responses/Error'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/Limited'
  /v1/usage:
    get:
      tags:
      - account
      summary: This key's metering for the last 31 days
      responses:
        '200':
          description: Usage per UTC day
          content:
            application/json:
              schema:
                type: object
                properties:
                  days:
                    type: array
                    items:
                      type: object
                      properties:
                        day:
                          type: string
                          format: date
                        requests:
                          type: integer
                        quotes:
                          type: integer
                        compute_ms:
                          type: integer
                  daily_quote_cap:
                    type: integer
                  max_quotes_per_request:
                    type: integer
        '403':
          $ref: '#/components/responses/Forbidden'
  /v1/health:
    get:
      tags:
      - account
      summary: Version and CPU path of the serving engine
      responses:
        '200':
          description: Health
          content:
            application/json:
              schema:
                type: object
                properties:
                  product:
                    type: string
                  version:
                    type: string
                  cpu_path:
                    type: string
                  threads:
                    type: integer
        '403':
          $ref: '#/components/responses/Forbidden'
components:
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: x-api-key
  schemas:
    NumberArray:
      type: array
      items:
        type: number
    Numbers:
      description: A number (broadcast) or an array of numbers; all arrays in a request have one length (at most
        100,000)
      oneOf:
      - type: number
      - type: array
        items:
          type: number
        maxItems: 100000
    Flags:
      description: 1 call, 0 put (a number or an array)
      oneOf:
      - type: integer
        enum:
        - 0
        - 1
      - type: array
        items:
          type: integer
          enum:
          - 0
          - 1
    NullableNumbers:
      type: array
      items:
        type:
        - number
        - 'null'
    Common:
      type: object
      properties:
        certificate:
          type: boolean
          default: false
          description: return a signed reproducibility certificate
    SpotQuote:
      type: object
      required:
      - price
      - S
      - K
      - T
      - r
      - q
      - is_call
      properties:
        price:
          $ref: '#/components/schemas/Numbers'
        S:
          $ref: '#/components/schemas/Numbers'
        K:
          $ref: '#/components/schemas/Numbers'
        T:
          $ref: '#/components/schemas/Numbers'
        r:
          $ref: '#/components/schemas/Numbers'
        q:
          $ref: '#/components/schemas/Numbers'
        is_call:
          $ref: '#/components/schemas/Flags'
    Contract:
      type: object
      required:
      - S
      - K
      - T
      - r
      - q
      - sigma
      - kind
      properties:
        S:
          $ref: '#/components/schemas/Numbers'
        K:
          $ref: '#/components/schemas/Numbers'
        T:
          $ref: '#/components/schemas/Numbers'
        r:
          $ref: '#/components/schemas/Numbers'
        q:
          $ref: '#/components/schemas/Numbers'
        sigma:
          $ref: '#/components/schemas/Numbers'
        kind:
          description: 'European: 0 call, 1 put, 2 cash-or-nothing digital call. American (/v1/greeks/named with
            american): 1 call, 0 put'
          oneOf:
          - type: integer
            enum:
            - 0
            - 1
            - 2
          - type: array
            items:
              type: integer
              enum:
              - 0
              - 1
              - 2
    AmericanOptions:
      type: object
      properties:
        accuracy:
          type: string
          enum:
          - accurate
          - fast
          - high
          default: accurate
      description: 'American options: accuracy accurate (default), fast or high'
    Meta:
      type: object
      properties:
        n:
          type: integer
        compute_ms:
          type: number
        version:
          type: string
        cpu_path:
          type: string
        certificate:
          type: object
          description: present when the request asked for one
  responses:
    Sigma:
      description: Implied volatilities (null = no volatility reproduces the price)
      content:
        application/json:
          schema:
            allOf:
            - $ref: '#/components/schemas/Meta'
            - type: object
              properties:
                sigma:
                  $ref: '#/components/schemas/NullableNumbers'
                greeks:
                  type: object
                  additionalProperties:
                    $ref: '#/components/schemas/NullableNumbers'
    Error:
      description: Bad request (the message never echoes your inputs)
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
    Forbidden:
      description: Missing or unknown API key (API Gateway)
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                type: string
    Limited:
      description: Rate limit, monthly quota, daily quote cap or WAF limit reached
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
              message:
                type: string
