Back to Community
fetch_csv() is not importing minutes correctly

Hello! I have seen a few other posts here related to this, but none of the answers seemed to help me.
I have a CSV that is hosted at a URL, and it has prices for a signal on a 5 minutes interval. The first few rows are something like:

Date,Value  
2017-08-01 03:45:00,207.79  
2017-08-01 03:50:00,208.02  
2017-08-01 03:55:00,208.55  
2017-08-01 04:00:00,209.75  
2017-08-01 04:05:00,213.84  
2017-08-01 04:10:00,213.35  
2017-08-01 04:15:00,212.61  
2017-08-01 04:20:00,212.58  

Right now, I am simply trying to read the data and have it respect the correct times within the dataframe.
I have the code:

import pandas

def initialize(context):  
    fetch_csv('https://myserver/my.csv',  
        date_column='Date',  
        usecols=['Value'],  
        symbol='sig',  
        date_format='%Y-%m-%d %h:%m:%s')  
def handle_data(context, data):  
    current_sig_price = data.current('sig', 'Value')  
    print current_sig_price  
    record(sig=current_sig_price)  

As you can see, I have date_format='%Y-%m-%d %h:%m:%s', which appears to me to match the date(s) `2017-08-01 03:45:00, however, my printed statements in the logs show only the price being change being updated on a new date:

...
2017-08-01 15:56  PRINT 225.73  
2017-08-01 15:57  PRINT 225.73  
2017-08-01 15:58  PRINT 225.73  
2017-08-01 15:59  PRINT 225.73  
2017-08-01 16:00  PRINT 225.73  
2017-08-02 09:31  PRINT 217.92  
2017-08-02 09:32  PRINT 217.92  
2017-08-02 09:33  PRINT 217.92  
2017-08-02 09:34  PRINT 217.92  
...

Does anyone have any idea how to get each dataframe sent to handle_data()to properly respect the correct timestamps in my CSV? Is my date_format correct?

Any help would be super appreciated! Thanks!

3 responses

Note I have also tried: date_format='%Y-%m-%d %H:%M:%S' which results in the same (incorrect) date parsing.

When I try this date formatting in straight up Python: datetime.strptime('2017-08-01 03:45:00', '%Y-%m-%d %H:%M:%S'), I get a date object correctly (datetime.datetime(2017, 8, 1, 3, 45). So I'm still at a loss here.

Hi Brett,

With fetch_csv you can only import day frequency data. If your csv file contains multiple rows for a given day, only the last row of data will be imported. At the moment, the platform does not support importing higher frequency data (minute bar, 5 minute bars, etc)

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.

Hi Ernesto,

Thanks for the reply! Ok, thats exactly what I'm seeing. However, it appears to counter Dan Dunn's comment here: https://www.quantopian.com/posts/new-feature-fetcher . Granted, that answer is fairly old. Any plans to re-support fetching higher frequency data?

Thanks,
Brett