-
Notifications
You must be signed in to change notification settings - Fork 706
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Summary
Local processors apply fills only when order.status == Status::Filled. When using PartialFillExchange, partial fills are emitted as Status::PartiallyFilled, so local state (position/balance/fee/trade count) is not updated until the final fill.
Evidence
File: hftbacktest/src/backtest/proc/local.rs
if order.status == Status::Filled {
self.state.apply_fill(&order);
}Same logic in L3 local:
File: hftbacktest/src/backtest/proc/l3_local.rs
if order.status == Status::Filled {
self.state.apply_fill(&order);
}PartialFillExchange sets Status::PartiallyFilled for partial fills:
File: hftbacktest/src/backtest/proc/partialfillexchange.rs
if (order.leaves_qty / self.depth.lot_size()).round() > 0f64 {
order.status = Status::PartiallyFilled;
} else {
order.status = Status::Filled;
}Impact
Incorrect state values when using PartialFillExchange (positions/fees/trade counts undercounted between partial fills). This can materially distort PnL and risk metrics.
Repro (minimal)
- Use
PartialFillExchange - Place a limit order that fills in multiple partials
- After the first partial fill, check
state_values.position-> it remains unchanged until final fill
Expected
Apply fills for partial fills as well (or apply deltas based on incremental exec_qty).
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working