# CPCV validation

`POST https://firm.wealthnow.io/api/v3/validation/cpcv`

- Plan: Starter and up
- Price: 3 credits per call (failed requests are free)
- MCP tool: `cpcv`
- Source: https://app.wealthnow.io/docs/reference/cpcv

Subsample Sharpe dispersion over the combinatorial group splits of CPCV (AFML Ch. 12) on a return series you POST: the series is cut into n_groups time blocks and the Sharpe of every k-block subset is reported (n_splits = C(n_groups, k); n_paths = AFML's backtest-path count, k/n_groups x C(n_groups, k)). Nothing is refit, so it is NOT an out-of-sample test and cannot detect overfitting or selection bias: a series picked as the best of many backtests scores about its in-sample Sharpe here too. Call it when the user asks how stable a return series' Sharpe is across time; to ask whether a Sharpe is real or a multiple-testing artifact, use deflated_sharpe with the number of trials.

## Body (application/json)

| Field | Type | Required | Description |
|---|---|---|---|
| `returns` | array of number | yes | Flat per-period return series, at least max(3 x n_groups, 100) returns. |
| `n_groups` | integer | no | Time blocks the series is cut into. Default `10`. Range 3 to 20. |
| `embargo_days` | integer | no | Returns dropped at the start of each block; below the block size, len(returns) // n_groups. Default `5`. Range 0 to …. |
| `k` | integer | no | Blocks per subset, at most n_groups - 1; C(n_groups, k), the subsets scored, may be at most 2,000 per call. Default `2`. Range 2 to 19. |
| `annualisation` | number | no | Periods per year of the returns (252 daily, 52 weekly, 12 monthly) Default `252`. Range … to 525600. |

## Example request

```bash
curl -X POST "https://firm.wealthnow.io/api/v3/validation/cpcv" \
  -H "Authorization: Bearer $WEALTHNOW_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "returns": [
      0.0007, 0.012, -0.0018, -0.0059, 0.0026, 0.0009,
      0.0031, 0.0049, -0.0074, -0.0038, 0.0122, 0.0024,
      -0.0093, 0.0015, 0.0049, 0.0004, 0.0033, -0.003,
      -0.006, 0.0093, 0.007, -0.0099, -0.0023, 0.0085,
      0.0009, -0.0005, 0.0002, -0.0049, 0.0047, 0.0096,
      -0.0073, -0.007, 0.0095, 0.0043, -0.0043, 0.0004,
      -0.0013, 0.0011, 0.009, -0.0027, -0.0099, 0.0073,
      0.0089, -0.0058, -0.0025, 0.0027, 0.0002, 0.0056,
      0.0014, -0.0097, 0.0028, 0.0121, -0.0039, -0.0069,
      0.0046, 0.0026, 0.0015, 0.0029, -0.0065, -0.0016,
      0.0123, 0.0004, -0.0103, 0.0033, 0.0067, -0.001,
      0.0011, -0.0023, -0.0037, 0.0093, 0.005, -0.0109,
      -0.0007, 0.0103, -0.0002, -0.0029, 0.0007, -0.0025,
      0.0049, 0.0075, -0.0083, -0.0054, 0.0113, 0.0034,
      -0.0066, 0.0006, 0.0012, 0.0015, 0.0068, -0.0038,
      -0.0083, 0.009, 0.008, -0.008, -0.0025, 0.0051,
      0.0009, 0.0034, 0.0001, -0.008, 0.0045, 0.0113,
      -0.0061, -0.007, 0.0069, 0.0034, -0.0007, 0.0014,
      -0.0049, 0.0002, 0.0114, -0.0017, -0.0105, 0.0055,
      0.0078, -0.0029, -0.0006, -0.0007, -0.0016, 0.0085
    ],
    "n_groups": 10,
    "k": 2,
    "embargo_days": 5
  }'
```

## Errors

| Status | Code | Meaning |
|---|---|---|
| 400 | `invalid_ticker` | The request is malformed, for example a ticker that is not a symbol: `invalid_ticker`, refused before any credit is reserved, with `param` naming the parameter. Not billed. |
| 401 | `unauthorized` | Missing or invalid API key. |
| 402 | `plan_required` | Your plan does not include this tool, you are out of credits, or your workspace's spend cap paused its keys. `plan_required` names the plan that unlocks the tool; `usage_exceeded` means the credit balance is spent; `spend_cap_reached` means the key is paused until the cap resets or is raised: `detail` names the cap and the reset, `cap_usd` and `resets_at` (ISO 8601) carry them, and `doc_url` links pricing and credits. Not billed. |
| 403 | `scope_denied` | This API key is limited to some products and this tool is not one of them. `product` names the tool's product and `scopes` the key's products. An upgrade does not change it: use a key whose scopes include the product, or change this key's scopes. Not billed. |
| 404 | `not_found` | No such resource. Not billed. |
| 422 | `validation` | A parameter is missing, out of range or the wrong type; `param` names it. Not billed. |
| 429 | `rate_limited` | Your plan's rate limit is spent for this window. Retry after `Retry-After` seconds. Not billed. |
| 503 | `paid_data_unavailable` | The data could not be served completely right now; retry later. Not billed. |
| 504 | `request_timeout` | The request ran past the server's time budget; retry. Not billed. |
