Model submit-side ack latency¶
The simulator can defer the ACCEPTED event until a sampled
deadline after submitOrder(). This mirrors the cancel and replace
ack models and lets backtests reproduce the race where market data
moves between submission and the venue accepting the order.
Behavior¶
SUBMITTEDfires immediately- The order is held aside, not yet placed in the book
- At the sampled ack deadline:
ACCEPTEDfires + the order runs through the existing post-accept logic (POST_ONLY check, queue tracker registration, try-fill) - If POST_ONLY would cross the book at acceptance time, the order
is
REJECTEDwithreject_reason = "late_post_only_crossed"
Configure¶
Two BacktestConfig knobs:
submitAckLatencyNs— base ack delay. Default0preserves the legacy synchronous flow.submitAckJitterNs— uniform jitter band, clamped non-negative.
RNG sampling shares cancelAckSeed.
The bindings expose the pair as one SimulatedExecutor setter,
set_submit_ack_latency(latency_ns, jitter_ns=0). BacktestRunner's
constructor takes only (registry, fee_rate, initial_capital) and
owns its executor internally, so from Python / Node the knob applies
to a SimulatedExecutor you drive yourself — a standalone one, or
PaperBroker.simulated_executor. Set BacktestConfig in C++ to
change the knob for a BacktestRunner.
Detect the race from a strategy¶
"""Detect submit-side late-cross rejections from a strategy."""
import flox_py as flox
class Watcher(flox.Strategy):
def __init__(self, symbols):
super().__init__(symbols)
self.post_only_failures = 0
def on_order_update(self, ctx, ev):
if (ev.status == "REJECTED" and
ev.reject_reason == "late_post_only_crossed"):
self.post_only_failures += 1
Notes¶
- The order does not participate in queue matching or fills before
ACCEPTED. Trades arriving during the ack window do not consume it. - Conditional orders (stop / TP / trailing) follow the same async
path when
submitAckLatencyNs > 0. They reachPENDING_TRIGGERat the ack deadline, not at submit time. - The clock source is the engine's simulated clock; live runs follow whichever clock the connector attached.