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
-5.881
Tracking Error
0.098
Treynor Ratio
0
Total Fees
$0.00
class VentralHorizontalProcessor(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2020, 11, 20)  # Set Start Date
        self.SetCash(100000)  # Set Strategy Cash
        self.AddOption("AAPL", Resolution.Minute)
        
        self.shortDelta = .25
        self.longDelta = .15
        
        self.curr_day = -1
        
    def OnData(self, data):
        if self.curr_day != self.Time.day:
            self.getContracts(data)
            self.curr_day = self.Time.day
        
    def getContracts(self, slice):
        shortContract = None
        longContract = None

        # Get Contracts
        for i in slice.OptionChains:
            chain = i.Value
            contracts = [x for x in chain]
            contracts = sorted(contracts, key=lambda x: (x.Expiry, x.Greeks.Delta))
            shortContract = min(contracts, key=lambda x: abs(x.Greeks.Delta-self.shortDelta))
            longContract = min([c for c in contracts if c.Expiry==shortContract.Expiry], key=lambda x: abs(x.Greeks.Delta-self.longDelta))
            self.Debug(f"shortcontract: Strike: {shortContract.Strike} Expiry: {shortContract.Expiry} Delta: {shortContract.Greeks.Delta}")
            self.Debug(f"longContract: Strike: {longContract.Strike} Expiry: {longContract.Expiry} Delta: {longContract.Greeks.Delta}")
        
        # Check that contracts are not the same
        if shortContract != longContract:
            pass
            #self.placeOrder(shortContract, longContract)