Overall Statistics |
Total Orders 42 Average Win 0.53% Average Loss -0.20% Compounding Annual Return -1.241% Drawdown 4.400% Expectancy -0.613 Net Profit -2.469% Sharpe Ratio -1.88 Sortino Ratio -1.343 Probabilistic Sharpe Ratio 0.187% Loss Rate 89% Win Rate 11% Profit-Loss Ratio 2.62 Alpha -0.023 Beta -0.017 Annual Standard Deviation 0.014 Annual Variance 0 Information Ratio -0.929 Tracking Error 0.214 Treynor Ratio 1.469 Total Fees $43.92 Estimated Strategy Capacity $180000000.00 Lowest Capacity Asset ZM X3RPXTZRW09X Portfolio Turnover 0.39% |
#region imports using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Globalization; using System.Drawing; using QuantConnect; using System.Text.RegularExpressions; using QuantConnect.Algorithm.Framework; using QuantConnect.Algorithm.Framework.Selection; using QuantConnect.Algorithm.Framework.Alphas; using QuantConnect.Algorithm.Framework.Portfolio; using QuantConnect.Algorithm.Framework.Execution; using QuantConnect.Algorithm.Framework.Risk; using QuantConnect.Algorithm.Selection; using QuantConnect.Parameters; using QuantConnect.Benchmarks; using QuantConnect.Brokerages; using QuantConnect.Util; using QuantConnect.Interfaces; using QuantConnect.Algorithm; using QuantConnect.Indicators; using QuantConnect.Data; using QuantConnect.Data.Consolidators; using QuantConnect.Data.Custom; using QuantConnect.DataSource; using QuantConnect.Data.Fundamental; using QuantConnect.Data.Market; using QuantConnect.Data.UniverseSelection; using QuantConnect.Notifications; using QuantConnect.Orders; using QuantConnect.Orders.Fees; using QuantConnect.Orders.Fills; using QuantConnect.Orders.Slippage; using QuantConnect.Scheduling; using QuantConnect.Securities; using QuantConnect.Securities.Equity; using QuantConnect.Securities.Future; using QuantConnect.Securities.Option; using QuantConnect.Securities.Forex; using QuantConnect.Securities.Crypto; using QuantConnect.Securities.Interfaces; using QuantConnect.Storage; using QCAlgorithmFramework = QuantConnect.Algorithm.QCAlgorithm; using QCAlgorithmFrameworkBridge = QuantConnect.Algorithm.QCAlgorithm; #endregion using QuantConnect.DataSource; namespace QuantConnect { public class ExtractAlphaEstimizeAlgorithm : QCAlgorithm { private DateTime _time = DateTime.MinValue; public override void Initialize() { SetStartDate(2019, 1, 1); SetEndDate(2020, 12, 31); SetCash(100000); AddUniverse(MyCoarseFilterFunction); UniverseSettings.Resolution = Resolution.Minute; } private IEnumerable<Symbol> MyCoarseFilterFunction(IEnumerable<CoarseFundamental> coarse) { return (from c in coarse where c.HasFundamentalData && c.Price > 4 orderby c.DollarVolume descending select c.Symbol).Take(500); } public override void OnData(Slice slice) { if (_time > Time) return; // Accessing Data var consensus = slice.Get<EstimizeConsensus>(); var estimate = slice.Get<EstimizeEstimate>(); var release = slice.Get<EstimizeRelease>(); if (estimate.IsNullOrEmpty()) return; var sortedByEpsEstimate = from value in estimate.Values where (value.Eps != null) orderby value.Eps descending select value.Symbol.Underlying; var longSymbols = sortedByEpsEstimate.Take(10).ToList(); var shortSymbols = sortedByEpsEstimate.TakeLast(10).ToList(); foreach (var kvp in Portfolio) { var symbol = kvp.Key; if (kvp.Value.Invested && !longSymbols.Contains(symbol) && !shortSymbols.Contains(symbol)) { Liquidate(symbol); } } var targets = new List<PortfolioTarget>(); targets.AddRange(longSymbols.Select(symbol => new PortfolioTarget(symbol, 0.05m))); targets.AddRange(shortSymbols.Select(symbol => new PortfolioTarget(symbol, -0.05m))); SetHoldings(targets); _time = Expiry.EndOfMonth(Time); } public override void OnSecuritiesChanged(SecurityChanges changes) { foreach(var security in changes.AddedSecurities) { // Requesting Data var consensusSymbol = AddData<EstimizeConsensus>(security.Symbol).Symbol; var estimateSymbol = AddData<EstimizeEstimate>(security.Symbol).Symbol; var releaseSymbol = AddData<EstimizeRelease>(security.Symbol).Symbol; // Historical Data var history = History(new[]{ consensusSymbol, estimateSymbol, releaseSymbol }, 10, Resolution.Daily); Debug($"We got {history.Count()} items from our history request"); } } } }