Reject NaN prices before SimBroker mutates the book

Author: dajiaohuangCreated Sep 25, 2026Updated Sep 25, 2026

Bug

Order accepts a NaN price. SimBroker.place_order checks only whether price is less than or equal to zero; for NaN that comparison is false, so the broker returns a fill, records shares, and changes cash to NaN. The resulting broker state cannot be valued reliably.

Reproduction

On main at e4079a63fe58d287bbc69af49c97eac07502004b with Python 3.13.13:

broker = SimBroker(cash=1000)
order = Order(ticker="TEST", side="buy", quantity=1, price=float("nan"))
broker.place_order(order)

The call succeeds; the position becomes TEST: 1 and cash is NaN.

Expected

Reject a non-finite fill price before changing cash or positions.

Additional context

The normal pipeline validates market marks, but SimBroker and Order are public broker/model interfaces and currently permit this invalid input.