코드 변경
This commit is contained in:
@@ -534,31 +534,15 @@ async def analyze_stock_with_indicators(stock_code: str, stock_name: str) -> Opt
|
||||
return await analyze_stock(stock_code, stock_name, criteria)
|
||||
|
||||
async def get_all_tradable_stocks() -> List[tuple]:
|
||||
SKIP_KEYWORDS = [
|
||||
"ETF", "레버리지", "인버스", "KODEX", "TIGER", "ARIRANG",
|
||||
"KBSTAR", "HANARO", "SOL", "ACE", "KOSEF", "KINDEX", "RISE",
|
||||
"선물", "스팩", "리츠", "SPAC",
|
||||
]
|
||||
"""네이버 파이낸스에서 KOSPI+KOSDAQ 시가총액 순위 종목 조회.
|
||||
|
||||
KIS volume-rank API 대신 네이버 파이낸스 크롤링을 사용한다.
|
||||
실서버 API 키 불필요.
|
||||
"""
|
||||
try:
|
||||
_list_api = _real_market_api or korea_investment_api
|
||||
await asyncio.sleep(3.0)
|
||||
kospi_result = await _list_api.get_stock_list("J")
|
||||
await asyncio.sleep(3.0)
|
||||
kosdaq_result = await _list_api.get_stock_list("Q")
|
||||
|
||||
stocks = []
|
||||
for result in (kospi_result, kosdaq_result):
|
||||
if "output" in result:
|
||||
for item in result["output"]:
|
||||
stock_code = item.get("mksc_shrn_iscd", "")
|
||||
stock_name = item.get("hts_kor_isnm", "")
|
||||
if not stock_code or not stock_name:
|
||||
continue
|
||||
if any(kw in stock_name for kw in SKIP_KEYWORDS):
|
||||
continue
|
||||
stocks.append((stock_code, stock_name))
|
||||
|
||||
from app.services.naver_finance import get_naver_stock_list
|
||||
stocks = await get_naver_stock_list(max_pages_per_market=10)
|
||||
return stocks
|
||||
except Exception as e:
|
||||
logger.error(f"Error fetching stock list from KIS API: {e}", exc_info=True)
|
||||
logger.error(f"네이버 파이낸스 종목 조회 실패: {e}", exc_info=True)
|
||||
return []
|
||||
Reference in New Issue
Block a user