Back

It is possible to trade on Vix options?

Hi

I'm unsure of the syntax to get vix options chain...or even the futures chain..
I tried daily resolution as I read QC does not have minute data... which I fine since I dont make decision based on VIX directly

But then how do I get the options? From the future object, from the Futures.Index.Vix...

I tried multiple combinations with no luck my chains are always empty... is it not meant to work? or am I doing anything wrong.. any code sample would be appreciated! Also does anyone know why are options backtest so painfully slow to launch?
here is what i did:
namespace QuantConnect
{
public class VixStrength : QCAlgorithm
{
private const string SYMBOL = "SVXY";
private int barCounter = 0;

private OptionContract currentOpt = null;

public override void Initialize()
{
// backtest parameters
//SetWarmUp(TimeSpan.FromDays(3));

SetStartDate(year:2017, month:7, day:28);
SetEndDate(year:2017, month:8, day:1);
//SetEndDate(DateTime.Now);


// cash allocation
SetCash(100000);

//which equity
AddEquity(VixStrength.SYMBOL, Resolution.Minute);

var fut = AddFuture(Futures.Indices.VIX, Resolution.Daily);
var option = AddOption(Futures.Indices.VIX, Resolution.Daily);
option.SetFilter(universe => from symbol in universe
.Expiration(TimeSpan.FromDays(4), TimeSpan.FromDays(15))
where symbol.ID.OptionRight == OptionRight.Call &&
universe.Underlying.Price < symbol.ID.StrikePrice
select symbol);



}


private OptionContract GetBestOption(Slice slice)
{
//trying to figure out what is going on
foreach (var k in slice.FuturesChains.Keys)//just making sure there is something there
Debug("fut chain " + k);

foreach (var k in slice.OptionChains.Keys)//just making sure there is something there
Debug("opt chain " + k);

FuturesChain futChain;
slice.FutureChains.TryGetValue(Futures.Indices.VIX, out futChain);
if (futChain == null)
{
Debug("no futures");
}
else
{
//var fut = (from f in futChain.OrderBy(x => x.Expiry) select f).FirstOrDefault();
//Debug(fut.Symbol);
OptionChain chain;
var optionSymbol = QuantConnect.Symbol.Create(Futures.Indices.VIX, SecurityType.Option, Market.USA);
Debug(optionSymbol);
Debug("********");
if (slice.OptionChains.TryGetValue(optionSymbol, out chain))
{
Debug("Yeahhh key exists");
var contract = (
from optionContract in chain
.OrderBy(x => x.Strike)
.OrderBy(x => x.Expiry)
select optionContract
).FirstOrDefault();
Debug(contract.Symbol);
return contract;
}
else
{
Debug("no options");
}
}
return null;
}

public override void OnData(Slice data)
{
barCounter+=1;
if (!data.Bars.ContainsKey(VixStrength.SYMBOL))
return;

if (barCounter == 30)
Debug("GetBestOption");
currentOpt = GetBestOption(data);
return;

}

}
}


 thanks

Update Backtest








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