Systemicbeta

Standard Deviation

systemic:core-stdevStatistics

Inputs

NameTypeDescription
DataNumber seriesThe series of numbers over which the cumulative standard deviation is computed.

Outputs

NameTypeDescription
StDevNumber seriesThe cumulative (expanding) standard deviation: each bar covers all data from the start of the series up to that bar.

Cost

7
credits per run
1,000
bars

0.198 + 0.00582·n credits for n bars, rounded up. The marks are each plan's limit of bars.

The Standard Deviation module measures how far the values of a series spread around their mean. It does not use a rolling window. It produces an expanding (cumulative) standard deviation: each output value covers all values from the start of the series up to that bar.

σn=1n∑i=1n(xi−xˉn)2\sigma_n = \sqrt{\frac{1}{n}\sum_{i=1}^{n}(x_i - \bar{x}_n)^2}

Where:

  • xix_i is the ii-th value
  • xˉn\bar{x}_n is the mean of the first nn values
  • σn\sigma_n is the standard deviation at bar nn

Why Cumulative (Expanding) Standard Deviation?

Most traders know the rolling standard deviation: a fixed window that slides forward. This module is different: at each bar, it measures how spread out all data so far has been.

flowchart LR
    subgraph Rolling["Rolling StDev (Window = 3)"]
        R1["Point 5: uses points 3-5"]
        R2["Point 6: uses points 4-6"]
        R3["Point 7: uses points 5-7"]
    end
    
    subgraph Expanding["Cumulative StDev (This Module)"]
        E1["Point 5: uses points 1-5"]
        E2["Point 6: uses points 1-6"]
        E3["Point 7: uses points 1-7"]
    end
ApproachBehaviorBest For
RollingFixed memory, forgets old dataShort-term volatility signals
CumulativeNever forgets, stabilizes over timeHistorical context, regime detection

The cumulative approach answers: "How volatile has this asset been since the start of the series?"


How It Works

flowchart TD
    subgraph Input["Input Data"]
        P["Series of Values (prices, returns, indicators)"]
    end
    
    subgraph Process["At Each Point n"]
        M["Calculate cumulative mean of points 1...n"]
        D["Compute squared deviations from mean"]
        V["Average the squared deviations"]
        S["Take square root → σ_n"]
    end
    
    subgraph Output["Output Series"]
        SD["σ_2, σ_3, ... σ_n"]
    end
    
    P --> M --> D --> V --> S --> SD

Key property: Early output values move more. As data accumulates, the cumulative standard deviation settles toward the long-term volatility.


Real-World Volatility Comparison

Different assets have very different volatility. Using daily return data from June–December 2024:

AssetDaily StDev (σ)Annualized Volatility
SPY (S&P 500 ETF)0.85%~13.4%
GLD (Gold ETF)1.02%~16.1%
NVDA (Nvidia)3.32%~52.7%
BTC (Bitcoin)3.73%~59.3%

Annualized volatility = Daily σ × √252 (trading days per year)

This shows why position sizing and risk management cannot be the same for every asset: the same dollar amount in BTC carries roughly 4× the volatility of SPY.


Interpreting the Output

STDEV BehaviorWhat It Means
High valuesWide price swings; the asset is hard to predict
Low valuesValues stay close to the mean; stable behavior
Rising over timeRecent data is more volatile than earlier data
Falling / stabilizingThe asset is settling into a consistent range

The Stabilization Effect

Because the calculation is cumulative, one volatile bar early in the series has a large effect. As the series grows, the effect of that bar shrinks.

xychart-beta
    title "Cumulative StDev Stabilization (Conceptual)"
    x-axis "Data Points" [10, 50, 100, 200, 500]
    y-axis "σ Sensitivity to New Point" 0 --> 15
    line "Impact of One Outlier (%)" [10, 4, 2.5, 1.5, 0.8]

Trading Applications

1. Volatility Regime Detection

The cumulative standard deviation is a baseline for "normal" volatility. When short-term volatility (from another module) is far above this baseline, the market may be entering a new regime.

ConditionInterpretation
Short-term σ >> Cumulative σMarket stress or breakout
Short-term σ ≈ Cumulative σNormal conditions
Short-term σ << Cumulative σUnusual calm; potential squeeze

2. Risk-Adjusted Position Sizing

A basic principle: the higher the volatility, the smaller the position.

Position Size=Risk Budgetσ×Entry Price\text{Position Size} = \frac{\text{Risk Budget}}{\sigma \times \text{Entry Price}}

For a $10,000 portfolio risking 2% per trade ($200), with an asset priced at $100 and σ = 3%:

Shares=2000.03×100=66.67≈66 shares\text{Shares} = \frac{200}{0.03 \times 100} = 66.67 \approx 66 \text{ shares}

Higher volatility → fewer shares. This keeps the dollar risk similar across assets.

3. Historical Volatility Benchmarking

Comparing cumulative volatility across different date ranges helps to find structural changes:

  • "Is this asset more volatile in 2024 than it was in 2020-2023?"
  • "Has volatility permanently shifted after a major event?"

Combining with Other Modules

Standard deviation is rarely used alone. Consider these combinations:

CombinationPurpose
STDEV + Moving AverageBuild custom bands in the style of Bollinger Bands
STDEV + PercentileRank current volatility vs. history
STDEV ÷ Mean (with Divide)Coefficient of Variation: normalized volatility
Price − Mean (with Subtract), then ÷ STDEVZ-Score: how many σ the price is from the mean

Missing Data

A bar with no value (closed market, data gap, or an empty value from an earlier module) is never treated as zero:

  • The output on a missing bar is empty. No earlier value is carried forward
  • Missing bars are skipped, not filled with zero: the calculation continues at the next bar that has a value
  • The output is also empty on the first bar that has a value, because one value has no spread. It becomes a number once at least 2 bars have a value

Limitations to Consider

LimitationImplication
Lagging indicatorBased only on historical data; cannot predict future volatility
Assumes stationarityIf the asset's behavior changes fundamentally, old data may mislead
Sensitive to outliersExtreme values (especially early in the series) have a large effect
Not directionalA 5% gain and a 5% loss add equally to volatility

The Bigger Picture: Volatility in Markets

Standard deviation is a cornerstone of modern finance. It is the basis of:

Measuring volatility is not only about avoiding risk. It is about pricing risk correctly and finding cases where the market has mispriced it.


Further Reading

Rendering diagrams...
© 2026 WanoLabs. All rights reservedBeta v0.1.5