How it works...

In the first two steps, we imported the required libraries and defined the parameters responsible for loading the data and some of the settings of the neural network, such as the batch size and the number of epochs.

In Step 3, we downloaded the data. For this recipe, we resampled Intel's adjusted close prices (years 2015-2019) to weekly frequency by taking each period's last observed value. For resampling, we used the 'W-MON' argument as the desired frequency. That is because using 'W' would result in the data indices being created from the last day of the period. As we used the slice of the DataFrame to determine the size of the validation set, we had to make sure that the indices correspond to the first days of the weeks ...

Get Python for Finance Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.