AI 포트폴리오 분석 엔드포인트 및 Gemini 연동 제거

프롬프트 생성/복사 방식으로 전환하여 더 이상 불필요한
/api/stock/ai-analysis 엔드포인트, ai_analyst.py, google-generativeai 패키지 제거

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-25 04:47:42 +09:00
parent 4f854c5540
commit 09e5ab4e30
3 changed files with 0 additions and 217 deletions

View File

@@ -19,7 +19,6 @@ from .db import (
)
from .scraper import fetch_market_news, fetch_major_indices, fetch_overseas_news
from .price_fetcher import get_current_prices
from .ai_analyst import analyze_portfolio as ai_analyze_portfolio
app = FastAPI()
@@ -413,45 +412,3 @@ def remove_sell_history(record_id: int):
# ═══════════════════════════════════════════════════════════════
# AI 포트폴리오 분석 (Gemini Pro)
# ═══════════════════════════════════════════════════════════════
@app.get("/api/stock/ai-analysis")
def get_ai_analysis(force: bool = False):
"""AI 전문가 포트폴리오 분석 (Gemini Pro).
- 캐시: 5분 TTL (force=true 로 강제 갱신)
- 보유 종목 현재가 + 최근 뉴스를 포함해 Gemini에 전달
"""
# 포트폴리오 + 현재가 조회
items = get_all_portfolio()
if items:
tickers = list({item["ticker"] for item in items})
prices = get_current_prices(tickers)
else:
prices = {}
holdings = []
for item in items:
cp = prices.get(item["ticker"])
buy = item["avg_price"] * item["quantity"]
eval_amt = cp * item["quantity"] if cp is not None else None
profit = (eval_amt - buy) if eval_amt is not None else None
rate = round((profit / buy) * 100, 2) if (profit is not None and buy) else None
holdings.append({
**item,
"current_price": cp,
"profit_amount": profit,
"profit_rate": rate,
})
# 최근 뉴스 (국내 20건)
news = get_latest_articles(20)
if not isinstance(news, list):
news = []
try:
return ai_analyze_portfolio(holdings, news, force=force)
except RuntimeError as exc:
return JSONResponse(status_code=500, content={"error": str(exc)})