Daily returns

So far, we have looked at everything in terms of points, but let's now look at daily returns. This will help put our gains and losses into a more realistic context. Let's create a pandas series for each scenario: daily returns (close to close change), intraday returns, and overnight returns:

daily_rtn = ((spy['Close'] - spy['Close'].shift(1))/spy['Close'].shift(1))*100 
 
id_rtn = ((spy['Close'] - spy['Open'])/spy['Open'])*100 
  
on_rtn = ((spy['Open'] - spy['Close'].shift(1))/spy['Close'].shift(1))*100 

What we've done is use the pandas .shift() method to subtract each series from the prior day's series. For example, for the preceding first series, we are subtracting the close from the close one day before for each day. This will result in one less data point. If you print out the new series, you can see this as follows:

Daily_rtn 

This generates the following output:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.37.196