Overall Statistics
Total Trades
338
Average Win
1.90%
Average Loss
-1.22%
Compounding Annual Return
9.672%
Drawdown
37.000%
Expectancy
0.446
Net Profit
135.725%
Sharpe Ratio
0.496
Loss Rate
43%
Win Rate
57%
Profit-Loss Ratio
1.56
Alpha
0.08
Beta
0.188
Annual Standard Deviation
0.185
Annual Variance
0.034
Information Ratio
0.136
Tracking Error
0.237
Treynor Ratio
0.488
Total Fees
$5282.92
using QuantConnect.Indicators;
using System;
using System.Collections.Concurrent;
namespace QuantConnect 
{   
    public class VolatilityEffect : QCAlgorithm
    {
    	public readonly ConcurrentDictionary<Symbol, StandardDeviation> _symbolsData = new ConcurrentDictionary<Symbol, StandardDeviation>();
    	public int _month = 0;
        public override void Initialize() 
        {
        	// backtest parameters
        	UniverseSettings.Leverage = 2.0m;
			UniverseSettings.Resolution = Resolution.Daily;
            SetStartDate(2008, 1, 1);         
            SetEndDate(DateTime.Now);
            SetCash(100000);
            AddUniverse( coarse =>
            		{
            			return
            			( 	
            				from cf in coarse
            				let std = _symbolsData.GetOrAdd(cf.Symbol, sym => new StandardDeviation(600))
            				where std.Update(cf.EndTime,cf.Price)
							where cf.Price > 10.0m
            				orderby cf.DollarVolume descending
            				select cf.Symbol
            			).Take(100);
            		}
            	);
        }

        public override void OnData(Slice data) 
        {
			if(Time.Month != _month)
			{
				_month = Time.Month;
				foreach(var sym in Portfolio.Keys)
				{
					Liquidate(sym);
				}
				var leastVolatile = (from _symbol in data.Keys
									orderby _symbolsData[_symbol]
									select _symbol).Take(2);
				foreach(var entry in leastVolatile)
				{
					SetHoldings(entry,0.5);
				}
			}
        }
    }
}