CommencerCommencer gratuitement

Industry exposures with Pyfolio

You saw in the first video of this chapter how to use a groupby function to create the active weights per industry. The drawback is that it takes a snapshot in time. Since portfolio weights change, you can imagine that the industry exposures change over time as well. However, the calculation to determine industry exposures on each day for your portfolio, can become quite tedious and complex.

Luckily, you can use Pyfolio's tear sheet for this. The tear sheet shows you exposures over time, and summarizes overall top stock picks in your portfolio. Available is data on your portfolio returns under returns, and your daily positions in dollar value per stock, under positions. Go ahead and inspect positions and returns in the console.

Cet exercice fait partie du cours

Introduction to Portfolio Analysis in Python

Afficher le cours

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Define the sector mappings
sect_map = {'COST': 'Consumer Goods',
            'INTC': 'Technology', 
            'CERN': 'Healthcare', 
            'GPS': 'Technology',
            'MMM': 'Construction', 
            'DELL': '____', 
            'AMD': 'Technology'}
Modifier et exécuter le code