{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/statisticsoftheworld-com/json-schema/statisticsoftheworld-com-derivative-snapshot-schema.json",
  "title": "DerivativeSnapshot",
  "x-generated": "2026-11-26",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/statisticsoftheworld-com-openapi.yml#/components/schemas/DerivativeSnapshot",
  "type": "object",
  "required": [
    "generatedAt",
    "count",
    "available",
    "partial",
    "refreshSeconds",
    "quotes",
    "sourceErrors",
    "methodology",
    "quality",
    "rights"
  ],
  "properties": {
    "generatedAt": {
      "type": "string",
      "format": "date-time"
    },
    "count": {
      "type": "integer"
    },
    "available": {
      "type": "integer"
    },
    "partial": {
      "type": "boolean"
    },
    "refreshSeconds": {
      "type": "number"
    },
    "quotes": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/DerivativeQuote"
      }
    },
    "sourceErrors": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "methodology": {
      "type": "string"
    },
    "quality": {
      "type": "object",
      "properties": {
        "maxAgeSeconds": {
          "const": 15
        },
        "maxSpreadBps": {
          "const": 100
        },
        "minTwoSidedDepth": {
          "const": 1000
        },
        "depthBandPercent": {
          "const": 1
        },
        "depthUnit": {
          "type": "string"
        }
      }
    },
    "rights": {
      "type": "object",
      "required": [
        "source",
        "notice",
        "termsUrl"
      ],
      "properties": {
        "source": {
          "type": "string"
        },
        "notice": {
          "type": "string"
        },
        "termsUrl": {
          "type": "string",
          "format": "uri"
        }
      }
    }
  },
  "$defs": {
    "DerivativeQuote": {
      "allOf": [
        {
          "type": "object",
          "required": [
            "symbol",
            "displaySymbol",
            "name",
            "category",
            "chain",
            "venue",
            "instrumentType",
            "collateralAsset",
            "unit",
            "referenceDescription",
            "sourceUrl"
          ],
          "properties": {
            "symbol": {
              "type": "string",
              "description": "Exact venue-qualified contract ID, e.g. xyz:SILVER."
            },
            "displaySymbol": {
              "type": "string"
            },
            "name": {
              "type": "string"
            },
            "category": {
              "type": "string",
              "enum": [
                "equities",
                "etfs",
                "commodities",
                "currencies",
                "indices",
                "rates"
              ]
            },
            "chain": {
              "const": "Hyperliquid"
            },
            "venue": {
              "type": "string"
            },
            "instrumentType": {
              "const": "perpetual"
            },
            "collateralAsset": {
              "const": "USDC"
            },
            "unit": {
              "type": "string",
              "description": "Contract reference units; collateral does not determine quote units."
            },
            "referenceDescription": {
              "type": "string"
            },
            "metadataSource": {
              "type": "string",
              "format": "uri"
            },
            "sourceUrl": {
              "type": "string",
              "format": "uri"
            }
          }
        },
        {
          "type": "object",
          "required": [
            "price",
            "status",
            "observedAt",
            "sourceTime",
            "bestBid",
            "bestAsk",
            "spreadBps",
            "bidDepth",
            "askDepth"
          ],
          "properties": {
            "price": {
              "type": [
                "number",
                "null"
              ]
            },
            "status": {
              "type": "string",
              "enum": [
                "ok",
                "unavailable",
                "stale",
                "empty-book",
                "wide-spread",
                "low-depth"
              ]
            },
            "observedAt": {
              "type": [
                "string",
                "null"
              ],
              "format": "date-time"
            },
            "sourceTime": {
              "type": [
                "string",
                "null"
              ],
              "format": "date-time"
            },
            "bestBid": {
              "type": [
                "object",
                "null"
              ],
              "required": [
                "price",
                "size",
                "orders"
              ],
              "properties": {
                "price": {
                  "type": "number"
                },
                "size": {
                  "type": "number"
                },
                "orders": {
                  "type": "integer"
                }
              }
            },
            "bestAsk": {
              "type": [
                "object",
                "null"
              ],
              "required": [
                "price",
                "size",
                "orders"
              ],
              "properties": {
                "price": {
                  "type": "number"
                },
                "size": {
                  "type": "number"
                },
                "orders": {
                  "type": "integer"
                }
              }
            },
            "spreadBps": {
              "type": [
                "number",
                "null"
              ]
            },
            "bidDepth": {
              "type": [
                "number",
                "null"
              ]
            },
            "askDepth": {
              "type": [
                "number",
                "null"
              ]
            },
            "error": {
              "type": "string"
            }
          }
        }
      ]
    }
  }
}