Hello,
I'm a newbie to using Quantopian, and I've mostly written my own code for algo trading. I'm trying to get 15min resolution data using data.history() but I seem to be getting data only for the present day.
Example- At 9:45am, I want the first 15min data point from 9:30-9:45 and the earlier values from the previous day, but data.histrory() returns only the current day's prices, and it is emptied again at the start of the next trading day. Is there another way to get this data?
In initialize()
fields to get from history
context.fields =["price","open","high","low","close","volume"]
format for resample to convert 1min data into 15min data
context.conversion_dict= {
"open":"first",
"close":"last",
"price":"last",
"high":"max",
"low":"min",
"volume":"sum"
}
in handle_data()-
get 500 bar history at 1min resolution for ticker
d = data.history(ticker,context.fields,500,"1m")
convert to EST
d = d.tz_convert('US/Eastern')
resample 1min data to 15min data
d = d.resample("15Min",how=context.conversion_dict)
sort it to get most recent data at the top
d = d.sort(ascending=False)
When I log the dataframe using d.head(), I get the output-
2016-12-01 09:45:00-05:00 210560.0 110.22 110.42 110.21 110.22 110.390
2016-12-01 09:30:00-05:00 2739612.0 110.40 110.78 110.27 110.40 110.365
2016-12-01 09:15:00-05:00 NaN NaN NaN NaN NaN NaN
2016-12-01 09:00:00-05:00 NaN NaN NaN NaN NaN NaN
2016-12-01 08:45:00-05:00 NaN NaN NaN NaN NaN NaN
Since the market opens at 9:30, shouldn't the dataframe contain data from the previous day instead of NaNs?