Exercise

# Compare index performance against benchmark II

The next step in analyzing the performance of your index is to compare it against a benchmark.

In the video, we have use the S&P 500 as benchmark. You can also use the Dow Jones Industrial Average, which contains the 30 largest stocks, and would also be a reasonable benchmark for the largest stocks from all sectors across the three exchanges.

Instructions

**100 XP**

We have already imported `numpy`

as `np`

, `pandas`

as `pd`

, `matplotlib.pyplot`

as `plt`

for you. We have also loaded your Index and the Dow Jones Industrial Average (normalized) in a variable called `data`

.

- Inspect
`data`

and print the first five rows. - Define a function
`multi_period_return`

that takes a`numpy`

`array`

of period returns as input, and returns the total return for the period. Use the formula from the video - add 1 to the input, pass the result to`np.prod()`

, subtract 1 and multiply by 100. - Create a
`.rolling()`

window of length`'360D'`

from`data`

, and apply`multi_period_return`

. Assign to`rolling_return_360`

. - Plot
`rolling_return_360`

using the`title`

`'Rolling 360D Return'`

.