Σ
SDCalc
중급응용·12 min

시계열을 위한 이동 표준편차

시계열 분석에서 이동(롤링) 표준편차를 계산하고 해석하는 방법을 배워봅니다. 볼린저 밴드, 변동성 군집화, Python 코드 예시, 금융에서의 실전 응용을 다룹니다.

이동 표준편차란?

이동 표준편차(롤링 SD 또는 후행 변동성이라고도 합니다)는 슬라이딩 윈도우 기간에 대한 표준편차를 계산합니다. 모든 과거 데이터를 동등하게 사용하는 정적 표준편차와 달리, 이동 SD는 최근 관측에 초점을 맞추어 시간에 따른 변동성 변화를 감지하는 데 필수적입니다.

이 기법은 변동성이 일정하지 않은 금융 시장에서 핵심적입니다. 어떤 주식은 몇 달간 잠잠하다가 실적 발표나 시장 위기 때 갑자기 높은 변동성을 보일 수 있습니다. 이동 SD는 이런 역학을 실시간으로 포착합니다.

이동 SD가 중요한 이유

정적 표준편차는 모든 과거 데이터를 동등하게 취급하지만, 최근 변동성이 먼 과거보다 미래 변동성을 더 잘 예측하는 경우가 많습니다. 이동 SD는 변화하는 시장 상황에 적응하는 최신의 실행 가능한 위험 측도를 제공합니다.

롤링 표준편차 계산법

각 시점에서 이전 n개 데이터의 표준편차를 계산합니다. 시간이 지나면 윈도우가 이동하며, 항상 가장 최근의 n개 값을 사용합니다. 이렇게 하면 변동성 추정치의 시계열이 만들어집니다.

1

윈도우 정의

각 계산에 포함할 기간(예: 20일)을 선택합니다.
2

첫 번째 SD 계산

처음 n개 데이터의 표준편차를 계산합니다.
3

윈도우 이동

한 기간 앞으로 이동하고, 가장 오래된 값을 제거하고 최신 값을 추가합니다.
4

반복

데이터 끝까지 계속합니다.
python
import pandas as pd
import numpy as np

# Load your time series data
df = pd.read_csv('stock_prices.csv')

# 20-day rolling standard deviation
df['rolling_std_20'] = df['returns'].rolling(window=20).std()

# Annualized volatility (assuming daily returns)
df['annualized_vol'] = df['rolling_std_20'] * np.sqrt(252)

# Multiple windows for comparison
df['rolling_std_10'] = df['returns'].rolling(window=10).std()
df['rolling_std_50'] = df['returns'].rolling(window=50).std()

처음 (윈도우-1)개의 값은 최소 n개의 관측이 필요하므로 NaN이 됩니다. 실무에서는 min_periods 매개변수를 사용하여 더 적은 관측으로 조기에 계산을 시작할 수 있습니다.

적절한 윈도우 크기 선택

윈도우 크기는 반응성과 안정성 간의 상충관계를 만듭니다:

  • 짧은 윈도우 (5-10일):변동성 변화에 빠르게 반응하지만 노이즈가 많고 거짓 신호를 만들 수 있음
  • 중간 윈도우 (20-30일):반응성과 안정성의 균형; 20일은 볼린저 밴드의 업계 표준
  • 긴 윈도우 (50-100일):부드럽고 안정적이지만 체제 변화 감지가 느림; 추세 분석에 적합

꿀팁

여러 윈도우 크기를 함께 사용하세요. 10일, 20일, 50일 이동 SD를 비교하면 단기 변동과 장기 변동성 추세를 함께 파악할 수 있습니다. 이들 간의 괴리는 체제 변화를 시사할 수 있습니다.

실전 응용

이동 표준편차는 금융과 데이터 과학에서 폭넓게 활용됩니다:

  • 위험 관리:과거 평균이 아닌 최근 변동성을 사용하여 VaR(Value at Risk) 계산
  • 옵션 가격 결정:블랙-숄즈 등 모델의 내재 변동성 매개변수 추정
  • 포트폴리오 관리:현재 변동성에 따라 포지션 크기 조정; 변동성 급등 시 노출 축소
  • 이상 탐지:현재 변동성이 이동 평균에서 크게 벗어나는 비정상 기간 식별
  • 기술적 분석:볼린저 밴드, 켈트너 채널 등 변동성 기반 지표

