Does OnOrderEvent not fire in the case of orders placed through SetHoldings helper as opposed to manually executing the trade operations? Icould not find an example of using OnOrderEvent in conjunction with SetHoldings...
I added the following line copied from sample algorithm and not seeing any of the output showing in the backtest logs:
def OnOrderEvent(self, orderEvent):
order = self.Transactions.GetOrderById(orderEvent.OrderId)
self.Log("{0}: {1}: {2}".format(self.Time, order.Type, orderEvent))
Michael Manus
are you sure?
because this sample algo provided by quantconnect
with this code - edit:
def OnOrderEvent(self, fill):
order = self.Transactions.GetOrderById(fill.OrderId)
self.Log("{0} - {1}:TEST: {2}".format(self.Time, order.Type, fill))
gives me
2013-10-07 00:00:00 :Launching analysis for b7b7ab2d62b49b985ef07ea54076ba38 with LEAN Engine v2.4.0.1.30552013-10-07 09:30:01 :2013-10-07 09:30:01 - 4:TEST: Time: 10/7/2013 1:30:01 PM OrderID: 1 Symbol: SPY Status: Submitted2013-10-07 09:30:01 :2013-10-07 09:30:01 - 5:TEST: Time: 10/7/2013 1:30:01 PM OrderID: 2 Symbol: SPY Status: Submitted2013-10-07 16:00:00 :2013-10-07 16:00:00 - 5:TEST: Time: 10/7/2013 8:00:00 PM OrderID: 2 Symbol: SPY Status: Filled Quantity: -100 FillPrice: 153.6415 USD OrderFee: 1 USD2013-10-08 09:30:01 :2013-10-08 09:30:01 - 4:TEST: Time: 10/8/2013 1:30:01 PM OrderID: 1 Symbol: SPY Status: Filled Quantity: 100 FillPrice: 153.5956 USD OrderFee: 1 USD2013-10-08 09:30:01 :2013-10-08 09:30:01 - 4:TEST: Time: 10/8/2013 1:30:01 PM OrderID: 3 Symbol: SPY Status: Submitted2013-10-08 09:30:01 :2013-10-08 09:30:01 - 5:TEST: Time: 10/8/2013 1:30:01 PM OrderID: 4 Symbol: SPY Status: Submitted2013-10-08 16:00:00 :2013-10-08 16:00:00 - 5:TEST: Time: 10/8/2013 8:00:00 PM OrderID: 4 Symbol: SPY Status: Filled Quantity: -100 FillPrice: 151.8339 USD OrderFee: 1 USD2013-10-09 09:30:01 :2013-10-09 09:30:01 - 4:TEST: Time: 10/9/2013 1:30:01 PM OrderID: 3 Symbol: SPY Status: Filled Quantity: 100 FillPrice: 152.1367 USD OrderFee: 1 USD2013-10-09 09:30:01 :2013-10-09 09:30:01 - 4:TEST: Time: 10/9/2013 1:30:01 PM OrderID: 5 Symbol: SPY Status: Submitted2013-10-09 09:30:01 :2013-10-09 09:30:01 - 5:TEST: Time: 10/9/2013 1:30:01 PM OrderID: 6 Symbol: SPY Status: Submitted2013-10-09 16:00:00 :2013-10-09 16:00:00 - 5:TEST: Time: 10/9/2013 8:00:00 PM OrderID: 6 Symbol: SPY Status: Filled Quantity: -100 FillPrice: 151.9257 USD OrderFee: 1 USD
Michael Manus
yep added the wrong backtest....just changed the orders to setholdings, it's almost the same backtest
Matthew Jones
staring at a computer screen last night! I'm sure it was ID-10-T error.
Matthew Jones
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!