feat(signal_v2): foundation — config + state + requirements
- signal_v2/config.py: Settings dataclass loading web-ai/.env explicitly - signal_v2/state.py: PollState dataclass + module-level singleton - requirements.txt: httpx / fastapi / uvicorn / pytest-asyncio / respx - .gitignore: signal_v2/data/*.db (WAL/SHM) - empty tests/ marker Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -59,3 +59,7 @@ Desktop.ini
|
|||||||
KIS_SETUP.md
|
KIS_SETUP.md
|
||||||
# Claude Code subagent state
|
# Claude Code subagent state
|
||||||
.claude/
|
.claude/
|
||||||
|
|
||||||
|
# Signal V2 runtime data
|
||||||
|
signal_v2/data/*.db
|
||||||
|
signal_v2/data/*.db-*
|
||||||
|
|||||||
8
requirements.txt
Normal file
8
requirements.txt
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# Signal V2 dependencies (added 2026-05-16, Phase 2)
|
||||||
|
httpx>=0.27
|
||||||
|
fastapi>=0.110
|
||||||
|
uvicorn>=0.27
|
||||||
|
python-dotenv>=1.0
|
||||||
|
pytest>=8.0
|
||||||
|
pytest-asyncio>=0.23
|
||||||
|
respx>=0.21
|
||||||
0
signal_v2/__init__.py
Normal file
0
signal_v2/__init__.py
Normal file
28
signal_v2/config.py
Normal file
28
signal_v2/config.py
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
"""Signal V2 환경변수 로딩."""
|
||||||
|
import os
|
||||||
|
from dataclasses import dataclass, field
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
|
# web-ai/.env 명시 로드 (signal_v2/config.py 의 parent.parent = web-ai/)
|
||||||
|
load_dotenv(Path(__file__).parent.parent / ".env")
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass(frozen=True)
|
||||||
|
class Settings:
|
||||||
|
stock_api_url: str = field(
|
||||||
|
default_factory=lambda: os.getenv("STOCK_API_URL", "").rstrip("/")
|
||||||
|
)
|
||||||
|
webai_api_key: str = field(
|
||||||
|
default_factory=lambda: os.getenv("WEBAI_API_KEY", "").strip()
|
||||||
|
)
|
||||||
|
port: int = field(default_factory=lambda: int(os.getenv("SIGNAL_V2_PORT", "8001")))
|
||||||
|
db_path: Path = field(
|
||||||
|
default_factory=lambda: Path(__file__).parent / "data" / "signal_v2.db"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def get_settings() -> Settings:
|
||||||
|
"""매 호출 시 신선한 Settings (테스트 monkeypatch 호환)."""
|
||||||
|
return Settings()
|
||||||
0
signal_v2/data/.gitkeep
Normal file
0
signal_v2/data/.gitkeep
Normal file
15
signal_v2/state.py
Normal file
15
signal_v2/state.py
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
"""PollState — process-wide singleton."""
|
||||||
|
from dataclasses import dataclass, field
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class PollState:
|
||||||
|
portfolio: dict | None = None
|
||||||
|
news_sentiment: dict | None = None
|
||||||
|
screener_preview: dict | None = None
|
||||||
|
last_updated: dict[str, str] = field(default_factory=dict)
|
||||||
|
fetch_errors: dict[str, int] = field(default_factory=dict)
|
||||||
|
|
||||||
|
|
||||||
|
# Process-wide singleton. Phase 3 imports: from signal_v2.state import state
|
||||||
|
state = PollState()
|
||||||
0
signal_v2/tests/__init__.py
Normal file
0
signal_v2/tests/__init__.py
Normal file
Reference in New Issue
Block a user