Overall Statistics |
Total Trades 8 Average Win 0.14% Average Loss -0.37% Compounding Annual Return -4.264% Drawdown 1.100% Expectancy -0.316 Net Profit -0.698% Sharpe Ratio -2.455 Probabilistic Sharpe Ratio 6.137% Loss Rate 50% Win Rate 50% Profit-Loss Ratio 0.37 Alpha -0.031 Beta -0.056 Annual Standard Deviation 0.012 Annual Variance 0 Information Ratio -0.051 Tracking Error 0.144 Treynor Ratio 0.536 Total Fees $6.00 Estimated Strategy Capacity $2200000.00 Lowest Capacity Asset IBM VOBM1Z09FM2U|IBM R735QTJ8XC9X Portfolio Turnover 1.57% |
#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(-3, 3, 0, 31); // 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; } } }