Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Fetch_csv question, why can't I access the new signal after fetch_csv?

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)  
2 responses

Why do I see a message of this?

1969-12-31 WARN Dropped 3292 rows from fetched csv.  

Is it because of the datetime format? How to convert 1/30/2000 to the right one for quantopian?

Hi HP,

Thanks for posting. It looks like the entire file is being dropped by fetch_csv, because BPNYA is not an equity in our database. If you're intending to use this as a signal as opposed to pricing data for an equity, I would recommend that you look at the Fetcher section of the help page, which talks about how to use the .csv data as a signal.

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.