Files
민헌andClaude Fable 5 dfb9ad6e66 초기 커밋 — 협상 AI 에이전트 정본: 엔진·데모 콘솔·측정 인프라·증빙
- server/: FastAPI 협상 엔진 (5라운드, Q-Table/UCB, 페르소나 계측, :53117)
- frontend/: 데모 콘솔 (React+Tailwind → nginx, /api 프록시)
- eval/·testdata/: 지표 8종 측정 하네스 + 재현 가능 테스트셋
- results/: 측정 증빙 (지표별 result+provenance, raw 원본 동결+SHA256)
  ① 86.0 · ② 76.0 · ③ 5.99% · ⑥ p95 3.61ms · ⑦ 611만/년 · ⑧ 91/100 · ⑨ 99.71 · ⑩ 97.99
- docker-compose.yml + run.sh: backend+frontend 일괄 기동

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0112XUWF4bc3gGrEt8vsYCzy
2026-08-31 13:09:52 +09:00

72 lines
2.8 KiB
Python

"""3구간 가격 지표 — Price(P), Anchor(A), Target(T) 기반 점수(1~99).
⑩ 실시간 페르소나 정확도의 긴장도(Tension) 계측 근거이기도 하다.
"""
import math
from typing import Optional
from pydantic import BaseModel
from common.enums import IndicatorRangeEnum, IndicatorType
class IndicatorResponse(BaseModel):
indicator_type: IndicatorType
indicator_value: int
indicator_range: IndicatorRangeEnum
class ThreeSegIndicator:
"""3-Segment Indicator — 구간별 점수 산출."""
def _case1(self, anchoring_price: int, current_price: int,
target_price: int) -> Optional[IndicatorResponse]:
"""Case 1: Optimal Zone (PZ1) — P ≤ A, 점수 99 고정."""
if anchoring_price >= current_price:
return IndicatorResponse(
indicator_type=IndicatorType.PERCENT_DETAIL,
indicator_value=99,
indicator_range=IndicatorRangeEnum.PZ1,
)
return None
def _case2(self, anchoring_price: int, current_price: int,
target_price: int) -> Optional[IndicatorResponse]:
"""Case 2: Negotiable Zone (PZ2) — A < P < T, 99→80 선형 보간."""
if anchoring_price < current_price < target_price:
percent = int(math.floor(
99 - ((current_price - anchoring_price)
/ (target_price - anchoring_price) * 19)))
return IndicatorResponse(
indicator_type=IndicatorType.PERCENT_DETAIL,
indicator_value=percent,
indicator_range=IndicatorRangeEnum.PZ2,
)
return None
def _case3(self, anchoring_price: int, current_price: int,
target_price: int) -> Optional[IndicatorResponse]:
"""Case 3: Target Exceeded Zone (PZ3) — P ≥ T, 79에서 지수 감쇠."""
if target_price <= current_price:
scale_exponent = int(math.floor(math.log10(target_price)))
k = math.pow(10, -scale_exponent)
exponent = -k * (current_price - target_price)
raw_score = 79 * math.exp(exponent)
percent = max(1, int(math.floor(raw_score)))
return IndicatorResponse(
indicator_type=IndicatorType.PERCENT_DETAIL,
indicator_value=percent,
indicator_range=IndicatorRangeEnum.PZ3,
)
return None
def calculate(self, anchoring_price: int, current_price: int,
target_price: int) -> Optional[IndicatorResponse]:
ret = [
self._case1(anchoring_price, current_price, target_price),
self._case2(anchoring_price, current_price, target_price),
self._case3(anchoring_price, current_price, target_price),
]
return next((r for r in ret if r is not None), None)