For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
Stop Limit Order gets executed despite of being cancelled
-
Hi There,
I believe I've found a bug, in backtest mode I cancel a StopLimit order before it was submitted, I can see its status changed from 1 to 5 but it still got executed anyway.
Please find the logs below:
Starting Portfolio Value: 10000.00 2013-08-29_00:00:00 [1] Price: 3.38, Portfolio: 10000.00, Cash: 10000.00, Position Size: 0 2013-08-30_00:00:00 [2] Price: 3.27, Portfolio: 10000.00, Cash: 10000.00, Position Size: 0 2013-08-30_00:00:00 [2] SHORT: 611 shares @ 3.27 2013-09-03_00:00:00 [3] NOTIFY_ORDER: [ref:1] Sell Limit Submitted, Size: 0.00, Price: 0.00, Cost: 0.00, Comm 0.00 2013-09-03_00:00:00 [3] NOTIFY_ORDER: [ref:1] Sell Limit Accepted, Size: 0.00, Price: 0.00, Cost: 0.00, Comm 0.00 2013-09-03_00:00:00 [3] NOTIFY_ORDER: [ref:1] Sell Limit Completed, Size: -611.00, Price: 3.32, Cost: -2028.52, Comm 2.03 2013-09-03_00:00:00 [3] Created Sell Stop Order ref:2 611 @ 3.4712306518587837 2013-09-03_00:00:00 [3] Price: 3.27, Portfolio: 10028.52, Cash: 12026.49, Position Size: -611 2013-09-03_00:00:00 [3] Exit, liquidating -611 shares 2013-09-03_00:00:00 [3] Cancelling stop order ref:2 2013-09-03_00:00:00 [3] ------------------------------ BEFORE ------------------------------ 2013-09-03_00:00:00 [3] {'_active': True, 2013-09-03_00:00:00 [3] '_limitoffset': 0.0, 2013-09-03_00:00:00 [3] '_plimit': 3.4538744985994896, 2013-09-03_00:00:00 [3] 'broker': None, 2013-09-03_00:00:00 [3] 'comminfo': None, 2013-09-03_00:00:00 [3] 'created': <backtrader.order.OrderData object at 0x7fc7646a9220>, 2013-09-03_00:00:00 [3] 'dteos': 735114.9999999999, 2013-09-03_00:00:00 [3] 'executed': <backtrader.order.OrderData object at 0x7fc7646a9940>, 2013-09-03_00:00:00 [3] 'info': AutoOrderedDict(), 2013-09-03_00:00:00 [3] 'p': <backtrader.metabase.AutoInfoClass_OrderBase_Order_BuyOrder object at 0x7fc7646a9e80>, 2013-09-03_00:00:00 [3] 'params': <backtrader.metabase.AutoInfoClass_OrderBase_Order_BuyOrder object at 0x7fc7646a9e80>, 2013-09-03_00:00:00 [3] 'plen': 3, 2013-09-03_00:00:00 [3] 'position': 0, 2013-09-03_00:00:00 [3] 'ref': 2, 2013-09-03_00:00:00 [3] 'status': 1, 2013-09-03_00:00:00 [3] 'triggered': False} 2013-09-03_00:00:00 [3] ------------------------------ BEFORE ------------------------------ 2013-09-03_00:00:00 [3] ------------------------------ AFTER ------------------------------ 2013-09-03_00:00:00 [3] {'_active': True, 2013-09-03_00:00:00 [3] '_limitoffset': 0.0, 2013-09-03_00:00:00 [3] '_plimit': 3.4538744985994896, 2013-09-03_00:00:00 [3] 'broker': None, 2013-09-03_00:00:00 [3] 'comminfo': None, 2013-09-03_00:00:00 [3] 'created': <backtrader.order.OrderData object at 0x7fc7646a9220>, 2013-09-03_00:00:00 [3] 'dteos': 735114.9999999999, 2013-09-03_00:00:00 [3] 'executed': <backtrader.order.OrderData object at 0x7fc7646a9940>, 2013-09-03_00:00:00 [3] 'info': AutoOrderedDict(), 2013-09-03_00:00:00 [3] 'p': <backtrader.metabase.AutoInfoClass_OrderBase_Order_BuyOrder object at 0x7fc7646a9e80>, 2013-09-03_00:00:00 [3] 'params': <backtrader.metabase.AutoInfoClass_OrderBase_Order_BuyOrder object at 0x7fc7646a9e80>, 2013-09-03_00:00:00 [3] 'plen': 3, 2013-09-03_00:00:00 [3] 'position': 0, 2013-09-03_00:00:00 [3] 'ref': 2, 2013-09-03_00:00:00 [3] 'status': 5, 2013-09-03_00:00:00 [3] 'triggered': False} 2013-09-03_00:00:00 [3] ------------------------------ AFTER ------------------------------ 2013-09-04_00:00:00 [4] NOTIFY_ORDER: [ref:2] Buy StopLimit Submitted, Size: 0.00, Price: 0.00, Cost: 0.00, Comm 0.00 2013-09-04_00:00:00 [4] NOTIFY_ORDER: [ref:3] Buy Close Submitted, Size: 0.00, Price: 0.00, Cost: 0.00, Comm 0.00 2013-09-04_00:00:00 [4] NOTIFY_ORDER: [ref:2] Buy StopLimit Accepted, Size: 0.00, Price: 0.00, Cost: 0.00, Comm 0.00 2013-09-04_00:00:00 [4] NOTIFY_ORDER: [ref:3] Buy Close Accepted, Size: 0.00, Price: 0.00, Cost: 0.00, Comm 0.00 2013-09-04_00:00:00 [4] NOTIFY_ORDER: [ref:3] Buy Close Completed, Size: 611.00, Price: 3.31, Cost: -2028.52, Comm 2.02 2013-09-04_00:00:00 [4] NOTIFY_TRADE: BARS:1, PROFIT GROSS:6.11, NET:2.06 2013-09-04_00:00:00 [4] Price: 3.31, Portfolio: 10002.06, Cash: 10002.06, Position Size: 0 2013-09-05_00:00:00 [5] Price: 3.41, Portfolio: 10002.06, Cash: 10002.06, Position Size: 0 2013-09-06_00:00:00 [6] NOTIFY_ORDER: [ref:2] Buy StopLimit Completed, Size: 611.00, Price: 3.45, Cost: 2110.32, Comm 2.11
I am running version 1.9.76.123
Any ideas?
Thanks in Advance.