I followed the API and documentation and during my backtests I'm able to pull the data I desire (VIX historical file found on CBOE). My code functions fine with the imported data during backtests and I verified that using logs and schedule functions.
I'm using .Rest and If IsLiveMode: in my import class.
Day 1 live I tried using .RemoteFile as this worked fine for the backtests. Further drilldown into the documents suggested using .Rest for live projects so I swapped it. Now on the second day the imported data still doesn't seem to be working with my live project. I read that in daily intervals the data will be imported on a 30-min basis. My first schedule order happens within the first 30-min of the trading day, so could this be the potential problem? I just need to wait a little?
Its paramound to controlling and monitoring my assets which are assigned a risk based margin model. Does anyone have any experience with importing data working for backtests but not for live trading? I would appreciate any insight.
Thank you,
Stephen
Stephen Hyer
Ok so, I was able to get my code to work. It turns out (at least in my experimental discovery) that the InLiveMode stuff interferes with IsMakretOpen("SPY") stuff. The attached code helps me pull VIX data in live mode. I would prefer if I didn't ping the server every 10 minutes, but this works on a complex set of scheduled functions. The OnData and AddData code found in the examples works as intended.
class Vix(PythonData): '''New VIX Object''' def GetSource(self, config, date, isLiveMode): #if isLiveMode: return SubscriptionDataSource("http://www.cboe.com/publish/scheduledtask/mktdata/datahouse/vixcurrent.csv", SubscriptionTransportMedium.RemoteFile); def Reader(self, config, line, date, isLiveMode): # New VIX object index = Vix() index.Symbol = config.Symbol #if isLiveMode: if not (line.strip() and line[0].isdigit()): return None try: # Example File Format: # Date, Open High Low Close Volume Turnover # 1/1/2008 7792.9 7799.9 7722.65 7748.7 116534670 6107.78 data = line.split(',') index.Time = datetime.strptime(data[0], "%m/%d/%Y") index.Value = data[4] index["Open"] = float(data[1]) index["High"] = float(data[2]) index["Low"] = float(data[3]) index["Close"] = float(data[4]) except ValueError: # Do nothing return None return index
Stephen Hyer
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.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!