| Overall Statistics |
|
Total Trades 3 Average Win 0% Average Loss -0.16% Compounding Annual Return 88.638% Drawdown 1.100% Expectancy -1 Net Profit 1.342% Sharpe Ratio 9.132 Probabilistic Sharpe Ratio 94.255% Loss Rate 100% Win Rate 0% Profit-Loss Ratio 0 Alpha 0.427 Beta -0.217 Annual Standard Deviation 0.068 Annual Variance 0.005 Information Ratio 6.522 Tracking Error 0.23 Treynor Ratio -2.847 Total Fees $3.00 Estimated Strategy Capacity $38000000.00 Lowest Capacity Asset GOOCV 30AKMEIPIUG06|GOOCV VP83T1ZUHROL |
#region imports
from AlgorithmImports import *
#endregion
class BasicTemplateOptionsAlgorithm(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2016, 1, 1)
self.SetEndDate(2016, 1, 10)
self.SetCash(100000)
option = self.AddOption("GOOG")
self.option_symbol = option.Symbol
# set our strike/expiry filter for this option chain
option.SetFilter(-2, +2, 0, 180)
# use the underlying equity as the benchmark
self.SetBenchmark("GOOG")
def OnData(self,slice):
if self.Portfolio.Invested: return
chain = slice.OptionChains.get(self.option_symbol)
if chain:
# 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
symbol = contracts[0].Symbol
self.MarketOrder(symbol, 1)
self.MarketOnCloseOrder(symbol, -1)
def OnOrderEvent(self, orderEvent):
self.Log(f'{orderEvent}')