INNER CODE UNIT · Python
execute_trade
YichengYang-Ethan/oracle3 · oracle3/blinks/server.py:165
async def execute_trade(
market_ticker: str,
body: ExecuteTradeBody,
side: str = 'yes',
amount: int = 1,
price: float | None = Query(None, description='Limit price in dollars'),
) -> JSONResponse:
"""Build a transaction via DFlow Trade API and return base64 serialized tx."""
if not _MARKET_TICKER_RE.match(market_ticker):
raise HTTPException(
status_code=400,
detail='market_ticker must be alphanumeric/underscores/hyphens, max 100 chars',
)
if side not in ('yes', 'no'):
raise HTTPException(status_code=400, detail='side must be yes or no')
if amount < 1 or amount > _MAX_AMOUNT:
raise HTTPException(
status_code=400,