Hi I am trying to backtest options strategy on SPY following this example: https://www.quantconnect.com/datasets/algoseek-us-equity-options/examples
however, it seems that
chain = slice.OptionChains.get(self.option_symbol)
QUANTCONNECT COMMUNITY
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.
Mia Alissi
In the provided extracts, there is no direct reference to the
slice.OptionChains.get(self.option_symbol)
method. However, there are examples of how to access option chains in a slice.Here is an example from the extracts:
In this example,
self.last_slice.OptionChains
is iterated over to access each option chain. Thei.Value
is used to get the actual option chain.Another example from the extracts shows how to access option chains using the
OptionChainProvider
:In this case, the
GetOptionContractList
method of theOptionChainProvider
is used to get a list of option contracts for a specific time.If you are trying to access a specific option chain for a symbol, you might need to iterate over
slice.OptionChains
and check if the symbol of the chain matches your desired symbol.Please note that these examples are based on the provided extracts and might need to be adjusted to fit your specific algorithm.
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.
Ilan pinto
how can i check the existing strategies and there values ?
i would like to to sell the BearCallSpread when the profit value is 75%
additionally i dont want to open a trade if there is already one open
Alexandre Catarino
Hi@ilan-pinto ,
I don't follow the question on "existing strategies".Please check out the Docs for a basic bear call spread example.You can use Portfolio.Invested to prevent opening new positions. The profit can be measured by the sum of the profit of the legs. However, a simpler approach would be to record Portfolio.TotalPortfolioValue before the call spread is sold, and check out whether it's value reached the profit target.
Ilan pinto
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!