Back

Need help with getting VIX

Total noob here. I'm trying to get VIX close for the past 3 days and VIX current high and low but I'm getting 0's instead of the actual numbers. What am I doing wrong?

 

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.Option, "VIX", Resolution.Minute);


// Schedule an event to fire at a specific date/time
Schedule.On(DateRules.EveryDay("TQQQ"), TimeRules.BeforeMarketClose("TQQQ", 10), () =>
{
Log("SpecificTime: Fired at : " + Time);
IEnumerable<TradeBar> bars = History("VIX", TimeSpan.FromDays(3));
Decimal total = 0;
foreach(TradeBar bar in bars){
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);

});
}
Update Backtest







0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


If the algorithm is just meant to determine the value of VIX, or CBOE Volatility Index, using the VIX future data is one possible method. Here is a previous discussion regarding the VIX data.

The backtest below is a potential method for using the VIX Future data from QuantConnect:

In order to save the VIX close for the past three days, it might be worth looking into implementing a RollingWindow instead of requesting historical prices. A rolling window allows for an array of data with reverse list access semantics. Hope this information is useful.

1


Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed

 
";