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
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
0
Tracking Error
0
Treynor Ratio
0
Total Fees
$0.00
//Universe Selection and Past Bars - tester 

using System;
using System.Collections.Generic;
using System.Linq;
using QuantConnect.Data;
using QuantConnect.Data.Consolidators;
using QuantConnect.Data.Market;
using QuantConnect.Indicators;

namespace QuantConnect 
{   
    /*
    *   The underlying QCAlgorithm class has many methods which enable you to use QuantConnect.
    *   We have explained some of these here, but the full base class can be found at:
    *   https://github.com/QuantConnect/Lean/tree/master/Algorithm
    */
    public class UniverseSelectionandPastBarsAlgorithm : QCAlgorithm 
    {
    	public readonly TimeSpan BarPeriod = TimeSpan.FromDays(1);	//Daily data
        public readonly int SimpleMovingAveragePeriod = 10;
        public readonly int RollingWindowSize = 10;
        
        private SecurityChanges _changes = SecurityChanges.None;
        
        // Holds all of our data keyed by each symbol
        public readonly Dictionary<string, SymbolData> Data = new Dictionary<string, SymbolData>();
        
        public override void Initialize() 
        {
        	SetStartDate(2018, 05, 7);         
            SetEndDate(2018, 05, 8);
            SetCash(25000);
            UniverseSettings.Leverage = 1.0m;
            UniverseSettings.Resolution = Resolution.Daily;
            AddUniverse(Universe.DollarVolume.Top(5));
        }

        public void OnData(TradeBars data) //	New data arrives here.
        {
        	foreach (var universe in UniverseManager.Values) {
			    if (universe is UserDefinedUniverse) {continue;}
			    
			    Debug (String.Format("====Symbols Count {0}", universe.Members.Keys.Count())); //How many symbols from universe 
			    
			    if (_changes == SecurityChanges.None)
            	{
            		Debug ("No Changes");
            		return;
            	}
			    
			    
			    foreach (Symbol symbol in universe.Members.Keys){
			    		Securities[symbol].SetDataNormalizationMode(DataNormalizationMode.Raw);
			    		Data.Add(symbol, new SymbolData(symbol, BarPeriod, RollingWindowSize));
        				
        				
        				Debug (String.Format("{0} - OHLC[{1:0.00}, {2:0.00}, {3:0.00}, {4:0.00}, {5:0}]",  
        				symbol, data[symbol].Open, data[symbol].High, data[symbol].Low,
        				data[symbol].Close, data[symbol].Volume));
        		}
			}
        }
 
 
 // Contains data pertaining to a symbol in our algorithm
        public class SymbolData
        {
            
            // This symbol the other data in this class is associated with
            
            public readonly Symbol Symbol;
            // A rolling window of data, data needs to be pumped into Bars by using Bars.Update( tradeBar ) and
            // can be accessed like:
            //  mySymbolData.Bars[0] - most first recent piece of data
            //  mySymbolData.Bars[5] - the sixth most recent piece of data (zero based indexing)
            
            public readonly RollingWindow<TradeBar> Bars;
            public readonly TimeSpan BarPeriod;
            public SimpleMovingAverage SMA;

            // Initializes a new instance of SymbolData
            public SymbolData(Symbol symbol, TimeSpan barPeriod, int windowSize)
            {
                Symbol = symbol;
                BarPeriod = barPeriod;
                //Bars = new RollingWindow<IBaseDataBar>(windowSize); original
                Bars = new RollingWindow<TradeBar>(windowSize);
            }

            
            // Returns true if all the data in this instance is ready (indicators, rolling windows, ect...)
            public bool IsReady
            {
                get { return Bars.IsReady && SMA.IsReady; }
            }

            
            // Returns true if the most recent trade bar time matches the current time minus the bar's period, this
            // indicates that update was just called on this instance
            // <param name="current">The current algorithm time</param>
            // <returns>True if this instance was just updated with new data, false otherwise</returns>
            public bool WasJustUpdated(DateTime current)
            {
                return Bars.Count > 0 && Bars[0].Time == current - BarPeriod;
            }
        }
 
 
 	/// <summary>
        /// Event fired each time the we add/remove securities from the data feed
        /// </summary>
        /// <param name="changes">Object containing AddedSecurities and RemovedSecurities</param>
        public override void OnSecuritiesChanged(SecurityChanges changes)
        {
            _changes = changes;
        }
 
    } //BasicTemplateAlgorithm 
}  //namespace