Overall Statistics |
Total Trades 10 Average Win 0% Average Loss 0% Compounding Annual Return -68.915% Drawdown 2.900% Expectancy 0 Net Profit 0% Sharpe Ratio -4.573 Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha -1.166 Beta 0.436 Annual Standard Deviation 0.173 Annual Variance 0.03 Information Ratio -9.119 Tracking Error 0.181 Treynor Ratio -1.816 Total Fees $2.50 |
using QuantConnect.Securities.Option; namespace QuantConnect { public class StraddleFundamentalAlgorithm : QCAlgorithm { private List<Symbol> _symbols = new List<Symbol>(); public override void Initialize() { UniverseSettings.Resolution = Resolution.Daily; SetStartDate(2016, 03, 01); SetEndDate(2016, 03, 09); SetCash(10000); AddUniverse(CoarseSelectionFunction, FineSelectionFunction); } public IEnumerable<Symbol> CoarseSelectionFunction(IEnumerable<CoarseFundamental> coarse) { return coarse .Where(x => x.HasFundamentalData) .OrderByDescending(x => x.DollarVolume) .Select(x => x.Symbol).Take(15); } public IEnumerable<Symbol> FineSelectionFunction(IEnumerable<FineFundamental> fine) { return fine .Where(x => // More than 7 days after earnings report Time >= x.EarningReports.FileDate.AddDays(-7) && Time >= x.EarningReports.FileDate.AddDays(0) && // Invalid FileDate x.EarningReports.FileDate != new DateTime()) .Select(x => x.Symbol).Take(5); } public override void OnData(Slice data) { foreach (var kvp in data.OptionChains) { var chain = kvp.Value; var symbol = kvp.Key; if (_symbols.Contains(symbol.Underlying)) return; var atmStraddle = chain .OrderBy(x => Math.Abs(chain.Underlying.Price - x.Strike)) .ThenByDescending(x => x.Expiry) .FirstOrDefault(); if (atmStraddle != null) { _symbols.Add(symbol.Underlying); Buy(OptionStrategies.Straddle(symbol, atmStraddle.Strike, atmStraddle.Expiry), 1); Log(string.Format("{0} straddle orders submitted", symbol.Underlying)); } } } public override void OnSecuritiesChanged(SecurityChanges changes) { foreach (var security in changes.RemovedSecurities) { if (security is Option) continue; Log(security.Symbol); } // Add option for every added security foreach (var security in changes.AddedSecurities) { if (security is Option) continue; if (security.Symbol.Equals("SPY")) continue; var option = AddOption(security.Symbol.Value); option.SetFilter(-2, 2, TimeSpan.Zero, TimeSpan.FromDays(45)); } } } }