Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Fetch CSV - is there a way to compare the date to the backtest date so that only those rows are included for that date?

Hi Everyone
When I fetch the data shown below the code an order is placed for AXTI even on 2017-1-4 although it is not part of the csv data. Has anyone figured out how to prevent this from happening? For example how would I compare the date of csv to the backtester date and then only place orders for stocks in that date range? Using the data below, I would like to place an order for AXTI on 2017-1-3, and place orders for ATHN and TLT on 2017-1-4 (exclude AXTI on 2017-1-4)
Please let me know if this can be done.
Much appreciate
Savio

def handle_data(context, data):  
    ESTdate = get_datetime('US/Eastern')  
    for stock in data.fetcher_assets:  
        limit = data.current(stock,'limit')  
        shares = data.current(stock,'shares')  
        # test for market open by timestamp  
        if ESTdate.hour == 9 and ESTdate.minute == 31:  
            # Placing order for day  
            order(stock, shares, style=LimitOrder(limit))  

symbol date limit shares
AXTI 2017-1-3 4.83 23800
ATHN 2017-1-4 108.96 1300
TLT 2017-1-4 119.88 1600

1 response

Pls ignore I figured it out