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
using QuantConnect.Data;
using System;
using QuantConnect.Securities.Future;

namespace QuantConnect.Algorithm.CSharp
{
    
    public class vixalgo : QCAlgorithm
    {
    	private Future _vx;
    	private Identity _vix;
    	private IndicatorDataPoint _latestVx;
    	
        public override void Initialize()
        {
        	
			SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage, 
			AccountType.Cash);//Brokerage model and account type
            SetStartDate(2012, 10, 07);  //Set Start Date
            SetEndDate(2012, 10, 15);    //Set End Date
            SetCash(10000);             //Set Strategy Cash
            SetWarmUp(TimeSpan.FromDays(7)); //Warm up 7 days of data.
			SetBenchmark("SPY"); // Defaults to Equity market
			AddSecurity(SecurityType.Equity, "TQQQ", Resolution.Minute);
			
            _vx = AddFuture(Futures.Indices.VIX);
			_vx.SetFilter(TimeSpan.Zero, TimeSpan.FromDays(value: 182));
			_vix = new Identity("VIX");
			PlotIndicator("VIX", _vix);

			
			// Schedule an event to fire at a specific date/time
			Schedule.On(DateRules.EveryDay("TQQQ"), TimeRules.BeforeMarketClose("TQQQ", 10), () =>
			{
				Log("SpecificTime: Fired at : " + Time);
				Log(_latestVx);
				/*IEnumerable<TradeBar> bars = History("VIX", TimeSpan.FromDays(3));
				Decimal total = 0;
				foreach(TradeBar bar in bars){
					Log(bar.ToString());
					Log("bar close: " + bar.Close);
					total += bar.Close;
				}
				total /= 3;
				var dailyVixHigh = Identity("VIX", Resolution.Daily, Field.High);
				var dailyVixLow = Identity("VIX", Resolution.Daily, Field.Low);
				Log("vix high: " + dailyVixHigh);
				Log("vix low: " + dailyVixLow);
				*/
	
			});
        }

        public override void OnData(Slice slice)
        {
         	if (slice.FutureChains.ContainsKey(_vx.Symbol))
            {
                var vixContract = slice.FutureChains[_vx.Symbol].OrderBy(x => x.Expiry).FirstOrDefault();
                if (vixContract != null)
                {
                    _latestVx = new IndicatorDataPoint(Time, vixContract.LastPrice);
                }
            }
        }
    }
}