Freak trades in F&O

Hi,
is there any updates on
“Internal dynamic execution range at Zerodha”.

Zerodha mentioned in the following link “To calculate this impact cost, the system will consider the best five bids and offers and the quantities available at those prices while placing the order”.

How I can code those in Python. Do I need to get the best five Ask for buy or Bid for sell. But the freak trades still can appear in the Bid/Ask market depth.
Please help me giving the logic.

Freak trades in F&O

Thanks
Benny