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.891
Tracking Error
0.176
Treynor Ratio
0
Total Fees
$0.00
Estimated Strategy Capacity
$0
Lowest Capacity Asset
from QuantConnect.Securities.Option import OptionPriceModels
from datetime import timedelta
import math

class Wheelinginthemoney(QCAlgorithm):

        
    def AddStocks(self,ticker):
            equity = self.AddEquity(ticker, self.resolution) #Adding
            self.Securities[ticker].SetDataNormalizationMode(DataNormalizationMode.Raw)
            return
                    
    def Initialize(self):
        
        self.SetStartDate(2014, 6, 3)
        self.SetEndDate(2021, 6,3)
        self.SetCash(100000)
        self.resolution = Resolution.Minute
        self.stocks = ["BRK.B"]
        self.sell_options = True
        self.sell_down_mode = False
    
        self.SetBrokerageModel(BrokerageName.AlphaStreams)
        
        for ticker in self.stocks:
            self.AddStocks(ticker)

        #assigns the first stock to a variable so it can be used in the date time scheduler
        self.symbol = self.stocks[0]

    def trade(self):
            self.sell_options = True
                    
    def OnData(self,slice):
        
        if self.sell_options == False or self.IsWarmingUp or self.IsMarketOpen(self.symbol) == False: return
        
        #in case there are open orders still, we want to cancel them

        contracts = self.OptionChainProvider.GetOptionContractList(self.stocks[0], self.Time)
        self.Debug(len(contracts))
        if len(contracts) == 0: return
        self.MarketOrder(contracts[0], 1)

    def OnOrderEvent(self, orderEvent):
        if orderEvent.Status != "Canceled" :
            self.trade
            self.Debug(orderEvent)