Commit Graph

11 Commits

Author SHA1 Message Date
eafa73edb1 feat(signal_v2-phase3a): scheduler NXT windows (20:00-23:30 / 04:30-07:00)
NXT 시간외 거래 시간대도 5분 cron 폴링 활성화. 23:30-04:30 dead zone
(KIS 점검) → 04:30 까지 skip. 기존 _seconds_until_next_market_open
(휴장일/주말용) 와 별개로 _seconds_until_nxt_or_market_open 신설.

3 new tests, scheduler suite 11 passed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-16 05:09:27 +09:00
68eb7b073c feat(signal_v2-phase3a): config + state extensions for KIS data
- config.py: KIS_APP_KEY/SECRET/ACCOUNT/IS_VIRTUAL + V1_TOKEN_PATH env
- state.py: PollState extended with minute_bars (deque) and asking_price
- requirements.txt: websockets>=12

19 existing tests still pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-16 05:06:40 +09:00
8342d38935 chore(signal_v2): sync holidays.json from stock + start.bat launcher
- holidays.json: authoritative copy from web-backend/stock/app/holidays.json
  (replaces 13-date stub from Task 3; now 16 dates including Jan/May/Dec edges)
- start.bat: uvicorn launcher (cd to web-ai root, host 0.0.0.0, port 8001)

19 tests still pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-16 03:55:41 +09:00
e47947fb69 fix(signal_v2): await cancelled poll_task + public cache_size
Code review fixes:
- main.py lifespan: await poll_task after cancel() to avoid client
  close racing with mid-fetch task (CRITICAL).
- stock_client: add public cache_size() method; main.py /health uses
  it instead of private _cache attribute (IMPORTANT).

19 tests still pass. Deferred to Phase 7 backlog:
- _ctx singleton test isolation (importlib.reload provides isolation in practice)
- poll_loop interval floor (interval >= 60 by design)
- shutdown logging
- response schema validation

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-16 03:52:45 +09:00
94c684bab8 feat(signal_v2): pull_worker + FastAPI app + 2 integration tests
poll_loop: asyncio.gather parallel fetch of 3 endpoints (portfolio,
news_sentiment, screener_preview) + state update. main.py: FastAPI
lifespan creates StockClient/SignalDedup/shutdown.Event then spawns
poll_loop as background task. GET /health reports status, last poll
times, cache size.

Signal V2 test suite: 19/19 PASS.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-16 03:49:50 +09:00
1a6d9fcb39 feat(signal_v2): rate_limit + 3 unit tests
SignalDedup: 24h-rolling duplicate signal blocker. SQLite WAL +
busy_timeout=120000 standard fix (reference_sqlite_concurrency.md
pattern). PK (ticker, action) with UPSERT. Phase 4 (signal generator)
will call is_recent() before sending + record() after sending.

3 unit tests pass, total 17 signal_v2.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-16 03:46:59 +09:00
6cb5085118 test(signal_v2): add scheduler boundary tests at exact transitions
Code review noted missing boundary tests at:
- 09:00:00 (pre-market → market) → 60
- 15:30:00 (market → post-market) → 300
- 20:00:00 (post-market → overnight skip)

3 new tests, total 8 scheduler / 14 signal_v2.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-16 03:45:55 +09:00
fdabc69004 feat(signal_v2): scheduler + 5 unit tests
Time-window dispatcher: pre-market (07:00-09:00, 5min), market
(09:00-15:30, 1min), post-market (15:30-20:00, 5min), overnight skip
to next market day 07:00. Weekend + holiday detection via holidays.json.

Stub holidays.json with 13 dates. Task 6 will sync from
web-backend/stock/app/holidays.json.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-16 03:44:24 +09:00
90235497ae refactor(signal_v2): narrow stock_client exception catch + remove dead code
Code quality review fixes:
- _cached_request: catch httpx.HTTPError instead of bare Exception
  (avoid swallowing KeyboardInterrupt / asyncio.CancelledError)
- _request_with_retry: remove unused last_exc variable + dead post-loop
  raise paths. Final sentinel raise preserved for mypy.

6 tests still pass. Deferred to Phase 7 backlog: cache concurrency
coalescing + __aenter__/__aexit__ context manager support.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-16 03:43:09 +09:00
8469bf7ffa feat(signal_v2): stock_client + 6 integration tests
httpx async client with custom retry loop (max 3, exponential 1s/2s/4s),
memory dict cache (portfolio 60s / news-sentiment 300s / screener 60s),
X-WebAI-Key auth header injection. Stale fallback returns last
successful response with logger.warning on persistent failures.

6 integration tests pass with respx httpx mock.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-16 03:40:12 +09:00
8a2fac03a6 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>
2026-05-16 03:35:36 +09:00