I've been looking at scalping NQ futures today, and my entries would be determined primarily on minute resolution bars. After I've decided to enter though, the minute resolution doesn't do well at simulating what would happen. When I switch to tick data, things work a lot better, but it's very slow.
One thought I had on how to fix this would be to run in the minute resolution until I'm entering a trade, then switch to ticks. I haven't been able to get dropping in and out of ticks to work though. I get runtime errors when I try.
Anyone have a good way to do this?
Brent Oster
Here's some sample code. Change self.AllowTicks to True to see the latest error I was running into.
Fred Painchaud
Hi Brent,
You were close but you needed a couple more guards to make sure to call Enable and Disable only once (there are many ticks per minute 😊). Also, you need to let make your order before changing the security. You will also need to let OnData return prior to doing orders as changes to securities will happen in between OnData calls.
See attached code.
Fred
Brent Oster
Ah, I see your change and that seems like an obvious miss to me, but I'm not sure I 100% understand yet. In your example code the market order immediately liquidates. Is this related to your comment about letting ondata return?
I ran a quick test where I did a market order, waited a minute, changed the resolution, waited a minute, liquidated, waited a minute, then changed the resolution back. That all worked as I wanted it to, but all the waiting would be limiting, so I tried making some changes. I basically tried setting it up so that it would finish the ondata function and do changes the next time I entered ondata, but it broke again.
I'm not sure why, there's something I'm not getting. The error happens when I do the market order.
Fred Painchaud
Hi Brent,
I'm not a futures expert but what's sure is that .Mapped becomes None after the shift. This shift might not be supported. You might get more info from someone else.
Fred
Brent Oster
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!