def fill_price_worse_than_limit_price(fill_price, order):
 if order.limit:
  if (((order.direction > 0) and (fill_price > order.limit)) or ((order.direction < 0) and (fill_price < order.limit))):
   return True
 return False

def fill_price_worse_than_limit_price ( fill_price , order ) : if order . limit : if ( ( ( order . direction > 0 ) and ( fill_price > order . limit ) ) or ( ( order . direction < 0 ) and ( fill_price < order . limit ) ) ) : return True return False
checks whether the fill price is worse than the orders limit price .