LoslegenKostenlos loslegen

Calculate & plot the composite index

By now you have all ingredients that you need to calculate the aggregate stock performance for your group of companies.

Use the time series of market capitalization that you created in the last exercise to aggregate the market value for each period, and then normalize this series to convert it to an index.

Diese Übung ist Teil des Kurses

Manipulating Time Series Data in Python

Kurs anzeigen

Anleitung zur Übung

We have already imported pandas as pd and matplotlib.pyplot as plt for you. We have also loaded components and market_cap_series, which you worked with in the last exercise.

  • Aggregate the market cap per trading day by applying .sum() to market_cap_series with axis=1, assign to raw_index and print the result.
  • Normalize the aggregate market cap by dividing by the first value of raw_index and multiplying by 100. Assign this to index and print the result.
  • Plot the index with the title 'Market-Cap Weighted Index'.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Aggregate and print the market cap per trading day
raw_index = ____
print(____)

# Normalize the aggregate market cap here 
index = ____
print(____)

# Plot the index here

Code bearbeiten und ausführen