@Patrick,
No reason - 9 is just fine!
period9_high = float(period9_high.ix[-1]) works if the algo is only using one stock.
If you had more than one stock then its an error because pd.rolling_max returns a dataframe, so with multiple stocks, it can't convert multiple values to just one float. See this:
import pandas as pd
def initialize(context):
context.ListOfSids = symbols('AAPL', 'C')
def handle_data(context, data):
high_prices = history(9, '1d', 'high') # this is a dataframe
period9_high = pd.rolling_max(high_prices, window=9) # this returns a dataframe
print period9_high
period9_high = period9_high.ix[-1] # this returns a series (most recent 9 period high for all stocks)
print period9_high
AAPL_high = period9_high[symbol('AAPL')]
C_high = period9_high[symbol('C')]
print AAPL_high
print C_high
gives
Equity(24 [AAPL]) Equity(1335 [C])
2010-12-22 00:00:00+00:00 NaN NaN
2010-12-23 00:00:00+00:00 NaN NaN
2010-12-27 00:00:00+00:00 NaN NaN
2010-12-28 00:00:00+00:00 NaN NaN
2010-12-29 00:00:00+00:00 NaN NaN
2010-12-30 00:00:00+00:00 NaN NaN
2010-12-31 00:00:00+00:00 NaN NaN
2011-01-03 00:00:00+00:00 NaN NaN
2011-01-04 00:00:00+00:00 47.501 49.4
Equity(24 [AAPL]) 47.501
Equity(1335 [C]) 49.400
Name: 2011-01-04 00:00:00+00:00, dtype: float64
47.501
49.4
As Grant suggests, do read the help. There's loads of example algos too
James