| Overall Statistics |
|
Total Trades 6 Average Win 0.59% Average Loss -2.87% Compounding Annual Return -24.373% Drawdown 6.900% Expectancy -0.397 Net Profit -4.537% Sharpe Ratio -2.1 Probabilistic Sharpe Ratio 5.538% Loss Rate 50% Win Rate 50% Profit-Loss Ratio 0.21 Alpha -0.193 Beta 0.051 Annual Standard Deviation 0.083 Annual Variance 0.007 Information Ratio -2.758 Tracking Error 0.197 Treynor Ratio -3.43 Total Fees $4.00 Estimated Strategy Capacity $260000.00 Lowest Capacity Asset GOOCV XG8PSNPNECFA|GOOCV VP83T1ZUHROL |
from AlgorithmImports import *
class USEquityOptionsDataAlgorithm(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2020, 6, 1)
self.SetEndDate(2020, 8, 1)
self.SetCash(100000)
# Requesting data
self.underlying = self.AddEquity("GOOG").Symbol
option = self.AddOption("GOOG")
self.option_symbol = option.Symbol
# Set our strike/expiry filter for this option chain
option.SetFilter(-2, +2, 0, 7)
self.contract = None
def OnData(self, data):
if self.Portfolio[self.underlying].Invested:
self.Liquidate(self.underlying)
if self.contract is not None and self.Portfolio[self.contract.Symbol].Invested:
return
chain = data.OptionChains.get(self.option_symbol)
if chain:
# Select call contracts
calls = [contract for contract in chain if contract.Right == OptionRight.Call]
if len(calls) == 0:
return
# Select the call contracts with the furthest expiration
furthest_expiry = sorted(calls, key = lambda x: x.Expiry, reverse=True)[0].Expiry
furthest_expiry_calls = [contract for contract in calls if contract.Expiry == furthest_expiry]
# From the remaining contracts, select the one with its strike closest to the underlying price
self.contract = sorted(furthest_expiry_calls, key = lambda x: abs(chain.Underlying.Price - x.Strike))[0]
self.MarketOrder(self.contract.Symbol, 1)
def OnSecuritiesChanged(self, changes):
for security in changes.AddedSecurities:
# Historical data
history = self.History(security.Symbol, 10, Resolution.Minute)
self.Debug(f"We got {len(history)} from our history request for {security.Symbol}")