trophy

Long Only, ETF Alpha Streams Competition with $27,500 Prize Pool

Back

Futures Bracket Orders with Multiple Symbols

Hi, in my efforts to give back to the community I would like to share a demo futures algorithm that tests bracket orders for multiple futures symbols. It builds on the example found here, by Alexandre Catarino.

I find that some of the demo examples don't make it clear how to manage multiple symbols within the framework so I gave it a shot. I hope this algo assists others who will improve on it and share. 

For example this algo doesn't have any particular trading logic integrated. It just buys the symbols and submits/cancels bracket orders. I think there may also be nuanced issues with the order timing as it seems that certain functions and orders are being executed simultaneously although it may be just occurring within the same minute. Either way I'm not sure that it would be robust in live trading so if anyone has or can contribute a method to block/delay certain functions or orders more inline with reality please do.

PS. This algo features a helper file called `order_codes.py` which has reference dictionaries that translate the numerical order codes into their text equivalents. It doesn't have the error codes though, so those can be added if anyone wants to contribute those.

Thanks!

Update Backtest








0

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.


Very cool thank you Brian Christopher !

1

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.


Thank you Brian! very clear code. 

While skimming through I noticed, however, that your "_calc_order_quantity function is fine for stocks, but not for futures contracts. 

For example one e-min S&P500 futures contract is for 50 x the index, which means that you have to divide by 50 (besides price) in your "qnty" variable. Different futures have different conventions/notionals - for example the WTI oil futures quoted price is for 1 barrel, but one contracts is actually for 1,000 barrels. I cannot remember if QuantConnect has some multiplier attached to each futures to take care of this.

Hope this helps. Thx again Brian for your clear code.

0

Alex Muci Thanks for the correction. I forgot about that, and last time I checked I don't think QC had automatic handling of the futures contract multiple. Maybe Jared Broad can confirm? Either way I'm attaching a version which I believe handles the contract multiple. 

1


>last time I checked I don't think QC had automatic handling of the futures contract multiple
We do! The prices shown for trades are the individual future tick but the impact on margin and position size is according to the price-multiplier. 

0

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.


Jared Broad I'm guessing that means when you use `SetHoldings` it will factor the price multiple into the calculation. But if you need to compute the quantity of contracts yourself (so an order ticket is returned) then it seems like it's still necessary to incorporate the multiple, correct?

0

Hi Brian,

You're correct! SetHoldings factors the price multiple into its calculation but you would need to do this if calculating the quantity yourself.

0

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.


Update Backtest





0

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.


Loading...

This discussion is closed