Overall Statistics |
Total Trades 1 Average Win 0% Average Loss 0% Compounding Annual Return -99.919% Drawdown 53.000% Expectancy 0 Net Profit -29.584% Sharpe Ratio -2.699 Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha -3.979 Beta 0.778 Annual Standard Deviation 1.509 Annual Variance 2.278 Information Ratio -2.62 Tracking Error 1.509 Treynor Ratio -5.238 Total Fees $4.25 |
class DynamicOptimizedThrustAssembly(QCAlgorithm): def Initialize(self): self.SetStartDate(2019, 2, 19) # Set Start Date self.SetEndDate(2019, 3, 10) self.SetCash(100000) # Set Strategy Cash self.option = self.AddOption("GOOG") self.option_symbol = self.option.Symbol self.test_val=0 # set our strike/expiry filter for this option chain self.option.SetFilter(-2, +2, timedelta(0), timedelta(180)) def OnData(self, data): chain =data.OptionChains.GetValue(self.option_symbol) if chain is None: return # we sort the contracts to find at the money (ATM) contract with farthest expiration contracts = sorted(sorted(sorted(chain, \ key = lambda x: abs(chain.Underlying.Price - x.Strike)), \ key = lambda x: x.Expiry, reverse=True), \ key = lambda x: x.Right, reverse=True) # if found, trade it if len(contracts) == 0: return if self.test_val==0: symbol1 = contracts[0].Symbol symbol2 = contracts[1].Symbol self.SetHoldings(symbol1,1) self.SetHoldings(symbol2,-1) self.test_val=self.test_val+1