Is it possible to use OptionChainProvider along with Weekly Options?
Is it possible to use OptionChainProvider along with Weekly Options?
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.
yup!
# lib
from lib import SelectionModel
class OptionsAlgorithm(QCAlgorithm):
# ----------------------------------------------------------------------
# Initialize QuantConnect Algorithm
# ----------------------------------------------------------------------
def Initialize(self):
self.SetUniverseSelection(SelectionModel.OptionsUniverseSelectionModel(self.SelectOptionsSymbols))
# ----------------------------------------------------------------------
# Define Options universe
# ----------------------------------------------------------------------
def SelectOptionsSymbols(self, utcTime):
ticker = self.option_symbol
return [Symbol.Create(ticker, SecurityType.Option, Market.USA, f"?{ticker}")]
# IN ANOTHER FILE. YOU CAN PUT IT IN THE SAME FILE
from Selection.OptionUniverseSelectionModel import OptionUniverseSelectionModel
from datetime import date, timedelta
class OptionsUniverseSelectionModel(OptionUniverseSelectionModel):
def __init__(self, select_option_chain_symbols):
super().__init__(timedelta(1), select_option_chain_symbols)
def Filter(self, filter):
# Define options filter -- strikes +/- 3 and expiry between 0 and 180 days away
return (filteruniverse.IncludeWeeklys()
.BackMonths()
.PutsOnly()
.Strikes(-5, 5)
.Expiration(timedelta(self.filterStartDate), timedelta(self.filterEndDate))
)
Thanks for this Rajats179 .
I need to get weeklies for the SPX index, so I'm going to give this a try.
Do you know if this is the best-practice way to do this / is this recommended by the QC team?
cc: Derek Melchin , Shile Wen
to be honest I swithed from this to using the below instead because i had some issues with options universe I just don't remember what it was... .ekz.
self.option = self.AddOption(self.symbol, Resolution.Minute)
self.option.PriceModel = OptionPriceModels.CrankNicolsonFD()
self.option.SetFilter(-10, 0, timedelta(self.t1DTE), timedelta(self.t2DTE))
Index Options/SPX don't have weeklies sorry EKZ (they are different tickers to the ones we've added), it's not on the plan to add it as the amount of data is enormous. And Index Options are not even officially released =D so please don't judge too harshly! This will be announced soon, it was requested by a business sponsoring LEAN so if they want weeklies we can see what we can do =)
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.
Hello dear community and staff,
adding weekly SPX options to QuantConnect would be a huge advantage for all developers and companies using QuantConnect framework. ❤️
Kind regards
@ossenbrueck
use this to get weekly SPX
underlying = self.AddIndex("SPX", Resolution.Minute)
options = self.AddIndexOption(underlying.Symbol, "SPXW", Resolution.Minute)
options.SetFilter(lambda u: u.WeeklysOnly().Strikes(-1, 1).Expiration(0, 7))
self.symbol = options.Symbol
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!