I try to move my algo from QuantOpian to QC. One of my algos uses fetch_csv() and I do as follow here by QC:

class BasicTemplateAlgorithm(QCAlgorithm):

    def Initialize(self):
        # Set the cash we'd like to use for our backtest
        # This is ignored in live trading 
        self.SetCash(100000)
        
        # Start and end dates for the backtest.
        # These are ignored in live trading.
        self.SetStartDate(2017,1,1)
        self.SetEndDate(2017,1,1)
        
        # Add assets you'd like to see
        self.spy = self.AddEquity("SPY")

        vixUrl = 'http://www.cboe.com/publish/scheduledtask/mktdata/datahouse/vixcurrent.csv'
        fetch_csv(vixUrl, 
              symbol='VIX', 
              skiprows=1,
              date_column='Date', 
              pre_func=addFieldsVIX,
              post_func=shift_data)

    def OnData(self, slice):
        # Simple buy and hold template
        if not self.Portfolio.Invested:
            self.SetHoldings(self.spy, 1)
            self.Debug("numpy test >>> print numpy.pi: " + str(np.pi))

 

As I complie the program it says it is successful. I find this is quite strange since the function addFieldsVIX and shift_data in fetch_csv() are not yet coded. If I compile this by QuantOpian, I will get error that these both functions are not yet defined.

Then I start the Backtest and from right now I get error message:

Failed to initialize algorithm: Initialize(): Python.Runtime.PythonException: NameError : global name 'fetch_csv' is not defined
at Python.Runtime.PyObject.Invoke (Python.Runtime.PyTuple args, Python.Runtime.PyDict kw) [0x00033] in <14452d8e618b4a588d1da22cca9cdbfe>:0
at Python.Runtime.PyObject.InvokeMethod (System.String name, Python.Runtime.PyTuple args, Python.Runtime.PyDict kw) [0x00007] in <14452d8e618b4a588d1da22cca9cdbfe>:0
at Python.Runtime.PyObject.TryInvokeMember (System.Dynamic.InvokeMemberBinder binder, System.Object[] args, System.Object& result) [0x0003e] in <14452d8e618b4a588d1da22cca9cdbfe>:0
at (wrapper dynamic-method) System.Object:CallSite.Target (System.Runtime.CompilerServices.Closure,System.Runtime.CompilerServices.CallSite,object)
at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid1[T0] (System.Runtime.CompilerServices.CallSite site, T0 arg0) [0x0011d] in <63992662b765477a898ef49cdcc99ee2>:0
at QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper.Initialize () [0x00045] in <c6cfed4e549c48eeb4dd0cdf4703b650>:0
at QuantConnect.Lean.Engine.Setup.BacktestingSetupHandler+<>c__DisplayClass19_0.<Setup>b__0 () [0x00053] in <55fffdae2c13477494bf8667b6c09ec3>:0