Closed jaredbroad closed 4 months ago
Docs recommend the dedicated way to add option chains. We can keep the example of OptionChainProvider chaining but its kind of hacky.
Only show the OptionChainProvider method.
master
namespace QuantConnect.Algorithm.CSharp { public class ETFUniverseOptions : QCAlgorithm { Symbol _benchmark; List<DateTime> _selections = new List<DateTime>(); public override void Initialize() { SetCash(1000000000); SetStartDate(2020, 1, 1); SetEndDate(2024, 1, 1); UniverseSettings.Resolution = Resolution.Hour; UniverseSettings.DataNormalizationMode = DataNormalizationMode.Raw; Portfolio.SetPositions(SecurityPositionGroupModel.Null); SetSecurityInitializer(security => { var seeder = new FuncSecuritySeeder(GetLastKnownPrices).SeedSecurity(security); security.SetBuyingPowerModel(new ConstantBuyingPowerModel(1)); }); _benchmark = AddEquity("QQQ", dataNormalizationMode: DataNormalizationMode.Raw).Symbol; var etfUniverse = AddUniverse(Universe.ETF("QQQ", Market.USA, UniverseSettings, ETFConstituentsFilter)); AddUniverseOptions(etfUniverse, OptionFilterFunction); } private IEnumerable<Symbol> ETFConstituentsFilter(IEnumerable<ETFConstituentData> constituents) { return constituents.OrderByDescending(c => c.Weight).Take(10).Select(c => c.Symbol); } private OptionFilterUniverse OptionFilterFunction(OptionFilterUniverse optionFilterUniverse) { return optionFilterUniverse.Strikes(0, 2).FrontMonth().CallsOnly(); } } }
Closed by 4efe7b4
Expected Behavior
Docs recommend the dedicated way to add option chains. We can keep the example of OptionChainProvider chaining but its kind of hacky.
Actual Behavior
Only show the OptionChainProvider method.
Checklist
master
branch