---
title: "Clustering"
description: "Clustering is a risk rule that groups days by how a series moved recently and switches to Risk-Off whenever a day falls in the most volatile group."
canonical_url: "https://fincanva.com/docs/strategies/clustering"
last_updated: "2026-09-24"
md_url: "https://fincanva.com/docs/strategies/clustering.md"
---

# Clustering

Clustering is a quantitative risk rule that sorts days into groups according to how one series has moved over a recent window — how much and in which direction — and switches the strategy to its Risk-Off allocation on every day that falls in the most volatile group. It gives no probability: each day either is in the turbulent group or is not. It is one of the three rules in the **Quantitative regimes** group of the risk condition builder, where the app describes it as "Groups days by how the market has moved recently. It decides yes or no, with no probability: if the day falls in the turbulent group, you move to Risk-Off."

**Also seen as:** k-means clustering, regime clustering, k-means regimes

## How does a clustering rule decide which days are turbulent?

A clustering rule describes each day by a small set of numbers measured over the observation window, then lets a k-means algorithm find the groups those days naturally form. Each day belongs to the group whose centre it sits closest to:

$$
c(t) = \arg\min_{k}\; \lVert x_t - \mu_k \rVert
\qquad\qquad
\text{Risk-Off when}\quad c(t) = k_{\text{turbulent}}
$$

where $x_t$ describes how much and in which direction the series moved over the window ending on day $t$, $\mu_k$ is the centre of group $k$, $c(t)$ is the group day $t$ is assigned to, and $k_{\text{turbulent}}$ is the group with the highest volatility. In words: the strategy runs Risk-Off on exactly the days that look most like the most volatile stretch of the series' history.

## How is clustering different from Hidden regimes (Markov)?

Both rules learn regimes from one series, and they answer differently. [Hidden regimes (Markov)](/docs/strategies/hidden-regimes-markov) gives a probability and lets you set how sure it must be; Clustering gives a yes or no, so there is no threshold to set. Clustering also has no notion of how long a regime tends to last — each day is judged on its own window — so on a series that swings in and out of volatility it can switch more often, and the [confirmation delay](/docs/strategies/confirmation-delay) matters more.

## How does Fincanva handle it?

- **The series** is any instrument you pick under **Instrument**; a new rule starts on the S&P 500. There is no indicator, operator or pair of thresholds to set, unlike a Single series or Double series condition — see [condition types](/docs/strategies/condition-types).
- **Observation window (trading days)** runs from 10 to 63, default 21; the app's note: "How many days to look at to describe each day. 21 ≈ 1 month."
- **Number of regimes** is 2 or 3, default 2 ("How many groups of days the model looks for."). Whichever you pick, **only the most volatile group is Risk-Off**; with 3, the middle group stays Risk-On.
- **The rule uses only history available on each day.** The groups are recalibrated as the backtest moves forward, and a day is never assigned using data from after it.
- **It stays Risk-On until it has enough history to learn from**, and it stays Risk-On when the groups it finds are too alike in volatility to tell apart.
- **One decision, no hysteresis.** The [confirmation delay](/docs/strategies/confirmation-delay) is the brake against [whipsaw](/docs/strategies/whipsaw); the app's hint on that field reads "This rule has a single threshold: the delay is your brake against switching too often. 0 = immediate." **Auto-rebalance** works as it does on any condition.
- **Clustering is included from the Advanced plan**, at the strategy level and inside a Combined alike; Free and Starter do not offer it. See [what each plan includes](/docs/account-security/what-each-plan-includes).
- In the list of risk conditions a saved rule shows "Clustering" with its series, "turbulent group" as its comparison, and its regime count and window, such as "2 regimes" and "21-day window".

## What does it look like in practice?

You add a Clustering rule on a broad equity index with the default 21-day window and 2 regimes. Most days of the index's history sit in a calm group — small daily moves, drifting up — and a minority sit in a turbulent group of large moves, mostly down. For months each new day lands in the calm group and the strategy stays Risk-On.

A sell-off starts: over three weeks the 21-day window fills with large down days, and on the day its description moves closer to the turbulent group's centre than to the calm one's, the rule asks for Risk-Off. When the window has rolled past the sell-off and new days land back in the calm group, it asks for Risk-On again. With a 10-day window the same sell-off would register sooner, and brief shocks would register too; with 63 days it would register later and hold longer. The figures are illustrative, not a suggested setting.

Fincanva is for education and illustration only. It is not personalised financial advice, and past or simulated results do not predict future ones. [Read the Terms Addendum](https://fincanva.com/terms/addendum#section-3)
