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:
parent
3a22534c04
commit
29b0438416
2 changed files with 40 additions and 1 deletions
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue