Overall Statistics |
Total Orders 13341 Average Win 0.02% Average Loss -0.01% Compounding Annual Return -3.240% Drawdown 13.200% Expectancy -0.115 Net Profit -4.574% Sharpe Ratio -0.467 Sortino Ratio -0.673 Probabilistic Sharpe Ratio 4.757% Loss Rate 81% Win Rate 19% Profit-Loss Ratio 3.61 Alpha -0.007 Beta -0.281 Annual Standard Deviation 0.089 Annual Variance 0.008 Information Ratio -0.55 Tracking Error 0.299 Treynor Ratio 0.149 Total Fees $13219.00 Estimated Strategy Capacity $1900000.00 Lowest Capacity Asset JG WWHT0YOVJBL1 Portfolio Turnover 2.77% |
#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 namespace QuantConnect { public class QuiverWallStreetBetsDataAlgorithm : QCAlgorithm { public override void Initialize() { SetStartDate(2019, 1, 1); SetEndDate(2020, 6, 1); SetCash(100000); UniverseSettings.Resolution = Resolution.Daily; // add a custom universe data source (defaults to usa-equity) AddUniverse<QuiverWallStreetBetsUniverse>("QuiverWallStreetBetsUniverse", Resolution.Daily, altCoarse => { foreach (var datum in altCoarse) { Log($"{datum.Symbol},{datum.Mentions},{datum.Rank},{datum.Sentiment}"); } // define our selection criteria return from d in altCoarse where d.Mentions > 10 && d.Rank < 100 select d.Symbol; }); } public override void OnData(Slice slice) { var points = slice.Get<QuiverWallStreetBets>(); foreach (var point in points.Values) { var symbol = point.Symbol.Underlying; // Buy if the stock was mentioned more than 5 times in the WallStreetBets daily discussion if (point.Mentions > 5 && !Portfolio[symbol].IsLong) { MarketOrder(symbol, 1); } // Otherwise, short sell else if (point.Mentions <= 5 && !Portfolio[symbol].IsShort) { MarketOrder(symbol, -1); } } } public override void OnSecuritiesChanged(SecurityChanges changes) { foreach(var added in changes.AddedSecurities) { // Requesting data var quiverWSBSymbol = AddData<QuiverWallStreetBets>(added.Symbol).Symbol; // Historical data var history = History<QuiverWallStreetBets>(quiverWSBSymbol, 60, Resolution.Daily); Debug($"We got {history.Count()} items from our history request"); } } } }