{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "$id": "https://signalshopper.com/signals/schema/ranked.schema.json",
 "title": "Signal Shopper ranked feed",
 "description": "A ranked list of signals for one side (buy or sell). The provider ranks; Signal Shopper shows the first ten in the order given.",
 "type": "object",
 "required": [
  "format",
  "side",
  "items"
 ],
 "properties": {
  "format": {
   "const": "signalshopper.ranked/1"
  },
  "provider": {
   "type": "string"
  },
  "side": {
   "enum": [
    "buy",
    "sell"
   ]
  },
  "asOf": {
   "type": "string",
   "format": "date-time"
  },
  "refreshSeconds": {
   "type": "number",
   "minimum": 5,
   "description": "How often the feed changes, in seconds. The page reads it again after this long while it is on screen."
  },
  "label": {
   "type": "string",
   "minLength": 1,
   "description": "A name for this list, in place of Buys or Sells."
  },
  "meaning": {
   "type": "string",
   "minLength": 1,
   "description": "A few words on what being in this list means."
  },
  "valueName": {
   "type": "string",
   "minLength": 1,
   "description": "What a value is called, for example \"net gamma\". Defaults to \"gap\"."
  },
  "valueFormat": {
   "enum": [
    "percent",
    "number"
   ],
   "description": "\"percent\" (default) for a fraction shown as a percentage, \"number\" for a number shown as it is."
  },
  "valueUnit": {
   "type": "string",
   "minLength": 1,
   "description": "The unit of a \"number\" value, for example \"$M\"."
  },
  "items": {
   "type": "array",
   "maxItems": 100,
   "items": {
    "type": "object",
    "required": [
     "symbol"
    ],
    "anyOf": [
     {
      "required": [
       "market",
       "model"
      ]
     },
     {
      "required": [
       "edge"
      ]
     }
    ],
    "properties": {
     "symbol": {
      "type": "string",
      "minLength": 1
     },
     "type": {
      "type": "string",
      "minLength": 1,
      "description": "For example call, put or stock."
     },
     "expiry": {
      "type": "string",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
     },
     "strike": {
      "type": "number"
     },
     "market": {
      "type": "number",
      "exclusiveMinimum": 0,
      "description": "Market price."
     },
     "model": {
      "type": "number",
      "minimum": 0,
      "description": "The provider's own price."
     },
     "edge": {
      "type": "number",
      "description": "The signed value. For a price gap: (model - market) / market as a fraction, optional when market and model are given."
     },
     "asOf": {
      "type": "string",
      "format": "date-time"
     },
     "note": {
      "type": "string",
      "minLength": 1,
      "description": "A few words shown next to the contract."
     },
     "grid": {
      "type": "object",
      "required": [
       "symbol",
       "row",
       "column"
      ],
      "description": "Where this entry sits on the provider's heat map.",
      "properties": {
       "symbol": {
        "type": "string",
        "minLength": 1
       },
       "panel": {
        "type": "string",
        "minLength": 1
       },
       "row": {
        "type": [
         "number",
         "string"
        ]
       },
       "column": {
        "type": "string",
        "minLength": 1
       }
      }
     }
    },
    "dependentRequired": {
     "market": [
      "model"
     ],
     "model": [
      "market"
     ]
    }
   }
  }
 }
}
