Overall Statistics
Total Trades
0
Average Win
0%
Average Loss
0%
Compounding Annual Return
0%
Drawdown
0%
Expectancy
0
Net Profit
0%
Sharpe Ratio
0
Probabilistic Sharpe Ratio
0%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
0
Tracking Error
0
Treynor Ratio
0
Total Fees
$0.00
from QuantConnect.Data.Market import *
from QuantConnect.Data.Consolidators import *
from datetime import *
from System import *
from QuantConnect import *
from QuantConnect.Algorithm import *
from QuantConnect.Indicators import *
from QuantConnect.Securities.Option import OptionPriceModels
import decimal as d 
import operator

class BasicTemplateOptionsAlgorithm(QCAlgorithm):
                        
    def Initialize(self):   
        self.SetStartDate(2019, 1, 4)
        self.SetEndDate(2019, 1, 4)
        self.tickers_one = ["AAPL", "FB", "TSLA", "AMD"]

        self.symbols = []
        for ticker in self.tickers_one:
            symbol = self.AddEquity(ticker, Resolution.Minute).Symbol
            option = self.AddOption(ticker, Resolution.Minute)
            self.symbols.append(option.Symbol)
            option.SetFilter(-5, 5, timedelta(0), timedelta(14))

            
        self.AddEquity("SPY")
        self.Schedule.On(self.DateRules.EveryDay("SPY"),
                        self.TimeRules.At(12,40),
                        self.OnceADay1)
        
        self.Schedule.On(self.DateRules.EveryDay("SPY"),
                        self.TimeRules.At(12,45),
                        self.OnceADay2)
                        
        self.Schedule.On(self.DateRules.EveryDay("SPY"),
                        self.TimeRules.At(12,50),
                        self.OnceADay3)
                        
        
        self.Log("initialize")
    
        
    def OnceADay1(self):
            self.Log("before")
            for security in self.ActiveSecurities.Keys:
                self.Log(f'Security in Universe: {security.Value}')
                
    def OnceADay2(self):
            for symbol in self.symbols:
                self.RemoveSecurity(symbol)
                
    def OnceADay3(self):
            self.Log("after")
            for security in self.ActiveSecurities.Keys:
                self.Log(f'Security in Universe: {security.Value}')