January 2019
Intermediate to advanced
378 pages
8h 27m
English
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 ...
Read now
Unlock full access