Overall Statistics |
Total Trades 0 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Net Profit 0% Sharpe Ratio 0 Probabilistic Sharpe Ratio 0% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio -0.71 Tracking Error 0.312 Treynor Ratio 0 Total Fees $0.00 Estimated Strategy Capacity $0 |
namespace QuantConnect.Algorithm.CSharp { public class TickVolumeConsolidatorTest : QCAlgorithm { public Symbol TestSymbol; public long AccumulatedTicks; public IDataConsolidator MinuteTickConsolidator; //Consolidate Tick data into Minute bars public Resolution SymbolResolution; public override void Initialize() { SetStartDate(2020, 1, 1); //Set Start Date SetEndDate(2020, 12, 31); SetCash(100000); //Set Strategy Cash //Store the Resolution so it is a simple flag to switch between Tick and Minute for benchmarking SymbolResolution = Resolution.Tick; //Switch between Resolution.Tick and Resolution.Minute Symbol EURUSD = QuantConnect.Symbol.Create("EURUSD", SecurityType.Forex, Market.Oanda); TestSymbol = AddSecurity(EURUSD, SymbolResolution).Symbol; AccumulatedTicks = 0; if (SymbolResolution == Resolution.Tick) { //Only create the Tick Consolidator if using Tick Resolution MinuteTickConsolidator = Consolidate<QuoteBar>(TestSymbol, TimeSpan.FromMinutes(1), EventQuoteBar => { PrintQuoteBarAndTickVolume(this, EventQuoteBar, AccumulatedTicks); AccumulatedTicks = 0; //Reset AccumulatedTicks after each consolidated bar }); } } //End of Initialize() /// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here. /// Slice object keyed by symbol containing the stock data public override void OnData(Slice data) { if (SymbolResolution == Resolution.Tick) { if (data.Ticks != null) { foreach (var DataSymbol in data.Ticks.Keys) { if (DataSymbol != TestSymbol) { continue; } AccumulatedTicks += data.Ticks[TestSymbol].Count; } } } //End of Tick Resolution else { if (data.QuoteBars != null) { foreach (var DataSymbol in data.QuoteBars.Keys) { if (DataSymbol != TestSymbol) { continue; } PrintQuoteBarAndTickVolume(this, data.QuoteBars[DataSymbol], AccumulatedTicks); //AccumulatedTicks will always be 0 with non-Tick Resolution } } } //End of non-Tick Resolution } //End of OnData() public bool PrintQuoteBarAndTickVolume(QCAlgorithm algorithm, QuoteBar InQuoteBar, long InTickVolume) { if (InQuoteBar.Time.Hour == 0 && InQuoteBar.Time.Minute == 0 && InQuoteBar.Time.DayOfWeek == DayOfWeek.Monday) { //Only print once per week to avoid excessive logs algorithm.Debug(InQuoteBar.Symbol + " " + InQuoteBar.Time + ": O: " + InQuoteBar.Open + "; H: " + InQuoteBar.High + "; L: " + InQuoteBar.Low + "; C: " + InQuoteBar.Close + "; TV: " + InTickVolume); return true; } return false; } //End of PrintQuoteBarAndTickVolume() } //End of class TickVolumeConsolidatorTest } //End of namespace