Overall Statistics |
Total Trades 2 Average Win 0% Average Loss -1.22% Compounding Annual Return -43.585% Drawdown 1.500% Expectancy -1 Net Profit -1.221% Sharpe Ratio -10.646 Loss Rate 100% Win Rate 0% Profit-Loss Ratio 0 Alpha -0.188 Beta -16.051 Annual Standard Deviation 0.041 Annual Variance 0.002 Information Ratio -10.962 Tracking Error 0.042 Treynor Ratio 0.027 Total Fees $1.00 |
from datetime import timedelta class optionExample(QCAlgorithm): def Initialize(self): self.SetStartDate(2016, 1, 1) self.SetEndDate(2016, 1, 8) self.SetCash(100000) option = self.AddOption("GOOG",Resolution.Minute) self.option_symbol = option.Symbol # set our strike/expiry filter for this option chain option.SetFilter(self.UniverseFunc) def OnData(self,slice): if self.Time.hour == 15 and self.Time.minute == 30: option_invested = [x.Key.Value for x in self.Portfolio if x.Value.Invested and x.Value.Type==SecurityType.Option] # Print to log for contract in option_invested: quantity = self.Portfolio[contract].Quantity lastPrice = self.Securities[contract].Price self.Log("Contract: " + str(contract) + " - Quantity: " + str(quantity) + " - Last Price: " + str(lastPrice)) if not self.Portfolio.Invested: for i in slice.OptionChains: chain = i.Value call = [i for i in chain if i.Right == OptionRight.Call] contracts = sorted(sorted(call, key=lambda x: x.Expiry, reverse=True), key=lambda x: abs(x.UnderlyingLastPrice - x.Strike)) atm_contract = contracts[0] # Sell ATM Call Option Contract if len(contracts) == 0: continue symbol = contracts[0].Symbol # Place market price. self.MarketOrder(symbol, 1) def UniverseFunc(self, universe): # include weekly contracts return universe.IncludeWeeklys().Expiration(TimeSpan.FromDays(0),TimeSpan.FromDays(7)).Strikes(-2,2)