Overall Statistics |
Total Trades 4 Average Win 0% Average Loss 0% Compounding Annual Return -0.771% Drawdown 0.200% Expectancy 0 Net Profit -0.061% Sharpe Ratio 1.785 Probabilistic Sharpe Ratio 58.582% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0.055 Beta -0.075 Annual Standard Deviation 0.008 Annual Variance 0 Information Ratio -7.804 Tracking Error 0.069 Treynor Ratio -0.182 Total Fees $4.00 Estimated Strategy Capacity $3500000.00 Lowest Capacity Asset GOOCV WIQJ61J2NVQE|GOOCV VP83T1ZUHROL Portfolio Turnover 0.06% |
#region imports using System.Linq; using QuantConnect.Util; using QuantConnect.Data; using QuantConnect.Securities; using QuantConnect.Securities.Option; #endregion namespace QuantConnect.Algorithm.CSharp { public class IronCondorAlgorithm : QCAlgorithm { private Symbol _symbol; public override void Initialize() { SetStartDate(2017, 2, 1); SetEndDate(2017, 3, 1); SetCash(500000); var option = AddOption("GOOG"); _symbol = option.Symbol; option.SetFilter(universe => universe.IncludeWeeklys().Strikes(-15, 15) .Expiration(0, 40)); SetBenchmark(_symbol.Underlying); } public override void OnData(Slice slice) { // If there is underlying assets in portfolio at expiration, liquidate the stocks in order to roll into new contracts if (Portfolio[_symbol.Underlying].Invested) { Liquidate(); } if (Portfolio.Invested || !IsMarketOpen(_symbol)) return; if (!slice.OptionChains.TryGetValue(_symbol, out var chain)) return; // Find put and call contracts with the farthest expiry var expiry = chain.Max(x => x.Expiry); var contracts = chain.Where(x => x.Expiry == expiry).OrderBy(x => x.Strike); var putContracts = contracts.Where(x => x.Right == OptionRight.Put).ToArray(); var callContracts = contracts.Where(x => x.Right == OptionRight.Call).ToArray(); if (putContracts.Length < 10 || putContracts.Length < 10) return; // Select the strikes in the strategy legs var farPut = putContracts[0].Strike; var nearPut = putContracts[10].Strike; var nearCall = callContracts[^10].Strike; var farCall = callContracts[^1].Strike; var ironCondor = OptionStrategies.IronCondor( _symbol, farPut, nearPut, nearCall, farCall, expiry); Buy(ironCondor, 2); } } }