Skip to content

Add insufficient funds/shares validation to ExecuteOrder service #1010

@AbuMareBear

Description

@AbuMareBear

Summary

The ExecuteOrder service is missing validation for:

  • Canceling buy orders when user has insufficient funds
  • Canceling sell orders when user has insufficient shares

What's Needed

  1. Add validation logic to ExecuteOrder service to check:

    • For buy orders: user has enough cash balance to cover the purchase
    • For sell orders: user owns enough shares to sell
  2. Cancel orders that fail validation instead of executing them

  3. Add tests in test/services/execute_order_test.rb for:

    • Buy order with insufficient funds → order should be canceled
    • Sell order with insufficient shares → order should be canceled

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Not Ready

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions