Overall Statistics
Total Trades
49
Average Win
0.90%
Average Loss
-0.52%
Compounding Annual Return
2.972%
Drawdown
4.400%
Expectancy
1.053
Net Profit
12.420%
Sharpe Ratio
0.482
Loss Rate
25%
Win Rate
75%
Profit-Loss Ratio
1.74
Alpha
-0.094
Beta
6.269
Annual Standard Deviation
0.065
Annual Variance
0.004
Information Ratio
0.175
Tracking Error
0.065
Treynor Ratio
0.005
Total Fees
$0.00
namespace Sandbox.DualConsolidation
{
    public class DualConsolidation : QCAlgorithm
    {
        private const string VIX = "CBOE/VIX";
        private const string VXV = "CBOE/VXV";
        private SimpleMovingAverage smaVIX;
        private SimpleMovingAverage smaVXV;
        private IndicatorBase<IndicatorDataPoint> ratio_VXV_VIX;

        public override void Initialize()
        {
            SetStartDate(2014, 1, 1);
			SetEndDate(2018, 1, 1);
			SetCash(25000);
            // request data
            AddData<QuandlVix>(VIX, Resolution.Daily);
            AddData<Quandl>(VXV, Resolution.Daily);

            // these are really just 'identities' of the closing price
            smaVIX = SMA(VIX, 1);
            smaVXV = SMA(VXV, 1);
            ratio_VXV_VIX = smaVXV.Over(smaVIX);
        }
        

        public void OnData(Quandl data)
        {
	
            if (smaVIX.IsReady && smaVXV.IsReady && ratio_VXV_VIX.IsReady)
            {
            	if (!Portfolio.Invested && ratio_VXV_VIX > 1){
            		MarketOrder(VIX, 100);
            	}
            	else if(ratio_VXV_VIX < 1){
            		Liquidate();
            	}
            	
                Plot("Data", smaVIX, smaVXV);
                Plot("Ratio", ratio_VXV_VIX);
            }
        }

    }
    public class QuandlVix : Quandl 
    {
    	public QuandlVix() : base(valueColumnName: "vix close") { }
    }
}