> ## 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.

# Volatility Scaling Lab Server

> Volatility targeting, EWMA volatility, Monte Carlo bands, and risk diagnostics.

## Overview

The Volatility Scaling Lab Server supports volatility-scaling research workflows: EWMA volatility estimation, volatility-targeting data preparation, Monte Carlo band analysis, and performance/risk diagnostics.

## Connection

Add this server to your MCP client configuration.

<Tabs>
  <Tab title="Cursor">
    ```json theme={null}
    {
      "mcpServers": {
        "volatility-scaling-lab": {
          "url": "https://volatility-scaling-lab-production.up.railway.app/mcp/qca-open-loop-volatility"
        }
      }
    }
    ```
  </Tab>

  <Tab title="Bearer auth">
    ```json theme={null}
    {
      "mcpServers": {
        "volatility-scaling-lab": {
          "url": "https://volatility-scaling-lab-production.up.railway.app/mcp/qca-open-loop-volatility",
          "headers": {
            "Authorization": "Bearer ${env:VOLATILITY_SCALING_LAB_MCP_TOKEN}"
          }
        }
      }
    }
    ```
  </Tab>
</Tabs>

Restart the client after changing MCP configuration. The server tools appear automatically after the connection is established.

## Transport

| Property         | Value                                                                                   |
| ---------------- | --------------------------------------------------------------------------------------- |
| Protocol         | MCP over Streamable HTTP                                                                |
| MCP URL          | `https://volatility-scaling-lab-production.up.railway.app/mcp/qca-open-loop-volatility` |
| Health URL       | `https://volatility-scaling-lab-production.up.railway.app/health`                       |
| MCP path         | `/mcp/qca-open-loop-volatility`                                                         |
| Request envelope | `{"request": {...}}`                                                                    |
| Auth             | Optional bearer token when enabled for the endpoint                                     |

## Best-Fit Workflows

* Load market and risk-free data for a ticker/date range.
* Compute EWMA volatility from returns or from ticker/date input.
* Analyze Monte Carlo percentiles and band widths.
* Compare a strategy volatility path against Monte Carlo confidence bands.
* Compute return, volatility, Sharpe, drawdown, and tracking-error metrics.

## Recommended Tools

* compute-ewma-volatility-series
* load-and-prepare-data
* analyze-monte-carlo-results
* compare-strategy-to-monte-carlo
* compute-annualized-return
* compute-annualized-volatility
* compute-sharpe-ratio

## Tools

