{
  "openapi": "3.1.0",
  "info": {
    "title": "NEPSEFX Public Data",
    "version": "1.0.0",
    "description": "Read-only NEPSE share and Nepal mutual-fund research: NAV, disclosed portfolios, stock ownership, overlap and market data. Not investment advice or trade execution. Values may be delayed or unavailable. Check session dates, receipt timestamps and stale flags before describing data as current. Monetary values and percentages are decimal strings; money is NPR. Null means unavailable, not zero. Reuse responses, honor Retry-After and next_refresh_at, and avoid bulk polling. Additional response fields may be returned.",
    "contact": { "email": "support@nepsefx.com" },
    "termsOfService": "https://nepsefx.com/terms"
  },
  "servers": [{ "url": "https://nepsefx.com" }],
  "security": [],
  "paths": {
    "/api/v1/funds": {
      "get": {
        "operationId": "getFundDirectory",
        "summary": "Discover Nepal mutual funds, latest NAV, prices and portfolio periods",
        "description": "Includes open-end, listed closed-end, matured and pipeline identities. Pipeline identities may have no observations. Missing values are null, never zero.",
        "responses": {
          "200": {
            "description": "Available accepted fund data; inspect the independent observation and report dates.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FundOverview"
                }
              }
            }
          },
          "304": {
            "description": "Not modified when the supplied If-None-Match matches the current ETag."
          },
          "default": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/v1/funds/{fund}": {
      "get": {
        "operationId": "getFundDetail",
        "summary": "Read a fund’s NAV history, disclosed portfolio, allocations and distributions",
        "description": "Holdings are dated disclosures, not live inventory. NAV, exchange-price and report dates can differ. Open-end funds have no NEPSE price or premium/discount. Raw NAV changes exclude distributions.",
        "parameters": [
          {
            "$ref": "#/components/parameters/Fund"
          },
          {
            "name": "report",
            "in": "query",
            "description": "Exact Gregorian portfolio valuation date; omit for the latest financial report.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Available accepted fund data; inspect the independent observation and report dates.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FundDetail"
                }
              }
            }
          },
          "304": {
            "description": "Not modified when the supplied If-None-Match matches the current ETag."
          },
          "default": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/v1/funds/{fund}/nav": {
      "get": {
        "operationId": "getFundNavHistory",
        "summary": "Page backwards through accepted canonical fund NAV observations",
        "description": "history is ascending within the page. Pass next_before as the next exclusive before cursor until null. Conflicting observations remain unavailable pending review.",
        "parameters": [
          {
            "$ref": "#/components/parameters/Fund"
          },
          {
            "name": "before",
            "in": "query",
            "required": true,
            "description": "Exclusive Gregorian NAV observation date from next_before.",
            "schema": {
              "type": "string",
              "format": "date"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Available accepted fund data; inspect the independent observation and report dates.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FundNavHistory"
                }
              }
            }
          },
          "304": {
            "description": "Not modified when the supplied If-None-Match matches the current ETag."
          },
          "default": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/v1/funds/exposure": {
      "get": {
        "operationId": "getFundStockExposure",
        "summary": "Find stock-wise mutual fund holdings and fund owners by sector",
        "description": "Aggregates eligible complete disclosed portfolios in one BS period. Each contributing fund keeps its own valuation date. Sector exposure covers direct equity/promoter positions, not fund-of-fund look-through.",
        "parameters": [
          {
            "$ref": "#/components/parameters/FundPeriod"
          },
          {
            "$ref": "#/components/parameters/FundManager"
          },
          {
            "$ref": "#/components/parameters/FundType"
          }
        ],
        "responses": {
          "200": {
            "description": "Available accepted fund data; inspect the independent observation and report dates.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FundExposure"
                }
              }
            }
          },
          "304": {
            "description": "Not modified when the supplied If-None-Match matches the current ETag."
          },
          "default": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/v1/funds/changes": {
      "get": {
        "operationId": "getFundHoldingChanges",
        "summary": "Compare reported increases and reductions in fund stock units",
        "description": "Uses matching complete scopes and each fund’s previous disclosure. Unit changes may include corporate actions; they are not confirmed trades. Missing quantities and incompatible scopes are excluded.",
        "parameters": [
          {
            "$ref": "#/components/parameters/FundPeriod"
          },
          {
            "$ref": "#/components/parameters/FundManager"
          },
          {
            "$ref": "#/components/parameters/FundType"
          }
        ],
        "responses": {
          "200": {
            "description": "Available accepted fund data; inspect the independent observation and report dates.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FundChanges"
                }
              }
            }
          },
          "304": {
            "description": "Not modified when the supplied If-None-Match matches the current ETag."
          },
          "default": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/v1/funds/overlap": {
      "get": {
        "operationId": "getFundPortfolioOverlap",
        "summary": "Compare listed-portfolio overlap for two through eight funds",
        "description": "Returns conservative lower value and upper bounds where identities are unresolved. Percentages compare disclosed listed positions, not returns, alpha or correlations.",
        "parameters": [
          {
            "$ref": "#/components/parameters/FundPeriod"
          },
          {
            "name": "funds",
            "in": "query",
            "required": true,
            "description": "Comma-separated directory keys for two through eight funds.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Available accepted fund data; inspect the independent observation and report dates.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FundOverlap"
                }
              }
            }
          },
          "304": {
            "description": "Not modified when the supplied If-None-Match matches the current ETag."
          },
          "default": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/v1/funds/compare": {
      "get": {
        "operationId": "getFundNavComparison",
        "summary": "Read selected funds' canonical NAVs on a common actual-date window",
        "description": "Raw NAV change only; not distribution-adjusted total return. Start and end are shared actual valuation dates. Native observations remain distinct. Null bounds mean no shared history; complete=false means the observation bound was exceeded and must not be plotted as complete.",
        "parameters": [
          {"name": "funds", "in": "query", "required": true, "description": "One through eight comma-separated directory keys.", "schema": {"type": "string", "maxLength": 807}},
          {"name": "range", "in": "query", "schema": {"type": "string", "enum": ["month", "quarter", "year", "all"], "default": "year"}}
        ],
        "responses": {
          "200": {"description": "Exact canonical NAV observations and effective common dates.", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/FundComparison"}}}},
          "304": {"description": "Not modified when If-None-Match matches the current ETag."},
          "default": {"$ref": "#/components/responses/Unavailable"}
        }
      }
    },
    "/api/v1/flows/catalog": {
      "get": {
        "operationId": "getShareAndBrokerCatalog",
        "summary": "Discover share symbols, company names and broker identifiers",
        "responses": { "200": { "description": "Public reference catalog. Historical symbols can be present; use the individual endpoint's status to check availability.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Catalog" } } } }, "default": { "$ref": "#/components/responses/Unavailable" } }
      }
    },
    "/api/v1/indices/catalog": {
      "get": {
        "operationId": "getIndexCatalog",
        "summary": "Discover supported index and sector chart symbols",
        "responses": { "200": { "description": "Index definitions", "content": { "application/json": { "schema": { "type": "array", "items": { "type": "object", "required": ["id", "symbol", "name", "group"], "properties": { "id": { "type": "integer" }, "symbol": { "$ref": "#/components/schemas/Symbol" }, "name": { "type": "string" }, "group": { "enum": ["INDEX", "SECTOR"] } } } } } } }, "default": { "$ref": "#/components/responses/Unavailable" } }
      }
    },
    "/api/v1/market/status": {
      "get": {
        "operationId": "getMarketStatus",
        "summary": "Read session status, freshness and the NEPSE index quote",
        "responses": { "200": { "description": "Last available status; inspect stale and as_of", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/MarketStatus" } } } }, "default": { "$ref": "#/components/responses/Unavailable" } }
      }
    },
    "/api/v1/market": {
      "get": {
        "operationId": "getMarketDashboard",
        "summary": "Read market-wide prices and activity in one request",
        "description": "Prefer this publication when comparing multiple shares. stocks contains ordinary-equity marks, with nullable return values where the reference price is unknown. Prices can carry a prior-session mark before a new trade; do not infer a current-session execution from price alone.",
        "responses": { "200": { "description": "Last available market publication", "content": { "application/json": { "schema": { "allOf": [{ "$ref": "#/components/schemas/MarketStatus" }, { "type": "object", "required": ["stocks"], "properties": { "stocks": { "type": "array", "items": { "type": "object", "properties": { "symbol": { "$ref": "#/components/schemas/Symbol" }, "price": { "$ref": "#/components/schemas/Decimal" }, "day_pct": { "$ref": "#/components/schemas/NullableDecimal" }, "volume": { "type": "integer", "minimum": 0 } } } } } }] } } } }, "default": { "$ref": "#/components/responses/Unavailable" } }
      }
    },
    "/api/v1/scrip/{symbol}": {
      "get": {
        "operationId": "getShareOverview",
        "summary": "Read a share's company profile, peers, historical prices and announcements",
        "parameters": [{ "$ref": "#/components/parameters/Symbol" }, { "name": "history", "in": "query", "description": "Use recent for a bounded initial response; use the prices endpoint to page backwards.", "schema": { "enum": ["recent", "all"], "default": "all" } }],
        "responses": { "200": { "description": "Available company data. Profile values and announcements have independent source dates; this is not a live-quote guarantee.", "content": { "application/json": { "schema": { "type": "object", "properties": { "profile": { "type": "object" }, "peers": { "type": "array", "items": { "type": "object" } }, "prices": { "type": "array", "items": { "$ref": "#/components/schemas/PriceBar" } }, "price_count": { "type": "integer", "minimum": 0 }, "fund_owners": { "type": "array", "description": "Dated mutual-fund ownership shown by the scrip MF HOLDINGS panel; not live inventory.", "items": { "$ref": "#/components/schemas/FundOwner" } } } } } } }, "default": { "$ref": "#/components/responses/Unavailable" } }
      }
    },
    "/api/v1/scrip/{symbol}/prices": {
      "get": {
        "operationId": "getSharePriceHistory",
        "summary": "Read a page of daily share prices",
        "description": "Rows within a page are ascending by date. To retrieve older history, pass next_before as before until it is null. Do not assume the first page is the complete archive.",
        "parameters": [{ "$ref": "#/components/parameters/Symbol" }, { "$ref": "#/components/parameters/Before" }],
        "responses": { "200": { "$ref": "#/components/responses/PricePage" }, "default": { "$ref": "#/components/responses/Unavailable" } }
      }
    },
    "/api/v1/indices/{symbol}/prices": {
      "get": {
        "operationId": "getIndexPriceHistory",
        "summary": "Read a page of daily index values",
        "description": "Use a symbol from the index catalog. Rows are ascending within each page; follow next_before until null. Some historical rows have only closing values, with null OHLC or volume.",
        "parameters": [{ "$ref": "#/components/parameters/Symbol" }, { "$ref": "#/components/parameters/Before" }],
        "responses": { "200": { "$ref": "#/components/responses/PricePage" }, "default": { "$ref": "#/components/responses/Unavailable" } }
      }
    },
    "/api/v1/indices/{symbol}/benchmark": {
      "get": {
        "operationId": "getIndexBenchmark",
        "summary": "Read compact daily index closes for performance comparison",
        "description": "One indexed range with the actual preceding close when available. Dates are never future-filled. Start must be 1990 or later; end cannot be in the future; maximum span is forty years. Supports ETag and 304. Stored observations remain usable during an upstream refresh failure.",
        "parameters": [
          { "$ref": "#/components/parameters/Symbol" },
          { "name": "start", "in": "query", "required": true, "schema": { "type": "string", "format": "date" } },
          { "name": "end", "in": "query", "required": true, "schema": { "type": "string", "format": "date" } }
        ],
        "responses": {
          "200": { "description": "Dated closes in ascending order, including at most one predecessor", "content": { "application/json": { "schema": {
            "type": "object", "required": ["symbol", "refresh_ms", "prices"], "properties": {
              "symbol": { "type": "string" }, "refresh_ms": { "type": "integer", "const": 60000 },
              "prices": { "type": "array", "maxItems": 16384, "items": { "type": "object", "required": ["date", "close"], "properties": {
                "date": { "type": "string", "format": "date" }, "close": { "type": "string" }
              } } }
            }
          } } } },
          "304": { "description": "Unchanged benchmark; no response body" },
          "default": { "$ref": "#/components/responses/Unavailable" }
        }
      }
    },
    "/api/v1/flows/symbol/{symbol}": {
      "get": {
        "operationId": "getShareBrokerFlows",
        "summary": "Read recorded broker buying and selling for one share",
        "description": "Check meta.window, coverage and unrecorded_dates before treating the selected history as complete. Net recorded activity is not proof of a broker's or client's complete holdings.",
        "parameters": [{ "$ref": "#/components/parameters/Symbol" }, { "$ref": "#/components/parameters/Range" }, { "$ref": "#/components/parameters/Start" }, { "$ref": "#/components/parameters/End" }],
        "responses": { "200": { "$ref": "#/components/responses/Analysis" }, "default": { "$ref": "#/components/responses/Unavailable" } }
      }
    },
    "/api/v1/flows/broker/{broker}": {
      "get": {
        "operationId": "getBrokerShareFlows",
        "summary": "Read a broker's recorded buying and selling by share",
        "parameters": [{ "$ref": "#/components/parameters/Broker" }, { "$ref": "#/components/parameters/Range" }, { "$ref": "#/components/parameters/Start" }, { "$ref": "#/components/parameters/End" }],
        "responses": { "200": { "$ref": "#/components/responses/Analysis" }, "default": { "$ref": "#/components/responses/Unavailable" } }
      }
    },
    "/api/v1/flows/history/{symbol}/{broker}": {
      "get": {
        "operationId": "getShareBrokerDailyHistory",
        "summary": "Read daily trading activity for a share and broker",
        "parameters": [{ "$ref": "#/components/parameters/Symbol" }, { "$ref": "#/components/parameters/Broker" }, { "$ref": "#/components/parameters/Range" }, { "$ref": "#/components/parameters/Start" }, { "$ref": "#/components/parameters/End" }],
        "responses": { "200": { "description": "Recorded daily history; inspect meta coverage before treating it as complete", "content": { "application/json": { "schema": { "type": "object", "required": ["meta", "days"], "properties": { "meta": { "type": "object" }, "days": { "type": "array", "items": { "type": "object", "properties": { "date": { "type": "string", "format": "date" }, "buy_qty": { "type": "integer" }, "sell_qty": { "type": "integer" }, "net_qty": { "type": "integer" } } } } } } } } }, "default": { "$ref": "#/components/responses/Unavailable" } }
      }
    },
    "/api/v1/cal": {
      "get": {
        "operationId": "getNepaliCalendar",
        "summary": "Read a Bikram Sambat calendar with Gregorian dates and market holidays",
        "description": "Omit parameters for today in Asia/Kathmandu. Supply at most one of month, bs or ad. Unsupported or conflicting dates return HTTP 400. null holidays means unavailable, not no holidays.",
        "parameters": [
          { "name": "month", "in": "query", "description": "Bikram Sambat YYYY-MM", "schema": { "type": "string", "pattern": "^[0-9]{4}-[0-9]{2}$" } },
          { "name": "bs", "in": "query", "description": "Bikram Sambat YYYY-MM-DD", "schema": { "type": "string", "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$" } },
          { "name": "ad", "in": "query", "description": "Gregorian YYYY-MM-DD", "schema": { "type": "string", "format": "date" } }
        ],
        "responses": { "200": { "description": "Selected month, supported date bounds, today, selected date, fiscal context and holiday availability", "content": { "application/json": { "schema": { "type": "object", "required": ["timezone", "today", "date", "month"], "properties": { "timezone": { "const": "Asia/Kathmandu" }, "today": { "type": "object" }, "date": { "type": "object" }, "month": { "type": "object" }, "nextRefreshAt": { "type": "string", "format": "date-time" } } } } } }, "default": { "$ref": "#/components/responses/Unavailable" } }
      }
    },
    "/api/v1/cal/lite": {
      "get": {
        "operationId": "getNepalDate",
        "summary": "Read current Nepal time, Gregorian and Bikram Sambat dates and fiscal context",
        "responses": { "200": { "description": "Current Nepal date and fiscal context", "content": { "application/json": { "schema": { "type": "object" } } } }, "default": { "$ref": "#/components/responses/Unavailable" } }
      }
    }
  },
  "components": {
    "parameters": {
      "Fund": {"name": "fund", "in": "path", "required": true, "description": "Scheme key from the fund directory; a key is not necessarily a ticker.", "schema": {"$ref": "#/components/schemas/FundKey"}},
      "FundPeriod": {"name": "period", "in": "query", "required": true, "description": "Disclosure month in Bikram Sambat, not Gregorian YYYY-MM.", "schema": {"type": "string", "pattern": "^[0-9]{4}-(0[1-9]|1[0-2])$"}},
      "FundManager": {"name": "manager", "in": "query", "description": "Manager key from the fund directory, or all.", "schema": {"$ref": "#/components/schemas/FundKey"}},
      "FundType": {"name": "type", "in": "query", "schema": {"enum": ["active", "all", "closed_end", "open_end", "archive", "pipeline"], "default": "active"}},
      "Symbol": { "name": "symbol", "in": "path", "required": true, "description": "Uppercase symbol from the relevant share or index catalog, for example RSML for a share or NEPSE for an index", "schema": { "$ref": "#/components/schemas/Symbol" } },
      "Broker": { "name": "broker", "in": "path", "required": true, "description": "Broker identifier from the public catalog", "schema": { "type": "integer", "minimum": 1, "maximum": 32767 } },
      "Before": { "name": "before", "in": "query", "description": "Exclusive Gregorian business-date cursor; use the previous page's next_before", "schema": { "type": "string", "format": "date" } },
      "Range": { "name": "range", "in": "query", "description": "Custom requires start and end within retained coverage", "schema": { "enum": ["day", "week", "month", "three_months", "custom"], "default": "month" } },
      "Start": { "name": "start", "in": "query", "description": "Inclusive Gregorian start; required with range=custom", "schema": { "type": "string", "format": "date" } },
      "End": { "name": "end", "in": "query", "description": "Inclusive Gregorian end; required with range=custom", "schema": { "type": "string", "format": "date" } }
    },
    "responses": {
      "Unavailable": { "description": "Non-success response: invalid selection, unknown symbol, rate limit, or temporarily unavailable data. Check HTTP status; honor Retry-After when present. Never substitute zero values for an error.", "headers": { "Retry-After": { "description": "Retry delay in seconds when supplied", "schema": { "type": "string" } } } },
      "PricePage": { "description": "Ascending rows and exclusive cursor for the next older page", "content": { "application/json": { "schema": { "type": "object", "required": ["prices", "next_before"], "properties": { "prices": { "type": "array", "items": { "$ref": "#/components/schemas/PriceBar" } }, "next_before": { "type": ["string", "null"], "format": "date" } } } } } },
      "Analysis": { "description": "Recorded activity grouped by counterparty; meta includes the selected window and data coverage", "content": { "application/json": { "schema": { "type": "object", "required": ["meta", "summary"], "properties": { "meta": { "type": "object" }, "summary": { "type": "array", "items": { "type": "object", "properties": { "entity": { "type": "object" }, "buy_qty": { "type": "integer" }, "sell_qty": { "type": "integer" }, "net_qty": { "type": "integer" }, "buy_amount": { "$ref": "#/components/schemas/Decimal" }, "sell_amount": { "$ref": "#/components/schemas/Decimal" }, "net_amount": { "$ref": "#/components/schemas/Decimal" } } } } } } } } }
    },
    "schemas": {
      "FundOwner": {"type": "object", "required": ["key", "symbol", "name", "date", "quantity", "value", "weight_pct"], "properties": {"key": {"$ref": "#/components/schemas/FundKey"}, "symbol": {"type": ["string", "null"]}, "name": {"type": "string"}, "date": {"type": "string", "format": "date"}, "quantity": {"$ref": "#/components/schemas/NullableDecimal"}, "value": {"$ref": "#/components/schemas/Decimal"}, "weight_pct": {"$ref": "#/components/schemas/Decimal"}}},
      "FundKey": {"type": "string", "pattern": "^[a-z0-9][a-z0-9-]{0,99}$"},
      "FundSummary": {"type": "object", "required": ["key", "symbol", "name", "kind", "lifecycle", "manager_key", "nav", "nav_date", "price", "price_date"], "properties": {"key": {"$ref": "#/components/schemas/FundKey"}, "symbol": {"type": ["string", "null"]}, "name": {"type": "string"}, "kind": {"enum": ["open_end", "closed_end"]}, "lifecycle": {"type": "string"}, "manager_key": {"$ref": "#/components/schemas/FundKey"}, "nav": {"$ref": "#/components/schemas/NullableDecimal"}, "nav_date": {"type": ["string", "null"], "format": "date"}, "price": {"$ref": "#/components/schemas/NullableDecimal"}, "price_date": {"type": ["string", "null"], "format": "date"}, "price_change_pct": {"$ref": "#/components/schemas/NullableDecimal"}, "premium_pct": {"$ref": "#/components/schemas/NullableDecimal"}, "net_assets": {"$ref": "#/components/schemas/NullableDecimal"}, "period_bs": {"type": ["string", "null"]}}},
      "FundOverview": {"type": "object", "required": ["funds", "managers", "periods", "refresh_ms"], "properties": {"funds": {"type": "array", "items": {"$ref": "#/components/schemas/FundSummary"}}, "managers": {"type": "array", "items": {"type": "object", "required": ["key", "name"], "properties": {"key": {"$ref": "#/components/schemas/FundKey"}, "name": {"type": "string"}, "website": {"type": "string", "format": "uri"}}}}, "periods": {"type": "array", "items": {"type": "string", "pattern": "^[0-9]{4}-(0[1-9]|1[0-2])$"}}, "refresh_ms": {"type": "integer", "minimum": 0}, "portfolio_periods": {"type": "array", "description": "Complete portfolio membership per BS month; independent of NAV observations.", "items": {"type": "object", "required": ["period_bs", "funds"], "properties": {"period_bs": {"type": "string", "pattern": "^[0-9]{4}-(0[1-9]|1[0-2])$"}, "funds": {"type": "array", "uniqueItems": true, "items": {"$ref": "#/components/schemas/FundKey"}}}}}}},
      "FundHolding": {"type": "object", "required": ["key", "name", "asset_class", "quantity", "value", "weight_pct"], "properties": {"key": {"type": "string"}, "symbol": {"type": ["string", "null"]}, "name": {"type": "string"}, "asset_class": {"type": "string"}, "bucket": {"type": "string"}, "sector": {"type": ["string", "null"]}, "quantity": {"$ref": "#/components/schemas/NullableDecimal"}, "value": {"$ref": "#/components/schemas/Decimal"}, "weight_pct": {"$ref": "#/components/schemas/Decimal"}, "previous_quantity": {"$ref": "#/components/schemas/NullableDecimal"}, "change": {"$ref": "#/components/schemas/NullableDecimal"}}},
      "FundNavPoint": {"type": "object", "required": ["date", "nav"], "properties": {"date": {"type": "string", "format": "date"}, "nav": {"$ref": "#/components/schemas/Decimal"}, "price": {"$ref": "#/components/schemas/NullableDecimal"}, "premium_pct": {"$ref": "#/components/schemas/NullableDecimal"}}},
      "FundDetail": {"type": "object", "required": ["key", "refresh_ms", "report", "history", "prices", "next_before", "holdings", "allocation", "sectors", "distributions"], "properties": {"key": {"$ref": "#/components/schemas/FundKey"}, "refresh_ms": {"type": "integer", "minimum": 0}, "report": {"type": ["object", "null"], "properties": {"date": {"type": "string", "format": "date"}, "period_bs": {"type": ["string", "null"]}, "holdings_complete": {"type": "boolean"}, "holdings_scope": {"enum": ["listed", "all"]}, "url": {"type": "string", "format": "uri"}, "nav": {"$ref": "#/components/schemas/NullableDecimal"}, "units": {"$ref": "#/components/schemas/NullableDecimal"}, "assets": {"$ref": "#/components/schemas/NullableDecimal"}, "liabilities": {"$ref": "#/components/schemas/NullableDecimal"}, "net_assets": {"$ref": "#/components/schemas/NullableDecimal"}, "cash": {"$ref": "#/components/schemas/NullableDecimal"}, "fixed_income": {"$ref": "#/components/schemas/NullableDecimal"}, "listed_equity": {"$ref": "#/components/schemas/NullableDecimal"}, "unlisted_equity": {"$ref": "#/components/schemas/NullableDecimal"}, "realized_profit": {"$ref": "#/components/schemas/NullableDecimal"}, "unrealized_profit": {"$ref": "#/components/schemas/NullableDecimal"}, "distributable_profit": {"$ref": "#/components/schemas/NullableDecimal"}}}, "reports": {"type": "array", "items": {"type": "object", "properties": {"date": {"type": "string", "format": "date"}, "period_bs": {"type": ["string", "null"]}, "complete": {"type": "boolean"}}}}, "history": {"type": "array", "items": {"$ref": "#/components/schemas/FundNavPoint"}}, "prices": {"type": "array", "items": {"type": "object", "required": ["date", "price"], "properties": {"date": {"type": "string", "format": "date"}, "price": {"$ref": "#/components/schemas/Decimal"}}}}, "next_before": {"type": ["string", "null"], "format": "date"}, "holdings": {"type": "array", "items": {"$ref": "#/components/schemas/FundHolding"}}, "allocation": {"type": "array", "items": {"type": "object", "required": ["name", "value", "weight_pct"], "properties": {"name": {"type": "string"}, "value": {"$ref": "#/components/schemas/Decimal"}, "weight_pct": {"$ref": "#/components/schemas/Decimal"}}}}, "sectors": {"type": "array", "items": {"type": "object", "required": ["name", "value", "weight_pct"], "properties": {"name": {"type": "string"}, "value": {"$ref": "#/components/schemas/Decimal"}, "weight_pct": {"$ref": "#/components/schemas/Decimal"}}}}, "distributions": {"type": "array", "items": {"type": "object", "required": ["fiscal_year", "declared_date", "cash_pct", "cash_per_unit", "url"], "properties": {"fiscal_year": {"type": "string"}, "declared_date": {"type": ["string", "null"], "format": "date"}, "ex_date": {"type": ["string", "null"], "format": "date"}, "book_close_date": {"type": ["string", "null"], "format": "date"}, "payment_date": {"type": ["string", "null"], "format": "date"}, "cash_pct": {"$ref": "#/components/schemas/NullableDecimal"}, "declared_cash_pct": {"$ref": "#/components/schemas/NullableDecimal"}, "cash_per_unit": {"$ref": "#/components/schemas/NullableDecimal"}, "url": {"type": "string", "format": "uri"}}}}}},
      "FundNavHistory": {"type": "object", "required": ["history", "next_before"], "properties": {"history": {"type": "array", "items": {"$ref": "#/components/schemas/FundNavPoint"}}, "next_before": {"type": ["string", "null"], "format": "date"}}},
      "FundExposure": {"type": "object", "required": ["period_bs", "refresh_ms", "funds", "stocks", "sectors", "classes"], "properties": {"period_bs": {"type": "string", "pattern": "^[0-9]{4}-(0[1-9]|1[0-2])$"}, "refresh_ms": {"type": "integer", "minimum": 0}, "funds": {"type": "array", "items": {"type": "object", "properties": {"key": {"$ref": "#/components/schemas/FundKey"}, "date": {"type": "string", "format": "date"}}}}, "stocks": {"type": "array", "items": {"type": "object", "properties": {"symbol": {"type": "string"}, "asset_class": {"type": "string"}, "sector": {"type": "string"}, "quantity": {"$ref": "#/components/schemas/NullableDecimal"}, "value": {"$ref": "#/components/schemas/Decimal"}, "funds": {"type": "integer", "minimum": 0}, "owners": {"type": "array", "items": {"type": "object", "properties": {"fund": {"$ref": "#/components/schemas/FundKey"}, "quantity": {"$ref": "#/components/schemas/NullableDecimal"}, "value": {"$ref": "#/components/schemas/Decimal"}, "weight_pct": {"$ref": "#/components/schemas/Decimal"}}}}, "weight_pct": {"$ref": "#/components/schemas/NullableDecimal", "description": "Share of all disclosed security holdings, including unnamed positions; excludes cash/other assets. Display filters do not change this denominator."}}}}, "sectors": {"type": "array", "items": {"type": "object", "required": ["name", "value", "weight_pct"], "properties": {"name": {"type": "string"}, "value": {"$ref": "#/components/schemas/Decimal"}, "weight_pct": {"$ref": "#/components/schemas/Decimal"}}}}, "classes": {"type": "array", "items": {"type": "object", "required": ["name", "value", "weight_pct"], "properties": {"name": {"type": "string"}, "value": {"$ref": "#/components/schemas/Decimal"}, "weight_pct": {"$ref": "#/components/schemas/Decimal"}}}}}},
      "FundChanges": {"type": "object", "required": ["period_bs", "refresh_ms", "funds", "stocks"], "properties": {"period_bs": {"type": "string", "pattern": "^[0-9]{4}-(0[1-9]|1[0-2])$"}, "refresh_ms": {"type": "integer", "minimum": 0}, "funds": {"type": "array", "items": {"type": "object", "properties": {"key": {"$ref": "#/components/schemas/FundKey"}, "date": {"type": "string", "format": "date"}, "previous_date": {"type": "string", "format": "date"}}}}, "stocks": {"type": "array", "items": {"type": "object", "properties": {"symbol": {"type": "string"}, "asset_class": {"type": "string"}, "sector": {"type": "string"}, "quantity": {"$ref": "#/components/schemas/Decimal"}, "previous_quantity": {"$ref": "#/components/schemas/Decimal"}, "added_units": {"$ref": "#/components/schemas/Decimal"}, "reduced_units": {"$ref": "#/components/schemas/Decimal"}, "net_units": {"$ref": "#/components/schemas/Decimal"}, "value": {"$ref": "#/components/schemas/Decimal"}, "owners": {"type": "array", "items": {"type": "object", "properties": {"fund": {"$ref": "#/components/schemas/FundKey"}, "date": {"type": "string", "format": "date"}, "previous_date": {"type": "string", "format": "date"}, "quantity": {"$ref": "#/components/schemas/Decimal"}, "previous_quantity": {"$ref": "#/components/schemas/Decimal"}, "change": {"$ref": "#/components/schemas/Decimal"}}}}}}}}},
      "FundComparison": {"type": "object", "required": ["refresh_ms", "start", "end", "complete", "funds"], "properties": {"refresh_ms": {"const": 60000}, "start": {"type": ["string", "null"], "format": "date"}, "end": {"type": ["string", "null"], "format": "date"}, "complete": {"type": "boolean"}, "funds": {"type": "array", "maxItems": 8, "items": {"type": "object", "required": ["key", "history"], "properties": {"key": {"$ref": "#/components/schemas/FundKey"}, "history": {"type": "array", "maxItems": 16385, "items": {"$ref": "#/components/schemas/FundNavPoint"}}}}}}},
      "FundOverlap": {"type": "object", "required": ["period_bs", "basis", "refresh_ms", "funds", "pairs"], "properties": {"period_bs": {"type": "string", "pattern": "^[0-9]{4}-(0[1-9]|1[0-2])$"}, "basis": {"const": "listed"}, "refresh_ms": {"type": "integer", "minimum": 0}, "funds": {"type": "array", "items": {"$ref": "#/components/schemas/FundKey"}}, "pairs": {"type": "array", "items": {"type": "object", "required": ["a", "b", "value"], "properties": {"a": {"$ref": "#/components/schemas/FundKey"}, "b": {"$ref": "#/components/schemas/FundKey"}, "value": {"$ref": "#/components/schemas/Decimal"}, "upper": {"$ref": "#/components/schemas/Decimal"}}}}}},
      "Symbol": { "type": "string", "pattern": "^[A-Z0-9]{1,20}$", "examples": ["RSML"] },
      "Decimal": { "type": "string", "pattern": "^-?[0-9]+(?:\\.[0-9]+)?$" },
      "NullableDecimal": { "anyOf": [{ "$ref": "#/components/schemas/Decimal" }, { "type": "null" }] },
      "Catalog": {
        "type": "object", "required": ["equities", "brokers"],
        "properties": {
          "equities": { "type": "array", "items": { "type": "object", "required": ["symbol", "name"], "properties": { "symbol": { "$ref": "#/components/schemas/Symbol" }, "name": { "type": "string" } } } },
          "brokers": { "type": "array", "items": { "type": "integer", "minimum": 1, "maximum": 32767 } },
          "broker_names": { "type": "object", "additionalProperties": { "type": "string" } }
        }
      },
      "MarketStatus": {
        "type": "object", "required": ["as_of", "fetched_at", "open", "stale"],
        "properties": {
          "as_of": { "type": "string", "format": "date", "description": "Market session date in Asia/Kathmandu" },
          "fetched_at": { "type": "string", "format": "date-time", "description": "Receipt timestamp, not the time of every trade" },
          "next_refresh_at": { "type": ["string", "null"], "format": "date-time" },
          "open": { "type": "boolean", "description": "Whether the regular trading session is open" },
          "phase": { "enum": ["pre_open", "pre_open_closed", "open", "halted", "closed"] },
          "stale": { "type": "boolean" },
          "index": { "type": ["object", "null"], "properties": { "value": { "$ref": "#/components/schemas/Decimal" }, "change_pct": { "$ref": "#/components/schemas/Decimal" } } }
        }
      },
      "PriceBar": {
        "type": "object", "required": ["date", "close"],
        "properties": {
          "date": { "type": "string", "format": "date" },
          "open": { "$ref": "#/components/schemas/NullableDecimal" },
          "high": { "$ref": "#/components/schemas/NullableDecimal" },
          "low": { "$ref": "#/components/schemas/NullableDecimal" },
          "close": { "$ref": "#/components/schemas/Decimal" },
          "volume": { "type": ["integer", "null"], "minimum": 0 },
          "turnover": { "$ref": "#/components/schemas/NullableDecimal" }
        }
      }
    }
  }
}
