Back to Community
fetcher fetch_csv question

Hi I am looking at algo that uses fetch_csv to retrieve data from quandl. The problem is that the data is often 1 day or more late. So the I will pretty much always get the NaN during live trading I think it's because it can't find today's date row. Is there a way to just pick the first row's data, no matter how old it is?

        date_column='Trade Date',  

def rename_col1(df):  
    df = df.rename(columns={'Close': 'price','Trade Date': 'Date'})  
    df = df.fillna(method='ffill')  
    df = df[['price', 'Settle','sid']]  
    # Shifting data by one day to avoid forward-looking bias  
    return df.shift(1)  
3 responses

Sort by date and select by index.

Hi Andrew, thanks for replying. I am fairly new to Pythoan/Quantopian, can you clarify a little on what you mean by select by index or if there is any sample code on how to do that? Thanks.

Eh. The way the platform wants you to get at fetched CSVs lends itself to getting NaN. Looks like you want to be getting at the head of the frame instead of a possible NaN, you want to be using data.history(assets, field, bar_count, frequency) ... I wrote a snippet to try and access the frame directly, but I got a deprecation warning that I shouldn't be accessing the data frame directly.

Something like:
price = data.history(['v_one'], 'price', 5, '1d')