Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Notebook....previous days price

USING NOTEBOOK !!!

OK..is there an easy way to get previous days price ?

start = '2018-01-01'
end = '2018-01-05'
amazon = get_pricing('amzn',start_date=start,end_date=end)

Lets say I want to see if todays low is > yesterdays low...can't you index in notebook ?

I

1 response

There are a number of ways to check if a dataframe value is greater than a previous value . If one wants a scaler number (ie how much greater) then maybe something like this

gain = amazon.pct_change()  
or  
diff = amazon.diff()

If the current low is greater than the previous low then the values will be > 0.

If one wants a logical value, then different offsets can be compared directly using the 'shift' method.

gain_up = amazon > amazon.shift(1)

See attached notebook. Hope that helps.