Hello there, I'm confused about quite a few things with how QuantConnect deals with futures. I've attached an example algorithm that's buying the the highest open interest ES Mini S&P 500 Future, with daily rebalancing.
- What is SetHoldings doing? Here I'm setting it to a constant 0.1, however you can see in the Exposure graph that the exposure is close to 2.
- Why is exposure hovering near 2? S&P EMini are 50x leveraged exposure to the S&P index, so with a 0.1 argument to SetHoldings, I'd expect a position with net 5x leveraged exposure to the S&P index. So an exposure hovering near 5 would make sense to me
- Why is there so much variance in exposure? I'd expect a little bit due to overnight swings in value of positions, but I'm having a hard time explaining why exposure isn't much closer to being a straight horizontal line.
- How is order size being computed? The first order was placed for 201 contracts at a price of $2,687.50. This represents exposure to the underlying index of 201 * 2,687.50 * 50 = $27M
- $27M is 2.7x our margin at the time, which is close to what I'm seeing in the Exposure graph which makes me think exposure is “Exposure to underlying ÷ net portfolio value” — however not connecting the dots to how 0.1 SetHoldings got us here.
Separately two general questions about futures that I couldn't see the answers to:
- I know that S&P EMini is 50x leveraged to underlying index, because I googled it… is there anyway to get this 50x value in the programming environment? Not seeing it in the docs, but obviously you need to know this value to compute P&L
- Futures have a margin requirement that is not necessarily equal to the contract value, like right now Sept /ES is $4,479.75 but has a entry margin requirement of $6,600 and maintenance requirement of $6,000 per contract — are these values available in programming environment? I'd imagine you need them to accurately model margin calls, but not seeing them in the docs.
Lucky Dragon
I think 0.1 in your example is instructing QC to use $1M (your starting cash of $10M X 0.1) to buy as many contracts as possible given the margin requirement of $4500 for one ES contract in 2018.
Austin Sheppard
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!