Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Historical data for security

Is it possible to get pricing information (open, close, high low) for a security for a specific date? I see how I can get current pricing data, or a window of pricing data preceding the current moment - but I can't figure out how to get pricing data for a specific day in history.

Something like this is what I'm looking for:

historicClose = data.history(security, close, arbitraryDate)

thanks for any input!

2 responses

I have a similar question, I am trying to figure out to track the past-3 and past-5 days volume weighted price as one of the short-term momentum..

@Casey Maynard

Notebook:

get_pricing('COHR',start_date='2016-10-17', end_date='2016-10-17')  

Algorithm:

def initialize(context):  
    pass  
def handle_data(context, data):  
    context_hist = data.history(sid(1751), ['price', 'volume'], 10, '1d')  
    context_nine_day = context_hist[:-9]  
    print context_nine_day

@Jerry Xu

Notebook:

vwap_hist = get_pricing('COHR', start_date='2016-10-17', end_date='2016-10-22', fields = ['price', 'volume'])  
vwap_3 = (vwap_hist['price'][:-3] * vwap_hist['volume'][:-3]).sum() / vwap_hist['volume'][:-3].sum()  
vwap_5 = (vwap_hist['price'] * vwap_hist['volume']).sum() / vwap_hist['volume'].sum()  
print "3 day VWAP"  
print vwap_3  
print "5 day VWAP"  
print vwap_5

Algorithm:

def initialize(context):  
    pass  
def handle_data(context, data):  
    vwap_hist = data.history(sid(1751), ['price', 'volume'], 10, '1d')[:-5]  
    vwap_3 = (vwap_hist['price'][:-3] * vwap_hist['volume'][:-3]).sum() / vwap_hist['volume'][:-3].sum()  
    vwap_5 = (vwap_hist['price'] * vwap_hist['volume']).sum() / vwap_hist['volume'].sum()  
    print ("3 day VWAP: ")  
    print vwap_3  
    print ("5 day VWAP: ")  
    print vwap_5