prices = self.data.History(self.data.var["stocks"], 10, Resolution.Minute) prices = prices['close'] ret_mean = prices.pct_change().mean() msg = np.array2string(ret_mean,separator=',') msg2 = prices.pct_change().to_string() self.data.Log("ret pct_change " + msg2) self.data.Log("ret_mean " + msg)

 

Running this should give me an output like this:

prices.pct_change().mean() Output: prices.pct_change().mean(): Series Equity(8554 [SPY]): 0.000360162256317 Equity(19920 [QQQ]): -0.000349071472794 Equity(23921 [TLT]): -0.00105604535262 Equity(25801 [TIP]): -0.000195614219234 Equity(25485 [AGG]): -0.000227679365955

 

but it's giving me a total mean for all the stocks put together like this:

2017-01-03 09:32:00 ret pct_change symbol time AGG 2016-12-30 15:52:00 NaN 2016-12-30 15:53:00 -0.000093 2016-12-30 15:54:00 0.000000 2016-12-30 15:55:00 0.000185 2016-12-30 15:56:00 0.000000 2016-12-30 15:57:00 0.000046 2016-12-30 15:58:00 0.000046 2016-12-30 15:59:00 0.000000 2017-01-03 09:30:00 -0.003054 2017-01-03 09:31:00 0.000000 QQQ 2016-12-30 15:52:00 0.107993 2016-12-30 15:53:00 0.000085 2016-12-30 15:54:00 0.000085 2016-12-30 15:55:00 0.001100 2016-12-30 15:56:00 -0.000169 2016-12-30 15:57:00 0.000845 2016-12-30 15:58:00 0.000169 2016-12-30 15:59:00 0.000676 2017-01-03 09:30:00 0.005738 2017-01-03 09:31:00 -0.000252 SPY 2016-12-30 15:52:00 0.862178 2016-12-30 15:53:00 0.000090 2016-12-30 15:54:00 0.000135 2016-12-30 15:55:00 0.000718 2016-12-30 15:56:00 0.000045 2016-12-30 15:57:00 0.000941 2016-12-30 15:58:00 0.000313 2016-12-30 15:59:00 0.000761 2017-01-03 09:30:00 0.006263 2017-01-03 09:31:00 -0.000489 TIP 2016-12-30 15:52:00 -0.497447 2016-12-30 15:53:00 0.000000 2016-12-30 15:54:00 0.000000 2016-12-30 15:55:00 0.000000 2016-12-30 15:56:00 -0.000044 2016-12-30 15:57:00 0.000044 2016-12-30 15:58:00 -0.000044 2016-12-30 15:59:00 0.000133 2017-01-03 09:30:00 -0.001856 2017-01-03 09:31:00 0.000177 TLT 2016-12-30 15:52:00 0.051175 2016-12-30 15:53:00 -0.000168 2016-12-30 15:54:00 -0.000084 2016-12-30 15:55:00 -0.000461 2016-12-30 15:56:00 -0.000126 2016-12-30 15:57:00 0.000420 2016-12-30 15:58:00 -0.000084 2016-12-30 15:59:00 -0.000252 2017-01-03 09:30:00 -0.006127 2017-01-03 09:31:00 0.000338 2017-01-03 09:32:00 ret_mean 0.010815266655526064

 

Any ideas where I went wrong?