| Overall Statistics |
|
Total Trades 12 Average Win 0.79% Average Loss -0.54% Compounding Annual Return 3.766% Drawdown 1.900% Expectancy 0.235 Net Profit 0.738% Sharpe Ratio 1.146 Probabilistic Sharpe Ratio 52.317% Loss Rate 50% Win Rate 50% Profit-Loss Ratio 1.47 Alpha 0.005 Beta -0.052 Annual Standard Deviation 0.032 Annual Variance 0.001 Information Ratio 1.019 Tracking Error 0.634 Treynor Ratio -0.702 Total Fees $12.00 Estimated Strategy Capacity $550000.00 Lowest Capacity Asset CRWD 31BBZ886P0D6U|CRWD X59VIZ423I3P |
from datetime import timedelta
from math import floor,ceil
class BasicTemplateOptionsAlgorithm(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2020, 1, 1)
self.SetEndDate(2020, 3, 14)
self.SetCash(100000)
equity = self.AddEquity("CRWD", Resolution.Minute)
option = self.AddOption("CRWD", Resolution.Minute)
self.symbol = option.Symbol
# set our strike/expiry filter for this option chain
option.SetFilter(-30, +30, timedelta(0), timedelta(60))
# use the underlying equity as the benchmark
self.SetBenchmark(equity.Symbol)
def OnData(self,slice):
if not self.Portfolio.Invested and self.Time.hour != 0 and self.Time.minute != 0:
for i in slice.OptionChains:
if i.Key != self.symbol: continue
chain = i.Value
call = [x for x in chain if x.Right == OptionRight.Call]
put = [x for x in chain if x.Right == OptionRight.Put]
for i in call:
for j in put:
if i.Expiry == j.Expiry and i.Strike == j.Strike:
if self.Portfolio.Invested: return
if i.BidPrice + i.Strike > i.UnderlyingLastPrice + j.AskPrice:
self.MarketOrder(i.UnderlyingSymbol, 1) # long the underlying stocks
self.MarketOrder(j.Symbol, 1) # long put
self.MarketOrder(i.Symbol, -1) # short call
self.expirydate = i.Expiry
elif i.AskPrice + i.Strike < i.UnderlyingLastPrice + j.BidPrice:
#quantity = self.CalculateOrderQuantity(self.euqity_symbol,0.6)
self.MarketOrder(i.UnderlyingSymbol, -1) # short the underlying stocks
self.MarketOrder(j.Symbol, -1) # short put
self.MarketOrder(i.Symbol, 1) # long call
self.expirydate = i.Expiry
if self.Portfolio.Invested:
self.CheckForExpiry()
def OnOrderEvent(self, orderEvent):
self.Log(str(orderEvent))
def CheckForExpiry(self):
if (self.expirydate - self.Time) < timedelta(7):
#self.Log("less than 7 days before expiry")
self.Liquidate()