| Tool                                              | Description                                                                                                                                                                                                                                                                                                                                                                                 | Returns                                                                                                                   |                |
| ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | -------------- |
| `dual-ewmaestimator-update`                       | Updates the dual exponential weighted moving average (EWMA) estimator for volatility calculations using risky and index return values. Params: r\_risky: float (risky asset return), r\_index: float (index return)                                                                                                                                                                         | `Any`                                                                                                                     |                |
| `ewmavolatility-estimator-update`                 | Updates an EWMA volatility estimator with a new return value, computing the exponentially weighted moving average volatility. Params: return\_value (float): the latest return value to incorporate into the volatility estimate                                                                                                                                                            | `Any`                                                                                                                     |                |
| `ewmavolatility-estimator-reset`                  | Resets the EWMA volatility estimator to its initial state, clearing any accumulated data and starting fresh. Params: none                                                                                                                                                                                                                                                                   | `Any`                                                                                                                     |                |
| `ewmavolatility-estimator-get-current-volatility` | Retrieves the current EWMA volatility estimate from the volatility estimator. Params: No parameters.                                                                                                                                                                                                                                                                                        | `Any`                                                                                                                     |                |
| `dual-ewmaestimator-reset`                        | Resets the internal state of the DualEWMAEstimator volatility estimator. Params: none                                                                                                                                                                                                                                                                                                       | `Any`                                                                                                                     |                |
| `dual-ewmaestimator-get-current-volatilities`     | Returns the current volatility estimates calculated by the DualEWMA estimator. Params: none                                                                                                                                                                                                                                                                                                 | `Any`                                                                                                                     |                |
| `compute-volatility-tracking-error`               | Computes annualized volatility tracking error by measuring the mean absolute difference between daily volatility estimates and a target volatility, scaled by the square root of trading periods per year. Params: sigma\_hat\_index (np.ndarray): daily volatility estimates; sigma\_target (float): target daily volatility; periods\_per\_year (int, default=252): trading days per year | `float`                                                                                                                   |                |
| `compute-annualized-return`                       | Calculates annualized return from daily returns using either arithmetic mean or geometric (CAGR) method. Params: Inputs: returns (np.ndarray of daily returns), periods\_per\_year (int, default 252 trading days), method ('arithmetic' or 'geometric')                                                                                                                                    | `float`                                                                                                                   |                |
| `compute-annualized-volatility`                   | Compute annualized volatility from daily returns. Takes an array of daily returns and returns a single float representing the annualized volatility, scaled by the number of trading days per year. Params: returns: np.ndarray (daily returns), periods\_per\_year: int (default=252)                                                                                                      | `float`                                                                                                                   |                |
| `compute-sharpe-ratio`                            | Computes the Sharpe ratio from daily returns by annualizing return and volatility. Returns a float ratio without risk-free rate subtraction. Params: returns (np.ndarray): daily returns array; periods\_per\_year (int, default=252): trading days per year                                                                                                                                | `float`                                                                                                                   |                |
| `compute-maximum-drawdown`                        | Computes the maximum drawdown of a cumulative return series, returning the largest peak-to-trough decline as a positive percentage (e.g., 0.55 for 55% drawdown). Params: cumulative\_returns: np.ndarray - cumulative return series starting at 1.0 (e.g., np.array(\[1.0, 1.05, 0.98]))                                                                                                   | `float`                                                                                                                   |                |
| `metrics-to-dataframe`                            | Converts a dictionary of strategy metrics into a comparison DataFrame, organizing strategies as rows and metrics as columns. Params: metrics\_dict: Dictionary mapping strategy names to their metrics (e.g., \{'Strategy A': \{'Sharpe Ratio': 1.2, 'Volatility': 0.05}})                                                                                                                  | `pd.DataFrame`                                                                                                            |                |
| `load-and-prepare-data`                           | Loads and prepares financial data for backtesting, including asset prices and risk-free rates, aligned to a trading calendar and transformed into returns. Params: start\_date (str, default '2000-06-06'), end\_date (str                                                                                                                                                                  | None, defaults to today when omitted), cash\_rate\_convention (str, default 'calendar\_day'), ticker (str, default 'IVV') | `pd.DataFrame` |
| `compute-ewma-volatility-series`                  | Compute the EWMA volatility series for returns. Accepts direct returns, tabular/stored payloads with return\_column, or ticker + date range to load data inside the tool. Params: halflife (default 126), annualize (default true), periods\_per\_year (default 252).                                                                                                                       | `pd.DataFrame`                                                                                                            |                |
| `analyze-monte-carlo-results`                     | Analyze Monte Carlo simulation results to compute summary statistics including final, steady-state, and early-period percentiles and band widths. Params: df: pd.DataFrame - simulation results (required)                                                                                                                                                                                  | `Dict[str, float]`                                                                                                        |                |
| `compare-strategy-to-monte-carlo`                 | Compares a strategy's running annualized volatility to Monte Carlo confidence bands and returns key statistics. Params: strategy\_sigma\_hat\_ann: np.ndarray of strategy's volatility estimates; mc\_df: pd.DataFrame with p10, p50, p90 columns                                                                                                                                           | `Dict[str, float]`                                                                                                        |                |
| `plot-cumulative-returns`                         | Generates a line plot comparing cumulative returns across multiple trading strategies over time. Saves the figure if a path is provided. Params: Inputs: results\_dict (dict of strategy name to DataFrame), save\_path (optional save location), title (plot title, default: 'Cumulative Returns Comparison')                                                                              | `None`                                                                                                                    |                |
| `plot-weights`                                    | Plots strategy weights over time from a DataFrame, showing risky and cash allocations with optional title and saving capability. Params: Inputs: results\_df (pd.DataFrame with 'w' and 'c' columns), strategy\_name (optional title), save\_path (optional save location)                                                                                                                  | `None`                                                                                                                    |                |
| `plot-controller-states`                          | Generates a plot showing controller states (kappa) over time from a results DataFrame, with optional leverage controller visualization. Params: results\_df (pd.DataFrame): DataFrame containing 'kappa' and optional 'kappa\_lev' columns; strategy\_name (str): Strategy name for plot title; save\_path (Optional\[str]): Path to save the figure                                        | `None`                                                                                                                    |                |
| `plot-drawdown`                                   | Generates a drawdown plot comparing multiple trading strategies over time, showing percentage drawdowns from running maximums. Params: Inputs: results\_dict (dict of strategy names to DataFrames with 'R\_index' column), save\_path (optional path to save figure), title (plot title, default 'Drawdown Comparison')                                                                    | `None`                                                                                                                    |                |
| `create-metrics-table-markdown`                   | Generates a markdown table summarizing performance metrics for different strategies and saves it to a file. Params: metrics\_dict: Dict\[str, Dict\[str, float]] - strategy metrics (e.g., \{'Strategy A': \{'Sharpe Ratio': 1.2, 'Win Rate': 0.65}}); filename: str - output path (default: 'results/metrics\_table.md')                                                                   | `None`                                                                                                                    |                |

