Fill price of POST_ONLY order is not the same as price of the order #1730
-
hello, we recently tested some simple market maker strategy, the result shows that fill price of POST_ONLY order is from the order book rather than the price of the order. It's different from the real exchange. Is this a BUG or by design? Could you fix it or add an option to set the fill price type? I could confirm this behavior from the code below. pub fn simulate_fills(&self, order: &BookOrder) -> Vec<(Price, Quantity)> {
let is_reversed = self.side == OrderSide::Buy;
let mut fills = Vec::new();
let mut cumulative_denominator = Quantity::zero(order.size.precision);
let target = order.size;
for level in self.levels.values() {
if (is_reversed && level.price.value < order.price)
|| (!is_reversed && level.price.value > order.price)
{
break;
}
for book_order in level.orders.values() {
let current = book_order.size;
if cumulative_denominator + current >= target {
// This order has filled us, add fill and return
let remainder = target - cumulative_denominator;
if remainder.is_positive() {
fills.push((book_order.price, remainder));
}
return fills;
}
// Add this fill and continue
fills.push((book_order.price, current));
cumulative_denominator += current;
}
}
fills
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 4 replies
-
Hi @dpmabo Thanks for taking the time to report this. Could you confirm you're seeing this fill behavior when running a backtest, and not by separately using an order book with order objects? The reason I asked is I checked through the matching engine code and found the logic to make sure limit prices are honored: We also have tests for this behavior: However, I also see a condition in the matching engine that the Could you give more information on your config and what |
Beta Was this translation helpful? Give feedback.
-
I can confirm there was a bug in the logic here for I pushed a fix to |
Beta Was this translation helpful? Give feedback.
-
hi @cjdsellers,we are using L2_MBP for testing. I will build a dev version to verify this issue. |
Beta Was this translation helpful? Give feedback.
-
hi @cjdsellers, I just build nt from source and test it, it's working but seems has bug as below. # BUG: not update initial_fill[1...N]
initial_fill_price = initial_fill[0]
fills[0] = initial_fill |
Beta Was this translation helpful? Give feedback.
-
Thanks Chris, I checkout the latest dev code and it's working now. |
Beta Was this translation helpful? Give feedback.
#1733