stock-lab 오류 수정, lotto-lab 히트맵 기반 추천 기능 추가

This commit is contained in:
2026-02-05 01:26:20 +09:00
parent 4035432c54
commit c96815c2e3
4 changed files with 219 additions and 128 deletions

View File

@@ -8,10 +8,6 @@ import requests
from apscheduler.schedulers.background import BackgroundScheduler
from pydantic import BaseModel
from .db import init_db, save_articles, get_latest_articles
from .scraper import fetch_market_news, fetch_major_indices, fetch_overseas_news
@@ -33,7 +29,6 @@ WINDOWS_AI_SERVER_URL = os.getenv("WINDOWS_AI_SERVER_URL", "http://192.168.0.5:8
@app.on_event("startup")
def on_startup():
print(f"[StockLab] Startup. Windows AI Server URL: {WINDOWS_AI_SERVER_URL}")
init_db()
# 매일 아침 8시 뉴스 스크랩 (NAS 자체 수행)
@@ -52,9 +47,10 @@ def run_scraping_job():
articles_kr = fetch_market_news()
count_kr = save_articles(articles_kr)
# 2. 해외
articles_world = fetch_overseas_news()
count_world = save_articles(articles_world)
# 2. 해외 (임시 차단)
# articles_world = fetch_overseas_news()
# count_world = save_articles(articles_world)
count_world = 0
print(f"[StockLab] Saved {count_kr} domestic, {count_world} overseas articles.")
@@ -127,25 +123,7 @@ def order_stock(req: OrderRequest):
)
@app.get("/api/stock/analyze")
def analyze_market():
"""Windows PC를 통한 AI 시장 분석"""
print(f"[Proxy] Analyzing Market at {WINDOWS_AI_SERVER_URL}...")
try:
# 빈 JSON Body 전송
resp = requests.post(f"{WINDOWS_AI_SERVER_URL}/analyze/portfolio", json={}, timeout=120)
if resp.status_code != 200:
print(f"[ProxyError] Analyze Error: {resp.status_code} {resp.text}")
return JSONResponse(status_code=resp.status_code, content=resp.json())
return resp.json()
except Exception as e:
print(f"[ProxyError] Analyze Connection Failed: {e}")
return JSONResponse(
status_code=500,
content={"error": "Connection Failed", "detail": str(e), "target": WINDOWS_AI_SERVER_URL}
)
@app.get("/api/version")
def version():