이 스킬
시장 narrative regime + Pettitt change-point
시장 (KR/US) lookback 90 일 buildNarrativePulse 결과의 daily sentiment_mean 시계열에 Pettitt 1979 non-parametric change-point test 적용. regime shift 일자 자동 검출 + Mann-Whitney U_k 통계량 + exp 근사 p-value 의 유의성 검정. regime_label = score 평균 5 단 (긍정 / 약긍정 / 혼조 / 약부정 / 부정). topic group_by volume_total desc top N. 트리거 — '시장 regime 전환', 'narrative regime', 'Pettitt change-point'.
이어 가기
절차
실행 순서
- 1
Pettitt 는 *one change* 검정 — multiple shifts 는 binary search 또는 sliding window 별도 필요.
- 2
p-value 가 exp 근사식 (small n 부정확). n ≥ 60 권장.
- 3
volume-weighted 가 noise topic (자동 재배포) 에 민감 — Phase C `repeatedHeadlineFrequency` 보정 권장.
예시
이런 질문이 들어오면 이 skill 을 쓴다
- KR 시장 narrative 90 일 regime + shift 일자
- 최근 시장 sentiment 부정 → 긍정 전환 일자
- 시장 hot topic top 5 (반도체/배터리/...) volume 비중
출력
기대 결과
- regime_label / regime_score (volume-weighted daily mean)
- regime_shift_date / regime_shift_significant (p<0.05)
- pettitt_U / pettitt_pvalue
- topics_hot (list[topic_label, volume_total, sentiment_mean])
공개 호출 방식
from dartlab.scan.narrativeRegime import scanNarrativeRegime
result = scanNarrativeRegime(
market="KR",
lookbackDays=90,
changePointThreshold=0.05,
topTopics=5,
)
print(f"regime: {result['regime_label']} (score={result['regime_score']})")
print(f"shift: {result['regime_shift_date']} (p={result['pettitt_pvalue']})")
print("hot topics:")
for t in result["topics_hot"]:
print(f" {t['topic_label']}: volume={t['volume_total']}, mean={t['sentiment_mean']:.2f}") 출력 schema
| key | 의미 |
|---|---|
regime_label | 5 단 (긍정/약긍정/혼조/약부정/부정) |
regime_score | volume-weighted daily mean (-1~+1) |
regime_shift_date | Pettitt U_k argmax 일자 |
regime_shift_significant | p < threshold 유의 |
pettitt_U / pettitt_pvalue | Mann-Whitney U_k + exp 근사 |
topics_hot | volume desc top N |
L6 UI 차트 연동
/analysis/$code/events (PriceEventChart) 가 본 결과의 regime_shift_date ~ end 구간을 반투명 배경 band 로 차트에 표시 (showRegime=True toggle).
한계
- Pettitt 는 one change 검정 — multiple shifts 는 binary search 또는 sliding window 별도 필요.
- p-value 가 exp 근사식 (small n 부정확). n ≥ 60 권장.
- volume-weighted 가 noise topic (자동 재배포) 에 민감 — Phase C
repeatedHeadlineFrequency보정 권장.
연계 절차
- 본 recipe → news 내러티브 sentiment/topic pulse regime shift 검출.
engines.macro내러티브 축 +engines.scan전종목 신호와 결합.- regime shift 종목 →
recipes.sentiment.newsSentimentFactor로 팩터화. recipes.macro.qualityMacroBeta와 결합해 매크로 베타 민감도 점검.
런타임
실행 환경별 호환성
| 환경 | 상태 | 비고 / 제한 |
|---|---|---|
| Local Python | supported | · |
| Server | supported | · |
| MCP | supported | · |
| Web AI | limited | · |
| Pyodide | limited | · |
실패 회피
흔한 실패 · 절대 금지
- narrativePulse 빌드 0 행 (Phase A/B 미실행)
- 90 일 < 10 일 분산 (휴장·신규 시장)
- Pettitt p-value 근사식 small-n 부정확
- change-point shift_date 를 사건 원인 단정 금지
- n_days < 10 에서 regime 단정 금지