Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Data might not update in time

It looks like a lot of strategies use the pipeline factors for daily calculations. But if close price is used, it will be delayed for one night. To say we schedule some order logic function every day right after market open and the close price is used. The price is delayed for one night.

schedule_function(ordering_logic,date_rule=date_rules.every_day(),  
                      time_rule=time_rules.market_open(hours=0, minutes=5))  

If I wanna to do a market_close(hours=0, minutes=5), but the pipeline close_price is not updated yet. To say how to get the price of VIX or Vxx 5 minutes before market close? data.current(security, 'price', time_rule=time_rules.market_close(hours=0, minutes=5)) some code like that maybe?

2 responses

Pipeline should be used retrieve DAILY data and generally run in the "before_trading_start" function. The data will be available for that trading day and contains the previous trading day data. The "close" price, as an example, will be the previous days close. Store the pipeline output in context and it can be then accessed in the handle_data and any scheduled functions. See the documentation https://www.quantopian.com/help#using-results. Pipeline isn't intended for fetching intra-day or current data. (Note that "before_trading_start" will only run before a trading day and not on a day the market is closed which is handy to count trading days for instance.)

To get intra-day data then one needs to use the data.current or data.history methods (https://www.quantopian.com/help#overview-gettingdata).

In your example, the function "ordering_logic" will run every day 5 minutes after market open. If you assigned context.output = pipeline_output('my_pipe') in the "before_trading_start" function, then you could use context.output to access the previous days data (eg the VIX close).

The pipeline data get's the previous trading days data for one to use today. Is this what you were asking, or did you want to get todays data and use it today?

@Dan Thank you. It make sense now