Hello everyone,
I am new to QC and was hoping to get some help. Trying to adapt an algorithm to QC, I am trying to create a covariance matrix but am having a hard time with the QC History Dataframes.
Here is my attempt:
hist = self.History(self.stocks, self.lookback+1, Resolution.Daily).unstack(level=0).close
hist = hist[symbols].pct_change()[1:]
covar_matrix = hist.cov
Using this code, I receive the following error while attempting to call covar_matrix.shape[0] (to determine the number of symbols being analyzed):
QuantConnect.Scheduling.ScheduledEventException: In Scheduled Event 'SPY: MonthEnd: SPY: 15 min before MarketClose', ---> System.Exception: AttributeError : 'function' object has no attribute 'shape' ---> Python.Runtime.PythonException: AttributeError : 'function' object has no attribute 'shape'
at Python.Runtime.PyObject.Invoke (Python.Runtime.PyObject[] args) [0x00035] in <945e8bed1d5b4491a3fcef472d4dd5dc>:0
at QuantConnect.Scheduling.ScheduleManager+<>c__DisplayClass15_0.b__0 (System.String name, System.DateTime time) [0x00006] in <08e06e9d6cbe44de803fb98b16360adf>:0
at QuantConnect.Scheduling.ScheduledEvent.OnEventFired (System.DateTime triggerTime) [0x00029] in <08e06e9d6cbe44de803fb98b16360adf>:0
--- End of inner exception stack trace ---
--- End of inner exception stack trace ---
Can you help me solve this error and correct the format of the covariance matrix?
Any assistance is greatly appreciated. Thank you!
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!