Not sure what you're trying to do
I'm trying to get a sum of more than two time series objects and use result. It doesn't matter how to use it as it's not possible to get the sum in Quantopian. For example if I want to calculate mean and standard deviation of the result I'd do it like this using pandas:
from pandas import Series
from datetime import datetime
import numpy as np
dates = [datetime(2012, 5, 1), datetime(2012, 5, 2), datetime(2012, 5, 3)]
ts = Series(np.random.randn(3), dates) + Series(np.random.randn(3), dates) + Series(np.random.randn(3), dates)
print ts.mean(), ts.std()
0.478376431986 0.507340148737
However, Quantopian raises weird exception on the similar code.
Here is another Quantopian example, hopefully better one:
def initialize(context):
context.qqq = symbol('QQQ')
context.spy = symbol('SPY')
context.iwm = symbol('IWM')
def handle_data(context, data):
prices = history(bar_count=2, frequency='1d', field='price')
ts = prices[context.qqq] + prices[context.spy] + prices[context.iwm]
print ts.mean(), ts.std()
Any code, containing adding more than two different time series raises runtime exception: TypeError: int() argument must be a string or a number, not 'NoneType'
Regards,
Ed