first commit
This commit is contained in:
28
app/routers/trades.py
Normal file
28
app/routers/trades.py
Normal file
@@ -0,0 +1,28 @@
|
||||
"""Trades router — R:R scanner trade setup endpoints."""
|
||||
|
||||
from fastapi import APIRouter, Depends, Query
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.dependencies import get_db, require_access
|
||||
from app.schemas.common import APIEnvelope
|
||||
from app.schemas.trade_setup import TradeSetupResponse
|
||||
from app.services.rr_scanner_service import get_trade_setups
|
||||
|
||||
router = APIRouter(tags=["trades"])
|
||||
|
||||
|
||||
@router.get("/trades", response_model=APIEnvelope)
|
||||
async def list_trade_setups(
|
||||
direction: str | None = Query(
|
||||
None, description="Filter by direction: long or short"
|
||||
),
|
||||
_user=Depends(require_access),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
) -> APIEnvelope:
|
||||
"""Get all trade setups sorted by R:R desc, secondary composite desc.
|
||||
|
||||
Optional direction filter (long/short).
|
||||
"""
|
||||
rows = await get_trade_setups(db, direction=direction)
|
||||
data = [TradeSetupResponse(**r).model_dump(mode="json") for r in rows]
|
||||
return APIEnvelope(status="success", data=data)
|
||||
Reference in New Issue
Block a user