I was playing with the Sample Algorithm for a Basic Strategy just to learn my way around the Quantopian platform and Python. I encountered what appears to be a bug in order_target(). On one day, Sept 19, of the backtest, excessive fills occurred which were confirmed by a corresponding negative cash balance.
On Sept 19, order_target() was called twice. The target was 436 shares at 14:16. The target amount was changed to 401 shares at 14:18 on the log. The total fill was 803 shares on a 401 share order. The next day, a target_order() to close the position was placed. An overfill of -43 shares occurred. A buy was then apparently executed by the platform for 43 shares to compensate for the overfill. The overfill on the sell side concerns me also.
I'm a newbie here. So, if I'm confused, please show me the error of my ways. Thank you.
Please note that this code is only meant to demonstrate the bug encountered and has no algorithmic trading value.