Overall Statistics |
Total Trades 1 Average Win 0% Average Loss 0% Compounding Annual Return -14.460% Drawdown 9.400% Expectancy 0 Net Profit -6.376% Sharpe Ratio -1.049 Probabilistic Sharpe Ratio 4.920% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha -0.011 Beta 0.456 Annual Standard Deviation 0.094 Annual Variance 0.009 Information Ratio 0.843 Tracking Error 0.112 Treynor Ratio -0.217 Total Fees $1.00 Estimated Strategy Capacity $5600000.00 Lowest Capacity Asset VOO UPSZVZA9EQUD |
#region imports using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Globalization; using System.Drawing; using QuantConnect; 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.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.Interfaces; using QuantConnect.Storage; using QuantConnect.Data.Custom.AlphaStreams; using QCAlgorithmFramework = QuantConnect.Algorithm.QCAlgorithm; using QCAlgorithmFrameworkBridge = QuantConnect.Algorithm.QCAlgorithm; #endregion namespace QuantConnect.Algorithm.CSharp { public class UglyLightBrownFlamingo : QCAlgorithm { bool addedConsolidator = false; string symbolString = "VOO"; private void DebugAndLog(string message) { Debug(message); Log(message); } public override void Initialize() { SetStartDate(2022, 1, 1); //Set Start Date SetCash(100000); var universe = Universe.DollarVolume.Top(20); AddUniverse(universe); // Everyday we try and add a consolidator to the symbol minutely TradeBar subscription, if part of the universe, and we do that JUST ONCE Schedule.On(DateRules.EveryDay(), TimeRules.At(TimeSpan.FromHours(9)), () => { if (!addedConsolidator) { var symbol = UniverseManager[universe.Configuration.Symbol].Members.Keys.FirstOrDefault(m => m.Value == symbolString); if ( symbol != null) { var consolidator = new TradeBarConsolidator(TimeSpan.FromMinutes(15)); SubscriptionManager.AddConsolidator(symbol,consolidator); addedConsolidator = true; } } }); } public override void OnData(Slice data) { var symbol = data.Keys.FirstOrDefault(s => s.Value == symbolString); if (symbol != null && !Portfolio[symbol].Invested && Time.DayOfYear == 12 && Time.Hour == 10 && Time.Minute == 4) { SetHoldings(symbol, 0.5); } if(Time.Minute == 0 && Time.Hour == 12) { var consolidator = (TradeBarConsolidator)SubscriptionManager.Subscriptions.FirstOrDefault(s => s.TickType == TickType.Trade && s.Symbol.Value == symbolString)?.Consolidators.FirstOrDefault(); var security = ActiveSecurities.Values.FirstOrDefault(s => s.Symbol.Value == symbolString); string securityActive = security != null ? "security ACTIVE" : "security NOT ACTIVE"; decimal quantity = symbol != null && Portfolio.ContainsKey(symbol) ? Portfolio[symbol].Quantity : 0; if(consolidator != null) { DebugAndLog($"{Time}: CONSOLIDATOR FOUND, portfolio quantity {quantity}, {securityActive}"); } else { DebugAndLog($"{Time}: CONSOLIDATOR MISSING, portfolio quantity {quantity}, {securityActive}"); } } } } }