{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/philidor-io/json-schema/philidor-io-portfolio-overlap-response-schema.json",
  "title": "PortfolioOverlapResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/philidor-io-portfolio-api-openapi.yml#/components/schemas/PortfolioOverlapResponse",
  "type": "object",
  "properties": {
    "data": {
      "type": "object",
      "properties": {
        "snapshotId": {
          "type": "string"
        },
        "builtAt": {
          "type": "string"
        },
        "validTime": {
          "type": "string"
        },
        "status": {
          "type": "string",
          "enum": [
            "authoritative",
            "partial"
          ],
          "description": "'authoritative' = all positions resolved; 'partial' = only some resolved (see coverage.resolvedShare) so metrics are non-authoritative."
        },
        "totalUsd": {
          "type": "number"
        },
        "positionHhi": {
          "type": "number"
        },
        "factorHhi": {
          "type": "number"
        },
        "naiveEffectiveN": {
          "type": "number"
        },
        "effectiveN": {
          "type": "number"
        },
        "overlapRatio": {
          "type": "number"
        },
        "positions": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "vaultKey": {
                "type": "string"
              },
              "amountUsd": {
                "type": "number"
              },
              "weight": {
                "type": "number"
              },
              "resolved": {
                "type": "boolean"
              }
            },
            "required": [
              "vaultKey",
              "amountUsd",
              "weight",
              "resolved"
            ]
          }
        },
        "topFactors": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "factorKey": {
                "type": "string"
              },
              "symbol": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "weight": {
                "type": "number"
              },
              "positionCount": {
                "type": "number"
              },
              "vaultKeys": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "synthetic": {
                "type": "boolean"
              }
            },
            "required": [
              "factorKey",
              "symbol",
              "weight",
              "positionCount",
              "vaultKeys",
              "synthetic"
            ]
          }
        },
        "pairs": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "a": {
                "type": "string"
              },
              "b": {
                "type": "string"
              },
              "cosine": {
                "type": "number"
              },
              "sharedFactors": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "a",
              "b",
              "cosine",
              "sharedFactors"
            ]
          }
        },
        "coverage": {
          "type": "object",
          "properties": {
            "resolvedPositions": {
              "type": "number"
            },
            "unresolvedPositions": {
              "type": "number"
            },
            "resolvedUsd": {
              "type": "number"
            },
            "resolvedShare": {
              "type": "number"
            },
            "unresolvedVaultKeys": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          "required": [
            "resolvedPositions",
            "unresolvedPositions",
            "resolvedUsd",
            "resolvedShare",
            "unresolvedVaultKeys"
          ]
        }
      },
      "required": [
        "snapshotId",
        "builtAt",
        "validTime",
        "status",
        "totalUsd",
        "positionHhi",
        "factorHhi",
        "naiveEffectiveN",
        "effectiveN",
        "overlapRatio",
        "positions",
        "topFactors",
        "pairs",
        "coverage"
      ]
    }
  },
  "required": [
    "data"
  ]
}