## Examples

### Compute EWMA volatility from market data

```json theme={null}
{
  "request": {
    "ticker": "SPY",
    "start_date": "2020-01-01",
    "halflife": 252,
    "annualize": true
  }
}
```

### Load aligned market and cash-rate data

```json theme={null}
{
  "request": {
    "ticker": "SPY",
    "start_date": "2020-01-01",
    "cash_rate_convention": "calendar_day"
  }
}
```

### Analyze Monte Carlo output

```json theme={null}
{
  "request": {
    "df": {
      "rows": [
        {
          "step": 1,
          "p10": 0.1,
          "p50": 0.15,
          "p90": 0.2,
          "target": 0.15
        },
        {
          "step": 2,
          "p10": 0.11,
          "p50": 0.15,
          "p90": 0.19,
          "target": 0.15
        }
      ]
    }
  }
}
```

## Notes

* `compute-ewma-volatility-series` is the preferred one-step tool for requests that start from a ticker and date range.
* When `end_date` is omitted, data-loading tools use the current date on the server.
* Large tabular outputs can be returned as result handles.

<CardGroup cols={2}>
  <Card title="Client setup" icon="plug" href="/quantx/servers/deployed/client-setup">
    Configure this endpoint in Cursor, Claude Desktop, or a generic MCP client.
  </Card>

  <Card title="Shared tools" icon="wrench" href="/quantx/servers/deployed/shared-tools">
    Use health, result, artifact, environment, and table helper tools.
  </Card>
</CardGroup>

## Other Servers

<CardGroup cols={3}>
  <Card title="Dataloader" icon="server" href="/quantx/servers/dataloader">
    Market-data retrieval, TA-Lib indicators, and dataframe exports.
  </Card>

  <Card title="Fama-French Replicate" icon="server" href="/quantx/servers/fama-french-replicate">
    Official and replicated Fama-French factors plus loadings and alpha estimation.
  </Card>

  <Card title="Statistical Factor Models" icon="server" href="/quantx/servers/statistical-factor-models">
    Stock-Watson, complete-panel, and dynamic statistical factor extraction.
  </Card>

  <Card title="Jump Models" icon="server" href="/quantx/servers/jump-models">
    JumpModel and SparseJumpModel regime fitting, online prediction, and backtesting.
  </Card>

  <Card title="Wavelet Mean Reversion" icon="server" href="/quantx/servers/wavelet-mean-reversion">
    Wavelet-based mean reversion analysis for financial time series.
  </Card>

  <Card title="Parallax ExtremeHurst" icon="server" href="/quantx/servers/parallax-extreme-hurst">
    ExtremeHurst signal generation from OHLCV data.
  </Card>

  <Card title="EP Ratio Screener" icon="server" href="/quantx/servers/ep-ratio-screener">
    Fundamental stock screening based on earnings yield and balance-sheet quality.
  </Card>
</CardGroup>
