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.532
Tracking Error
0.161
Treynor Ratio
0
Total Fees
$0.00
Estimated Strategy Capacity
$0
Lowest Capacity Asset
namespace QuantConnect.Algorithm.CSharp
{
    public class ClientAlgorithm : QCAlgorithm
    {
    	// BACKTESTING PARAMETERS
    	// =================================================================================================================
    	
    	// general settings:
    	
    	// set starting cash
    	private int startingCash = 100000;
    	
    	// backtesting start date time:
    	// date setting variables
    	private int startYear = 2006;
    	private int startMonth = 1;
    	private int startDay = 1;
    	
    	// backtesting end date time:
    	// determines whether there is a specified end date
    	// if false it will go to the current date (if 'true' it will go to the specified date)
    	private bool enableEndDate = false;
    	// date setting variables
    	private int endYear = 2020;
    	private int endMonth = 1;
    	private int endDay = 5;
    	
    	
    	// universe settings:
    	
    	// data update resolution
    	// changes how often the data updates and algorithm looks for entry
    	// determines how often the function OnData runs
    	// list of resolutions:
    	// Resolution.Tick; Resolution.Second; Resolution.Minute; Resolution.Hour; Resolution.Daily
    	private readonly Resolution resolution = Resolution.Daily;
    	
    	// stock list for equities
    	// list of equities you want in the universe
    	// used in manual selection of universe
    	// set selectionType = false for activation
    	private readonly String[] manualUniverse = new String[]{
    			"SPY"
    	};
    	
    	
    	// position settings:
    	
    	// percent of portfolio to enter a position with
    	// note this value is recommended to be < 1 / manualUniverse.Count()
    	private readonly decimal portfolioAllocation = 1m;
    	
    	// number of securities to invest in
    	// note this will split the portfolioAllocation evenly among them
    	private readonly int stockCount = 5;
    	
    	
    	// indicator settings:
    	
    	
    	// =================================================================================================================
		
		// creates new universe variable setting
		private Dictionary<Symbol, SymbolData> universe = new Dictionary<Symbol, SymbolData>();
		
		// security changes variable
		private SecurityChanges securityChanges = SecurityChanges.None;
		
		// define offset universe to avoid first candle
		private bool offsetUniverse = true;
		
        public override void Initialize()
        {
        	// set start date
            SetStartDate(startYear, startMonth, startDay);
            // set end date
            if(enableEndDate)
            	SetEndDate(endYear, endMonth, endDay);
            // set starting cash
            SetCash(startingCash);
            
            foreach(string s in manualUniverse) {
            	AddEquity(s, resolution);
            }
        }

		// filter based on CoarseFundamental
	    public IEnumerable<Symbol> CoarseFilterFunction(IEnumerable<CoarseFundamental> coarse) {
	    	// returns the highest DollarVolume stocks
	    	// returns "totalNumberOfStocks" amount of stocks
	        return (from stock in coarse
	        		where !stock.HasFundamentalData
	        		orderby stock.DollarVolume descending
	        		select stock.Symbol).Take(stockCount);
        	return Universe.Unchanged;
	    }
	    
	    // empty since we consolidate bars
		public override void OnData(Slice data) {
			foreach(var symbol in data.Keys) {
				SymbolData sd = universe[symbol];
			}
		}
        
        // OnSecuritiesChanged runs when the universe updates current securities
        public override void OnSecuritiesChanged(SecurityChanges changes) {
            securityChanges = changes;
            // remove stocks from list that get removed from universe
            foreach (var security in securityChanges.RemovedSecurities) {
            	if(Securities[security.Symbol].Invested) {
            		Log($"{Time}->Portfolio: Liquidated security {security.Symbol} on universe exit");
            		Liquidate(security.Symbol);
            	}
            	
            	universe.Remove(security.Symbol);
            	Log($"{Time}->Universe: Removed security {security.Symbol} from universe");
            }
            
            // add new securities to universe list
            foreach(var security in securityChanges.AddedSecurities) {
            	
            	// create SymbolData variable for security
            	SymbolData sd = new SymbolData();
            	
            	// initalize data points:
            	sd.Algorithm = this;
            	sd.Symbol = security.Symbol;
            	
            	// add SymbolData to universe
            	universe.Add(security.Symbol, sd);
            }
        }
		
		// default class containing all symbol information
		public class SymbolData {
			// Variables:
			// algorithm
			public ClientAlgorithm Algorithm;
			// stock symbol
			public string Symbol = "";
		}
    }
}