Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
ordering futures

I have been working on a futures strategy and I feel that the ordering API could be more convenient for futures.
For equities I love

objective = opt.TargetPortfolioWeights(targets)  
order_optimal_portfolio(objective, constraints=[])  

However this is a little difficult to do with Futures. If you want to calculate TargetPortfolioWeights you need to calculate the notational value which is a little more involved. The other option would be to simply use order() but then you have to keep track of which positions you currently are holding. It would be great if I could simply do: objective = opt.TargetNumberPositions(targets)

If there is a way I can do this and I overlooked it, please let me know.

4 responses

Hi Peter,

Thanks for the feedback. Are you trying to set an objective that passes a number of positions instead of a % of the portfolio? It sounds like that's what you're aiming for but I want to confirm.

If you pass a TargetPortfolioWeight objective to Optimize, it will order based on notional value, so you don't need to think about that. Of course, if you're trying to order to a target number of contracts, then I imagine the work you mentioned is in factoring the notional value out of the weight. Am I understanding your request correctly?

Disclaimer

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 Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian 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.

Are you trying to set an objective that passes a number of positions instead of a % of the portfolio?
Yes

You understand my request correctly.

Thanks for the clarification, Peter. Do you think you could give me a bit more color as to why you prefer to specify target positions instead of target weights? I'm filing the feature request internally and would like to add a bit of an explanation as to how it can be helpful!

Sure, futures are a different animal than equities, but it feels like the developer (of an algo) has to do extra work just to place orders.
It feels like the API is made for equities. With futures different contracts have different historical volatility which drives, different margin requirements, and different amount of positions one wants to take. From my experience with futures the notational value is not used much. So to order a number of contracts I have to convert contracts into notional value, and then divide that by the portfolio value to get % of portfolio, then the API converts my % of portfolio value to a number of contracts. It just seems a bit silly but it is not the end of the world, it is a few multiplies and I have already written the code. Thanks for submitting a request.