Overall Statistics |
Total Trades 39 Average Win 1.28% Average Loss 0% Compounding Annual Return 19.243% Drawdown 4.700% Expectancy 0 Net Profit 26.770% Sharpe Ratio 1.493 Probabilistic Sharpe Ratio 71.151% Loss Rate 0% Win Rate 100% Profit-Loss Ratio 0 Alpha 0.162 Beta -0.003 Annual Standard Deviation 0.109 Annual Variance 0.012 Information Ratio 0.083 Tracking Error 0.28 Treynor Ratio -53.984 Total Fees $50.00 |
import numpy as np from datetime import timedelta class HorizontalOptimizedShield(QCAlgorithm): def Initialize(self): self.SetStartDate(2019, 1, 1) self.SetCash(100000) self.equity = self.AddEquity("MSFT", Resolution.Daily) self.Securities["MSFT"].SetDataNormalizationMode(DataNormalizationMode.Raw) def OnData(self, data): if self.Portfolio.Invested: return if not data.ContainsKey(self.equity.Symbol): return contracts = self.OptionChainProvider.GetOptionContractList(self.equity.Symbol, data.Time) self.underlyingPrice = self.Securities[self.equity.Symbol].Price under = self.underlyingPrice - 0.1 * self.underlyingPrice otm_puts = [i for i in contracts if i.ID.OptionRight == OptionRight.Put and i.ID.StrikePrice <= under and 10 < (i.ID.Date - data.Time).days < 30] if len(otm_puts) == 0: return contract = sorted(sorted(otm_puts, key = lambda x: x.ID.Date), key = lambda x: x.ID.StrikePrice)[0] self.AddOptionContract(contract, Resolution.Minute) self.MarketOrder(contract, -10)