Files
Stock-trading-programming/app/data/collector.py
T

24 lines
624 B
Python

"""
data/collector.py - KIS WebSocket 실시간 시세 수신
"""
import asyncio, logging
from app.execution.kis_client import KISWebSocket
logger = logging.getLogger(__name__)
class DataCollector:
def __init__(self, kis_client, on_price, on_vi):
self.ws = KISWebSocket(kis_client)
self.on_price = on_price
self.on_vi = on_vi
async def start(self, tickers: list):
for ticker in tickers:
self.ws.on_price(ticker, self.on_price)
self.ws.on_vi(self.on_vi)
await self.ws.subscribe(tickers)
async def stop(self):
await self.ws.close()