fix: Prevent user from cancelling trades after slot time has passed

Users can no longer cancel trades once the slot time has passed.
Added test to verify this behavior.
This commit is contained in:
counterweight 2025-12-23 10:39:09 +01:00
parent 3a22534c04
commit 29b0438416
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
2 changed files with 40 additions and 1 deletions

View file

@ -548,7 +548,13 @@ async def cancel_my_trade(
detail=f"Cannot cancel: status is '{exchange.status.value}'",
)
# Cancel the exchange (no time restriction per spec)
# Check if slot time has already passed
if exchange.slot_start <= datetime.now(UTC):
raise HTTPException(
status_code=400,
detail="Cannot cancel: trade slot time has already passed",
)
exchange.status = ExchangeStatus.CANCELLED_BY_USER
exchange.cancelled_at = datetime.now(UTC)