feat(db): ENV 키·스키마 확장 및 거래일/포트폴리오 DB 헬퍼

OrderWorker·수집통계·영구구독 알람 env 등록과 TradeDB/db_manager 조회·마이그레이션을 보강한다.
kr_trading_day 헬퍼와 ERD 문서를 함께 갱신한다.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Your Name
2026-08-28 16:45:36 +09:00
parent bc2b1b642c
commit 2c915c9508
4 changed files with 456 additions and 63 deletions

View File

@@ -145,6 +145,41 @@ def is_kr_trading_day(d: DateLike, *, holidays: Optional[Set[date]] = None) -> b
return day not in hol
def iter_kr_trading_days(
start: DateLike,
end: DateLike,
*,
holidays: Optional[Set[date]] = None,
) -> List[date]:
"""[start, end] 구간의 한국 거래일 목록 (주말·휴장 제외, 오름차순)."""
a = _parse_ymd(start)
b = _parse_ymd(end)
if a > b:
a, b = b, a
hol = holidays if holidays is not None else get_kr_market_holiday_set()
out: List[date] = []
cur = a
while cur <= b:
if is_kr_trading_day(cur, holidays=hol):
out.append(cur)
cur += timedelta(days=1)
return out
def count_kr_trading_days(
start: DateLike,
end: DateLike,
*,
holidays: Optional[Set[date]] = None,
) -> int:
"""[start, end] 한국 거래일 수. 잘못된 날짜면 1(최소 표본)."""
try:
n = len(iter_kr_trading_days(start, end, holidays=holidays))
return max(1, int(n))
except Exception:
return 1
def clamp_to_prev_kr_trading_day(
d: DateLike,
*,