Skip to content

Commit

Permalink
fix(rust): the price bound was not checked in the depth clear event.
Browse files Browse the repository at this point in the history
  • Loading branch information
nkaz001 committed Nov 16, 2024
1 parent 949d74e commit 415f81b
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions hftbacktest/src/depth/roivectormarketdepth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,22 @@ impl L2MarketDepth for ROIVectorMarketDepth {
}
}
}
let low_bid_tick = if self.low_bid_tick == INVALID_MAX {
self.roi_lb
} else {
self.low_bid_tick
};
let clear_upto = if clear_upto - 1 < self.roi_lb {
self.roi_lb
} else if clear_upto - 1 > self.roi_ub {
self.roi_ub
} else {
clear_upto - 1
};
self.best_bid_tick = depth_below(
&self.bid_depth,
clear_upto - 1,
self.low_bid_tick,
clear_upto,
low_bid_tick,
self.roi_lb,
self.roi_ub,
);
Expand All @@ -288,10 +300,22 @@ impl L2MarketDepth for ROIVectorMarketDepth {
}
}
}
let high_ask_tick = if self.high_ask_tick == INVALID_MIN {
self.roi_ub
} else {
self.high_ask_tick
};
let clear_upto = if clear_upto + 1 < self.roi_lb {
self.roi_lb
} else if clear_upto + 1 > self.roi_ub {
self.roi_ub
} else {
clear_upto + 1
};
self.best_ask_tick = depth_above(
&self.ask_depth,
clear_upto + 1,
self.high_ask_tick,
clear_upto,
high_ask_tick,
self.roi_lb,
self.roi_ub,
);
Expand Down

0 comments on commit 415f81b

Please sign in to comment.