한국투자증권(KIS) Open API를 통해 실계좌에서 운영 중인 AI 기반 주식 자동매매 시스템입니다. 단타(DayTrade)와 장기(Kostolany) 두 개의 독립 파이프라인이 각자의 전략·예산·계좌로 병렬 운영됩니다.
A production AI auto-trading system running on a live brokerage account via the Korea Investment & Securities (KIS) Open API. Two independent pipelines — DayTrade and Kostolany (long-term) — run in parallel with separate strategies, budgets, and accounts.
예측 정확도보다 리스크 관리와 운영 안정성을 우선합니다. 손절·익절·일일 손실 한도, 강제청산, 장애 복구, DB/KIS 정합성 검증이 모두 자동화되어 있습니다.
Risk management and operational stability take priority over prediction accuracy. Stop-loss, take-profit, daily loss limits, force-close, fault recovery, and DB/KIS reconciliation are all automated.
소스 저장소는 비공개입니다. 대시보드 URL은 인증 필요.
Source repository is private. Dashboard requires authentication.
| 모듈 | Module | 역할 | Role |
|---|---|---|---|
daytrade/selector.py |
아침 후보 선정 — fpool 스캔 후 스코어 정렬 | Morning candidate selection — fpool scan + score sort | |
daytrade/buy_agent.py |
매수 에이전트 — 진입 시그널 체크, 지정가 주문, 실체결가 확인 | Buy agent — entry signal check, limit order, fill price verification | |
daytrade/sell_agent.py |
매도 에이전트 — TP/SL/분할익절/트레일링 스탑 체크 | Sell agent — TP/SL/partial-TP/trailing stop checks | |
daytrade/close_agent.py |
종가마감 에이전트 — 3단계 청산, 중복방지 lock, 시장가 폴백 | EOD close agent — 3-phase liquidation, dedup lock, market-order fallback | |
daytrade/strategy.py |
진입·청산 시그널 계산 — ATR, RSI, 5분봉 브레이크아웃 | Entry/exit signal logic — ATR, RSI, 5-min breakout | |
daytrade/risk.py |
일일 손실 한도, 포지션 사이즈, 매수 허용 여부 판단 | Daily loss limit, position sizing, buy eligibility | |
daytrade/news_analyzer.py |
Gemini API 뉴스 감성분석 — 후보 스코어 조정 (±0.2) | Gemini news sentiment — candidate score adjustment (±0.2) | |
daytrade/ml_model.py |
단타 전용 ML — 진입 확률 게이트 (임계값 0.60) | DT-only ML — entry probability gate (threshold 0.60) | |
daytrade/analysis.py |
인디케이터 계산 — MA, ATR, RSI, 볼린저밴드 | Indicator builder — MA, ATR, RSI, Bollinger Bands | |
daytrade/kis_dt.py |
DT 전용 KIS 클라이언트 — 별도 계좌 격리, 토큰 독립 | DT-only KIS client — isolated account, independent token |
| 모듈 | Module | 역할 | Role |
|---|---|---|---|
agents/guard_agent.py |
장애 모니터링 — 2분 간격, KIS 토큰 갱신, API 헬스체크 | Fault monitoring — 2-min interval, KIS token refresh, API health | |
core/ledger.py |
체결 기록 + KIS 실거래 대조 — 슬리피지·미체결 감지 | Fill ledger + KIS reconciliation — detects slippage and unfilled orders | |
core/ws_manager.py |
WebSocket 실시간 시세 — REST 폴링 폴백 | WebSocket real-time prices — REST polling fallback | |
kis_client/ |
KIS API 클라이언트 패키지 — 토큰·dedup·레이트리밋 전담 | KIS API client package — token management, dedup, rate limiting | |
models/gemini_analyst.py |
Gemini Flash API — 뉴스 감성분석, 일일 사용량 추적·DB 플러시 | Gemini Flash API — news sentiment, daily usage tracking + DB flush | |
data/db.py |
PostgreSQL CRUD — 종목·캔들·포지션·거래내역·설정 | PostgreSQL CRUD — symbols, candles, positions, trades, config | |
utils/market_hours.py |
KRX 개장 여부 — 2026 공휴일 포함 | KRX market hours — including 2026 public holidays | |
core/finance_agent.py |
통합 잔고 관리 — TTL 캐시, pending 예약, DT/Kost 손익 추적 | Unified balance manager — TTL cache, pending reservation, DT/Kost P&L tracking | |
daytrade/dt_manager.py |
DT 파이프라인 관리자 — circuit breaker, 매수·매도 병렬 실행, 강제청산 조율 | DT pipeline manager — circuit breaker, parallel buy/sell execution, force-close coordination | |
core/kost_manager.py |
Kostolany 파이프라인 관리자 — circuit breaker, 파이프라인 싱글턴, EOD 리셋 | Kostolany pipeline manager — circuit breaker, pipeline singleton, EOD reset |
| 항목 | Item | 설정값 | Value | 설명 | Description |
|---|---|---|---|---|---|
| 손절 | Stop-Loss | −1.2% |
진입가 기준 | From entry | |
| 익절 | Take-Profit | +2.5% |
전량 청산 | Full exit | |
| 분할 익절 | Partial TP | +1.5% |
50% 매도 후 잔량 트레일링 | 50% exit, trailing on rest | |
| 트레일링 스탑 | Trailing Stop | −0.5% |
세션 고점 대비 낙폭 | Drop from session high | |
| 일일 손실 한도 | Daily Loss Limit | −3% |
초과 시 신규 매수 차단 | Block new buys on breach | |
| 매수 슬리피지 상한 | Buy Slippage Cap | +1% |
지정가 = 신호가 × 1.01, 미체결 시 스킵 | Limit = signal × 1.01, skip if unfilled | |
| ML 확률 게이트 | ML Probability Gate | 0.60 |
임계값 미만 신호 진입 차단 | Block entry below threshold |
| 기술 | Tech | 용도 | Purpose |
|---|---|---|---|
Python 3.11 |
전체 봇 파이프라인 | Full bot pipeline | |
APScheduler |
크론 스케줄러 — 각 파이프라인 독립 BackgroundScheduler | Cron scheduler — independent BackgroundScheduler per pipeline | |
KIS Open API |
시세 조회 + 실주문 (모의/실전 분리) | Market data + live orders (mock/live isolation) | |
Gemini Flash |
뉴스 감성분석, 일일 사용량 DB 추적 | News sentiment analysis, daily usage tracking | |
LightGBM |
단타 ML — 진입 확률 예측 (매일 재학습) | DT ML — entry probability prediction (daily retrain) | |
PostgreSQL |
거래·포지션·후보·설정 영구 저장 | Trades, positions, candidates, config persistent storage | |
Next.js 15 · Vercel |
실시간 대시보드 (인증 필요) | Real-time dashboard (authenticated) | |
Railway |
Python 봇 호스팅 — GitHub push 자동 배포 | Python bot hosting — auto-deploy on GitHub push | |
Telegram Bot API |
거래 알림 + 장애 경고 | Trade notifications + fault alerts |
실계좌 운영 봇은 예측 품질만큼 장애 내성이 중요합니다. 코드 배포 시 Python 문법 검증, import 폴백, 강제청산 이중화가 필수입니다.
For a live-account bot, fault tolerance matters as much as prediction quality. Python syntax validation, import fallback, and redundant force-close are essential before any deployment.