| Overall Statistics |
|
Total Trades 5 Average Win 0.33% Average Loss 0% Compounding Annual Return -0.211% Drawdown 2.100% Expectancy -0.5 Net Profit -0.034% Sharpe Ratio -0.04 Probabilistic Sharpe Ratio 31.061% Loss Rate 50% Win Rate 50% Profit-Loss Ratio 0 Alpha -0.005 Beta -0.191 Annual Standard Deviation 0.028 Annual Variance 0.001 Information Ratio 0.133 Tracking Error 0.162 Treynor Ratio 0.006 Total Fees $3.00 Estimated Strategy Capacity $110000.00 Lowest Capacity Asset 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 NakedCallAlgorithm : 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 nakedCall = OptionStrategies.NakedCall(_symbol, atmCall.Strike, expiry);
Buy(nakedCall, 1);
_call = atmCall.Symbol;
}
}
}