32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
"""API 路由:日常使用 - 前置匹配"""
|
|
|
|
from fastapi import APIRouter, Depends, Query
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app.database import get_db
|
|
from app import schemas
|
|
from app.matcher import run_match
|
|
|
|
router = APIRouter(prefix="/api/match", tags=["前置匹配"])
|
|
|
|
|
|
@router.get("", response_model=schemas.MatchResult)
|
|
def do_match(
|
|
market_cycle: str = Query(..., description="大盘周期:日线/4H/1H"),
|
|
market_regime_id: int = Query(..., description="大盘阶段 ID"),
|
|
trend_strength: str = Query(..., description="趋势强弱:强/弱/震荡"),
|
|
db: Session = Depends(get_db),
|
|
):
|
|
"""根据人工选择的三项参数,输出前置匹配结果"""
|
|
req = schemas.MatchRequest(
|
|
market_cycle=market_cycle,
|
|
market_regime_id=market_regime_id,
|
|
trend_strength=trend_strength,
|
|
)
|
|
return run_match(db, req)
|
|
|
|
|
|
@router.post("", response_model=schemas.MatchResult)
|
|
def do_match_post(req: schemas.MatchRequest, db: Session = Depends(get_db)):
|
|
return run_match(db, req)
|