Hi,
I have the following csv files I upload to the program:
def pre_func(df): # Create 10 MA
value = df['Price']
df['mean'] = pd.rolling_mean(value, 10)
log.info(df)
return df
def initialize(context):
bpnya_url = 'https://docs.google.com/spreadsheets/d/1sNBGpQH1mjd0uxqxPVC1kss4haFvGn9IAVbhKFXakYw/pub?output=csv'
fetch_csv(bpnya_url, pre_func = pre_func )
the dataframe looks like:
date symbol Price mean
0 1/2/1987 BPNYA 22.175 NaN
1 1/5/1987 BPNYA 23.312 NaN
2 1/6/1987 BPNYA 23.288 NaN
3 1/7/1987 BPNYA 24.447 NaN
4 1/8/1987 BPNYA 25.606 NaN
5 1/9/1987 BPNYA 26.765 NaN
6 1/12/1987 BPNYA 28.029 NaN
7 1/13/1987 BPNYA 29.189 NaN
8 1/14/1987 BPNYA 30.842 NaN
9 1/15/1987 BPNYA 32.210 26.5863
10 1/16/1987 BPNYA 32.632 27.6320
11 1/19/1987 BPNYA 32.421 28.5429
12 1/20/1987 BPNYA 33.158 29.5299
13 1/21/1987 BPNYA 33.895 30.4747
How come I always get nothing (nan) when I do
def handle_data(context,data):
current_price = data.current('BPNYA', 'Price')
current_mean = data.current('BPNYA', 'mean')
record(price = current_price, mean = current_mean)