> ## Documentation Index
> Fetch the complete documentation index at: https://docs.quantspace.limex.pro/llms.txt
> Use this file to discover all available pages before exploring further.

# run_risk_job

> Risk analytics and portfolio visualizations

## Overview

`run_risk_job` runs one risk / analytics function and returns an HTML, PNG, or CSV artifact.

**Inputs:**

* `portfolio_optimization_*.json` (`Prices` + `Weights`) — usual path
* `data_extractor_*.json` — fast path; optional `portfolio_weights`, otherwise equal 1/N

Ask for what you need (“QuantStats report”, “weight dynamics”, “copula density AAPL vs MSFT”) — skills pick `function` and params.

***

## Function catalog

| `function`              | What you get                                                                                                                   |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| `quantstats`            | QuantStats tearsheet-style performance report (returns, drawdowns, ratios) vs an optional benchmark (`benchmark_ticker`, `rf`) |
| `full_risk_report`      | Full Riskfolio-style risk report (e.g. CVaR and related risk metrics; `risk_metric`, `alpha`, `rf`, `t_factor`)                |
| `dynamic_weights`       | Interactive / HTML visualization of portfolio **weight paths** over time (best default for “show me weights”)                  |
| `factor_impact`         | Factor impact analysis (loadings / significance) for a list of factor tickers (`factors`, e.g. MTUM, VLUE, QUAL, SIZE)         |
| `bootstrap_ci`          | Bootstrap **confidence intervals** for portfolio metrics (`n_boot`, `block_size`, `bootstrap_method`, `confidence_level`)      |
| `bootstrap_vis`         | Bootstrap **path / distribution** visualization (`bootstrap_method`, optional `asset_ticker`, `initial_capital`)               |
| `cluster_dendrogram`    | Hierarchical clustering dendrogram of assets (`codependence`, optional `k_clusters`) — needs ≥2 assets                         |
| `cluster_visualization` | Network-style cluster graph (`layout`, `codependence`, `linkage`)                                                              |
| `risk_impact`           | Per-asset risk contribution / impact chart (`risk_metric`, `alpha`)                                                            |
| `copula_density`        | Pairwise copula density plot for two assets (`copula`, `asset1`, `asset2`)                                                     |

Most functions accept optional `start` / `end` (`YYYY-MM-DD`) to crop the window; omit for the full sample.

***

## Parameters

<ParamField body="input_url" type="string" required>
  Blob URL to `portfolio_optimization_*.json` or `data_extractor_*.json`.
</ParamField>

<ParamField body="config" type="object" required>
  <Expandable title="config fields">
    <ParamField body="function" type="string" required>
      One of the catalog values above.
    </ParamField>

    <ParamField body="portfolio_weights" type="object">
      Optional weights for the data-extraction fast path, e.g. `{ "AAPL": 0.5, "MSFT": 0.5 }`.
    </ParamField>

    <ParamField body="<function_name>" type="object">
      Nested object matching `function`, with that function’s parameters (see catalog).
    </ParamField>
  </Expandable>
</ParamField>

***

## Example — weight dynamics

```json theme={null}
{
  "input_url": "https://stqsnpprod.blob.core.windows.net/data/portfolio_optimization_35c1b5239d23.json",
  "config": {
    "function": "dynamic_weights",
    "dynamic_weights": {
      "start": null,
      "end": null
    }
  }
}
```

## Example — copula density

```json theme={null}
{
  "input_url": "https://stqsnpprod.blob.core.windows.net/data/portfolio_optimization_35c1b5239d23.json",
  "config": {
    "function": "copula_density",
    "copula_density": {
      "copula": "gaussian",
      "asset1": "AAPL",
      "asset2": "MSFT"
    }
  }
}
```

***

## Returns

```json theme={null}
{
  "status": "Succeeded",
  "output_url": "https://stqsnpprod.blob.core.windows.net/data/risk_dynamic_weights_f1e2d3c4b5a6.html",
  "output_name": "risk_dynamic_weights_f1e2d3c4b5a6.html",
  "execution_name": "job-risk-worker-abc123xyz"
}
```

***

## Resources

| Resource           | Value                 |
| ------------------ | --------------------- |
| Container Apps Job | `job-risk-worker`     |
| Env vars injected  | `INPUT_URL`, `CONFIG` |
| Output blob prefix | `risk_`               |
