Back

Using Consolidator and EMA for Quandl Data

Hi all, 

I am trying to have my stragety to run on two resolution, second and daily. Went to some of the good posts from Michael, but I am unfortunately stuck on 

  1. Cannot find ResolveConsolidator lib
  2. Or if I am using the right indicator for quandl data 
  3. And levergage with EMA (add and udpate EMA)
Update Backtest








I guessed that I could not attach backtest with the runtime error

Failed to initialize algorithm: Initialize(): Python.Runtime.PythonException: NameError : name 'ResolveConsolidator' is not defined
at QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.Initialize () [0x00045] in <2065e8e0d4584e7db60b4118fb8f00d8>:0
at QuantConnect.Lean.Engine.Setup.BacktestingSetupHandler+<>c__DisplayClass19_0.<Setup>b__0 () [0x0007c] in <70b4d6c40a9a4eaf8468e63c5ee127dc>:0 (Open Stacktrace)

from clr import AddReference # .NET Common Language Runtime (CLR) <- http://pythonnet.github.io/
AddReference("System")
AddReference("QuantConnect.Algorithm") # to load an assembly use AddReference
AddReference("QuantConnect.Common")

from QuantConnect.Algorithm import *
from QuantConnect.Data import *

import pandas as pd
from collections import deque # double queue container

from my_custom_data import * # QuandlFuture, CboeVix, CboeVxV
import decimal

class MyAlgorithm(QCAlgorithm):
def Initialize(self):
'''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.'''

self.SetStartDate(2013,1,1) #Set Start Date
self.SetEndDate(2013,11,1) #Set End Date
self.SetCash(100000) #Set Strategy Cash
# Find more symbols here: http://quantconnect.com/data
self.AddEquity("SPY", Resolution.Second)

# consolidator = TradeBarConsolidator(timedelta(1))
# consolidator.DataConsolidated += self.OnDailyData
# self.SubscriptionManager.AddConsolidator("SPY", consolidator)

# self.daily = RollingWindow[TradeBar](2)
# self.window = RollingWindow[TradeBar](2)


self.initRollingWindow()

def initRollingWindow(self):
self.vix_symbol = "CBOE/VIX"
self.vxv_symbol = "CBOE/VXV"
vix_symbol = self.AddData(QuandlVix, self.vix_symbol, Resolution.Daily)
vxv_symbol = self.AddData[Quandl](self.vxv_symbol, Resolution.Daily)

barPeriod = timedelta(1)
# This is the number of consolidated bars we'll hold in symbol data for reference
rollingWindowSize = 10

self.Data = {}
self.Data[self.vix_symbol] = SymbolData(vix_symbol, barPeriod, rollingWindowSize)
self.Data[self.vix_symbol] = SymbolData(vxv_symbol, barPeriod, rollingWindowSize)

for symbol, symbolData in self.Data.items():
self.Debug("symbol: %s"%(symbol))
# define a consolidator to consolidate data for this symbol on the requested period
consolidator = ResolveConsolidator(symbol, Resolution.Daily);
# consolidator = TradeBarConsolidator(barPeriod) # if symbolData.Symbol.SecurityType == SecurityType.Equity else QuoteBarConsolidator(BarPeriod)
# write up our consolidator to update the indicator
consolidator.DataConsolidated += self.OnDataConsolidated
# we need to add this consolidator so it gets auto updates
self.SubscriptionManager.AddConsolidator(symbolData.Symbol, consolidator)
# symbolData.EMA = self.EMA(symbol, rollingWindowSize)
0

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