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.
BacktestRunner takes the pair as constructor arguments
(submit_ack_latency_ns, submit_ack_jitter_ns; Node
submitAckLatencyNs, submitAckJitterNs) and applies them to its built-in
executor; PaperBroker passes them on from
runner_options={"submit_ack_latency_ns": ..., "submit_ack_jitter_ns": ...}.
A SimulatedExecutor you drive yourself takes them through
set_submit_ack_latency(latency_ns, jitter_ns=0).
Detect the race from a strategy¶
"""Detect submit-side late-cross rejections from a strategy."""
import lrvx
class Watcher(lrvx.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.
- On bar replay the clock reads the bar's end, so any positive ack latency moves a bar-callback order's fill to a later bar's open. See Latency on bar replay.