볼린저 밴드 해설

볼린저 밴드는 이동 표준편차의 가장 유명한 응용입니다. 1980년대 존 볼린저가 개발했으며, 변동성에 적응하는 동적 포락선을 가격 주위에 생성합니다.

볼린저 밴드

Upper Band = SMA(20) + 2 × Moving SD(20) Lower Band = SMA(20) - 2 × Moving SD(20)

밴드는 변동성이 큰 기간에는 넓어지고, 안정적인 기간에는 좁아집니다. 트레이더들은 다음과 같이 활용합니다:

  • 가격이 밴드에 닿을 때 과매수/과매도 상태 식별
  • 돌파에 앞서는 “스퀴즈”(저변동성) 감지
  • 현재 시장 상황에 기반한 동적 손절선 설정

변동성 군집화

금융에서 가장 중요한 실증적 사실 중 하나는 변동성이 군집화된다는 것입니다—높은 변동성 뒤에 높은 변동성이, 낮은 변동성 뒤에 낮은 변동성이 따르는 경향이 있습니다. 이는 로버트 엥글(2003년 노벨상)이 ARCH 모델로 공식화했습니다.

이동 SD는 이 군집화를 시각적으로 드러냅니다. 시간에 따른 롤링 변동성을 그래프로 그리면, 무작위 변동이 아닌 고변동성과 저변동성의 명확한 체제가 보입니다. 이는 심대한 의미가 있습니다:

  • 예측 가능성:내일의 변동성은 오늘과 비슷할 가능성이 높음—위험을 예측할 수 있음
  • 위험 배분:고변동성 체제 진입 시 포지션 축소
  • 전략 선택:서로 다른 변동성 환경에서 다른 매매 전략이 더 잘 작동

중요 유의사항

변동성이 군집화되지만, 체제 변화는 갑작스럽고 극적일 수 있습니다. 주요 뉴스, 시장 붕괴, 정책 발표가 변동성 체제를 순식간에 바꿀 수 있습니다. 이동 SD는 이런 변화에 항상 지연됩니다—새로운 현실을 반영할 때쯤이면 체제가 다시 바뀌어 있을 수 있습니다.

Further Reading

How to Read This Article

A statistics tutorial is a practical interpretation guide, not just a formula dump. It refers to the assumptions, notation, and reporting language that analysts need when they explain a result to a teacher, manager, client, or reviewer. The article body covers the specific topic, while the sections below create a common interpretation frame that readers can reuse across related metrics.

Reading goalWhat to focus onCommon mistake
DefinitionWhat the metric is and what quantity it summarizesTreating the formula as self-explanatory
Formula choiceSample versus population assumptions and notationUsing n when n-1 is required or vice versa
InterpretationWhether the result indicates concentration, spread, or riskCalling a large value good or bad without context

Frequently Asked Questions

How should I interpret a high standard deviation?

A high standard deviation means the observations are spread farther from the mean on average. Whether that spread is acceptable depends on the context: wide dispersion might signal risk in finance, instability in manufacturing, or genuine natural variation in scientific data.

Why do some articles mention n while others mention n-1?

The denominator reflects the difference between population and sample formulas. Population variance and population standard deviation use N because the full dataset is known. Sample variance and sample standard deviation often use n-1 because Bessel’s correction reduces bias when estimating population spread from a sample.

What is a statistical interpretation guide?

A statistical interpretation guide is a page that moves beyond arithmetic and explains meaning. It tells you what a metric is, when the formula applies, and how to describe the result in plain English without overstating certainty.

Can I cite this article in a report?

You should cite the underlying authoritative reference for formal work whenever possible. This page is best used as an explanatory bridge that helps you understand the concept before quoting the original standard or handbook.

Why include direct citations on every article page?

Direct citations give readers a route to verify the definition, notation, and assumptions. That improves trust and reduces the chance that a simplified explanation is mistaken for the entire technical standard.

Authoritative References

These sources define the concepts referenced most often across our articles. Bessel's correction is a sample adjustment, variance is a squared measure of spread, and standard deviation is the square root of variance expressed in the same units as the data.