Options with Quandl Vix Data

When running an algorithm which uses both options and external data I get the following error:

Runtime Error: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: The best overloaded method match for `System.Collections.Generic.KeyValuePair<QuantConnect.Symbol,QuantConnect.Data.BaseData>.KeyValuePair(QuantConnect.Symbol, QuantConnect.Data.BaseData)' has some invalid arguments

If I remove either the option chain or the external data (Quandl Vix future in this example) from the Initialize, it works fine. How can I resolve this conflict when using both?

Update Backtest

And a backtest with both options and external data


from clr import AddReference

from System import *
from QuantConnect import *
from QuantConnect.Algorithm import *
from QuantConnect.Indicators import *
from QuantConnect.Securities.Option import OptionPriceModels
from QuantConnect.Python import PythonQuandl # quandl data not CLOSE
from QuantConnect.Python import PythonData
import pandas as pd; import numpy as np
import datetime as dt
from datetime import timedelta
import decimal as d
from collections import deque # double queue container
from my_custom_data import * # QuandlFuture, CboeVix, CboeVxV

symbolStr = "UVXY"

# for using VIX futures settle in calc. ratios like VIX/VIX1
class QuandlFuture(PythonQuandl):
'''Custom quandl data type for setting customized value column name.
Value column is used for the primary trading calculations and charting.'''
def __init__(self):
# Define ValueColumnName: cannot be None, Empty or non-existant column name
# If ValueColumnName is "Close", do not use PythonQuandl, use Quandl:
# self.AddData[QuandlFuture](self.VIX1, Resolution.Daily)
self.ValueColumnName = "Settle"

class myAlgo(QCAlgorithm):
''' This example demonstrates how to get access to options history for a given underlying equity security.'''

def Initialize(self):
# this test opens position in the first day of trading, lives through stock split (7 for 1), and closes adjusted position on the second day
self.SetStartDate(2014, 01, 22) # reverse split on 24th
self.SetEndDate(2017, 11, 16)

# # add option and equity
equity = self.AddEquity(symbolStr, Resolution.Minute)
option = self.AddOption(symbolStr, Resolution.Minute)

# # set data and price model modes

self.symbol = option.Symbol

# filter options
option.SetFilter(-2,2, timedelta(300), timedelta(600))

# set benchmark

self.VIX1 = "SCF/CBOE_VX1_ON"
self.AddData(QuandlFuture, self.VIX1, Resolution.Daily)

Had to insert the code like this since backtests with errors can't be attached.


The strategy I want to implement is based on Alex' simple VIX strategy, but selling call spreads or buying put options on UVXY, to limit risk. However if I simply add 

option = self.AddOption("UVXY")

in Initialize to be able to trade options, I get the following error once the backtest hits March 20, 2012.

Runtime Error: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: The best overloaded method match for `System.Collections.Generic.KeyValuePair<QuantConnect.Symbol,QuantConnect.Data.BaseData>.KeyValuePair(QuantConnect.Symbol, QuantConnect.Data.BaseData)' has some invalid arguments

Unfortunately this runtime error prevents me from attaching the backtest here, any ideas on how to fix it?


Update Backtest


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.


This discussion is closed