주식 트레이드 강화 전략 추가

This commit is contained in:
2026-02-17 01:38:35 +09:00
parent 9dbf6e6791
commit 4d41405ac4
6 changed files with 1352 additions and 434 deletions

View File

@@ -49,26 +49,38 @@ class MacroAnalyzer:
results[name] = {"price": 0, "change": 0}
# [신규] 시장 스트레스 지수(MSI) 추가
time.sleep(0.6) # MSI 계산 전 추가 대기
time.sleep(0.6)
kospi_stress = MacroAnalyzer.calculate_stress_index(kis_client, "0001")
results['MSI'] = kospi_stress
print(f" - Market Stress Index: {kospi_stress}")
if kospi_stress >= 50:
risk_score += 2 # 매우 위험
risk_score += 2
elif kospi_stress >= 30:
risk_score += 1 # 위험
risk_score += 1
# [v2.0] KOSPI/KOSDAQ 연동 위험도 (둘 다 하락 시 더 위험)
kospi_change = results.get('KOSPI', {}).get('change', 0)
kosdaq_change = results.get('KOSDAQ', {}).get('change', 0)
if kospi_change <= -1.0 and kosdaq_change <= -1.0:
risk_score += 1 # 양대 지수 동반 하락
print(f" ⚠️ Both KOSPI({kospi_change}%) & KOSDAQ({kosdaq_change}%) declining!")
# [v2.0] 급반등 감지 (전일 급락 후 반등 = 불안정)
if kospi_change >= 2.0 and kospi_stress >= 30:
risk_score = max(risk_score, 1) # 급반등이지만 스트레스 높으면 CAUTION 유지
print(f" 📈 Sharp rebound detected but MSI still elevated")
# 시장 상태 정의
status = "SAFE"
if risk_score >= 2:
status = "DANGER" # 매수 중단 권장
if risk_score >= 3:
status = "DANGER"
elif risk_score >= 1:
status = "CAUTION" # 보수적 매매
status = "CAUTION"
return {
"status": status,
"risk_score": risk_score,
"risk_score": risk_score,
"indicators": results
}