January 2019
Intermediate to advanced
378 pages
8h 27m
English
Let's now look at the performance of our model. We're going to buy the next day's open if the close is predicted to be higher than the open. We'll then sell at the close that same day. We'll need to add a few extra data points to our DataFrame to calculate our results, as follows:
cdc = sp[['Close']].iloc[-1000:] ndo = sp[['Open']].iloc[-1000:].shift(-1) tf1 = pd.merge(tf, cdc, left_index=True, right_index=True) tf2 = pd.merge(tf1, ndo, left_index=True, right_index=True) tf2.columns = ['Next Day Close', 'Predicted Next Close', 'Current Day Close', 'Next Day Open'] tf2
This generates the following output:

Here we'll ...
Read now
Unlock full access