In the following code, we will incorporate text data about the headlines generated by the company of interest (which is fetched from the open source API provided by the Guardian's website) along with the last five days' stock price data. Then we'll couple the custom loss function, which takes the recency of an event into account:
- Import the headlines data from the Guardian website from here: https://open-platform.theguardian.com/ (note that you would have to apply for your own access key to be able to download the dataset from the website). Download the title and the corresponding date when the title appeared, and then preprocess the date so that it is converted into a date format:
from bs4 ...