| Overall Statistics |
|
Total Trades 28 Average Win 0.03% Average Loss -0.02% Compounding Annual Return -0.003% Drawdown 0.000% Expectancy 0.010 Net Profit -0.002% Sharpe Ratio -0.117 Probabilistic Sharpe Ratio 12.639% Loss Rate 60% Win Rate 40% Profit-Loss Ratio 1.53 Alpha -0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio -0.443 Tracking Error 0.312 Treynor Ratio -1.018 Total Fees $18.00 Estimated Strategy Capacity $28000000.00 Lowest Capacity Asset BP Y1VKEFA273HI|BP R735QTJ8XC9X |
#region imports
from AlgorithmImports import *
#endregion
from datetime import timedelta
from math import floor,ceil
class BasicTemplateOptionsAlgorithm(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2022, 1, 1)
#self.SetEndDate(2022, 9, 1)
self.SetCash(1000000)
equity = self.AddEquity("BP", Resolution.Minute)
option = self.AddOption("BP", Resolution.Minute)
self.symbol = option.Symbol
# set our strike/expiry filter for this option chain
option.SetFilter(-10, +10, timedelta(5), timedelta(90))
# use the underlying equity as the benchmark
self.SetBenchmark(equity.Symbol)
def OnData(self,slice):
if self.Portfolio.Invested: return
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, 100) # long the underlying stocks
self.MarketOrder(j.Symbol, 1) # long put
self.MarketOrder(i.Symbol, -1) # short call
elif i.AskPrice + i.Strike < i.UnderlyingLastPrice + j.BidPrice:
#quantity = self.CalculateOrderQuantity(self.euqity_symbol,0.6)
self.MarketOrder(i.UnderlyingSymbol, -100) # short the underlying stocks
self.MarketOrder(j.Symbol, -1) # short put
self.MarketOrder(i.Symbol, 1) # long call
def OnOrderEvent(self, orderEvent):
self.Log(str(orderEvent))