No, the algorithm isn't doing what you want. The following "if" condition is always True, because the arguments to CheckOver are missing:
if CheckOver:
order_target_percent(sid(24),1)
Another issue -- later on, you're comparing a float to a Series:
if (prev_ret > over):
You might want to consider rewriting your code without handle_data. You can use a second call to schedule_function to make your ordering logic run at the appropriate time. Within CheckOrder, you can test for early closes and store the result in something like context.early_close. Then you can check that result later in your ordering function.
Whichever path you choose, it's often useful to set breakpoints and step through the code in the debugger. After you hit a breakpoint, you can inspect objects with the print statement, e.g. "print(ret)". For single numeric values, "print" won't display anything; instead, just type the variable name and hit return.