How it works...
In Step 2, we defined the parameters (the ticker of the considered stock and timeframes) for later use.
In Step 3, we downloaded the necessary datasets using pandas_datareader, which provides us with a convenient way of downloading the risk-factors-related data without manually downloading the CSV files. For more information on this process, please refer to the There's more section in the Implementing the Fama-French three-factor model in Python recipe. One thing to note here is that we applied the format method to the index, as we had to remove PeriodIndex in order to join multiple datasets later.
In Steps 4 and 5, we downloaded Amazon's stock prices and calculated the monthly returns using the previously explained methodology. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access