Overall Statistics
Total Trades
1
Average Win
0%
Average Loss
0%
Compounding Annual Return
-71.622%
Drawdown
1.100%
Expectancy
0
Net Profit
-0.916%
Sharpe Ratio
-6.667
Probabilistic Sharpe Ratio
0%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0.601
Beta
-5.402
Annual Standard Deviation
0.103
Annual Variance
0.011
Information Ratio
-7.579
Tracking Error
0.122
Treynor Ratio
0.127
Total Fees
$1.00
Estimated Strategy Capacity
$11000000.00
Lowest Capacity Asset
GOOCV WQE8C4JAK93A|GOOCV VP83T1ZUHROL
from QuantConnect.Securities.Option import OptionPriceModels
from datetime import timedelta
class OptionsAlgorithm(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2017, 7, 1)
        self.SetEndDate(2017, 7, 3)
        self.SetCash(100000)
        option = self.AddOption("GOOG")
        option.SetFilter(-10, +10, timedelta(0), timedelta(180))
        option.PriceModel = OptionPriceModels.CrankNicolsonFD()
        self.SetWarmUp(TimeSpan.FromDays(7))

    def GetGreek(self, symbol):        
        for kvp in self.CurrentSlice.OptionChains:
            chain = kvp.Value
            contracts = [i for i in chain if i.Symbol==symbol]
            if contracts[0]:
                return contracts[0].Greeks
        return None
    def OnData(self,slice):
        
       if not self.Portfolio.Invested: 
        for chain in slice.OptionChains.Values:
            contracts = sorted(sorted(chain, \
                           key = lambda x: abs(chain.Underlying.Price - x.Strike)), \
                           key = lambda x: x.Expiry, reverse=True)
            self.MarketOrder(contracts[0].Symbol, 1)
            self.symbol = contracts[0].Symbol
       else:
           greeks = self.GetGreek(self.symbol) 
           if not greeks:return
           self.Log(f"Delta: {greeks.Delta}")
           self.Log(f"Vega: {greeks.Vega}")
           self.Log(f"Gamma: {greeks.Gamma}")