Overall Statistics
Total Trades
8
Average Win
0.23%
Average Loss
0%
Compounding Annual Return
-0.165%
Drawdown
2.100%
Expectancy
0
Net Profit
-0.026%
Sharpe Ratio
-0.028
Probabilistic Sharpe Ratio
31.260%
Loss Rate
0%
Win Rate
100%
Profit-Loss Ratio
0
Alpha
-0.005
Beta
-0.192
Annual Standard Deviation
0.028
Annual Variance
0.001
Information Ratio
0.135
Tracking Error
0.162
Treynor Ratio
0.004
Total Fees
$6.00
Estimated Strategy Capacity
$540000.00
Lowest Capacity Asset
IBM 2ZNFM7EZGPFGM|IBM R735QTJ8XC9X
Portfolio Turnover
0.95%
#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 CoveredPutAlgorithm : QCAlgorithm
    {
        private Symbol _put, _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 (_put != null && Portfolio[_put].Invested) return;

            if (!slice.OptionChains.TryGetValue(_symbol, out var chain)) return;

            // Find ATM put with the farthest expiry
            var expiry = chain.Max(x => x.Expiry);
            var atmPut = chain
                .Where(x=> x.Right == OptionRight.Put && x.Expiry == expiry)
                .OrderBy(x => Math.Abs(x.Strike - chain.Underlying.Price))
                .FirstOrDefault();

            if (atmPut == null) return;

            var coveredPut = OptionStrategies.CoveredPut(_symbol, atmPut.Strike, expiry);
            Buy(coveredPut, 1);

            _put = atmPut.Symbol;
        }
    }
}