Test market and limit orders in a sandbox
A market order seeks available liquidity immediately under the venue’s rules. A limit buy can fill up to its limit price. Its remainder depends on time in force, available liquidity and venue rules. Use an isolated book fixture for deterministic assertions, then repeat status checks in a demo environment.
Work through the same buy size
The artificial ask side offers 2 units at 101 and 3 at 102. For an unrestricted immediate buy of 3, the model consumes 2 at 101 and 1 at 102, averaging 101.3333. A buy limit at 101 can consume 2 at the first level and leaves 1 unfilled. In a resting-order scenario that unit remains open. With immediate-or-cancel it cancels.
Check the order quantity unit before comparing. Some APIs accept market buy input in quote currency, while limit quantities often represent base units. Record the rule for the product and order type. Use a fresh instrument metadata read to choose supported tick and lot increments. Binance spot order reference · OKX trade API
Run the demo checks
First reject an invalid size or price. Then observe acceptance, fills or expiry and reconciliation. Test cancellation of the remainder and a fill received before the terminal state. Use the demo environment’s virtual inventory and record its mode beside the logs, since the book and fills may differ from the fixture.