Overall Statistics |
Total Orders 5 Average Win 0% Average Loss -0.62% Compounding Annual Return -5.713% Drawdown 1.900% Expectancy -1 Start Equity 100000 End Equity 99059 Net Profit -0.941% Sharpe Ratio -2.568 Sortino Ratio -3.288 Probabilistic Sharpe Ratio 6.402% Loss Rate 100% Win Rate 0% Profit-Loss Ratio 0 Alpha -0.051 Beta -0.113 Annual Standard Deviation 0.019 Annual Variance 0 Information Ratio -0.115 Tracking Error 0.151 Treynor Ratio 0.419 Total Fees $4.00 Estimated Strategy Capacity $35000.00 Lowest Capacity Asset IBM VNWUCLACI1RA|IBM R735QTJ8XC9X Portfolio Turnover 0.63% |
#region imports using System; using System.Linq; using QuantConnect.Util; using QuantConnect.Data; using QuantConnect.Securities; using QuantConnect.Securities.Option; #endregion namespace QuantConnect.Algorithm.CSharp { public class ProtectiveCallAlgorithm : QCAlgorithm { private Symbol _call, _symbol; public override void Initialize() { SetStartDate(2014, 1, 1); SetEndDate(2014, 3, 1); SetCash(100000); var option = AddOption("IBM"); _symbol = option.Symbol; option.SetFilter(universe => universe.IncludeWeeklys().NakedCall(30, 0)); // use the underlying equity as the benchmark SetBenchmark(_symbol.Underlying); } public override void OnData(Slice slice) { if (_call != null && Portfolio[_call].Invested) return; if (!slice.OptionChains.TryGetValue(_symbol, out var chain)) return; // Find ATM call with the farthest expiry var expiry = chain.Max(x => x.Expiry); var atmCall = chain .Where(x=> x.Right == OptionRight.Call && x.Expiry == expiry) .OrderBy(x => Math.Abs(x.Strike - chain.Underlying.Price)) .FirstOrDefault(); if (atmCall == null) return; var protectiveCall = OptionStrategies.ProtectiveCall(_symbol, atmCall.Strike, expiry); Buy(protectiveCall, 1); _call = atmCall.Symbol; } } }