code: def compute_exposures(positions, factor_loadings):
      
      risk_exposures = factor_loadings.multiply(positions, axis='rows')
      return risk_exposures.groupby(level='dt').sum()
docs: Compute daily risk factor exposures.
  
      Parameters
      ----------
      positions: pd.Series
          A series of holdings as percentages indexed by date and ticker.
          - Examples:
              dt          ticker
              2017-01-01  AAPL      0.417582
                          TLT       0.010989
                          XOM       0.571429
              2017-01-02  AAPL      0.202381
                          TLT       0.535714
                          XOM       0.261905
  
      factor_loadings : pd.DataFrame
          Factor loadings for all days in the date range, with date and ticker as
          index, and factors as columns.
          - Example:
                                 momentum  reversal
              dt         ticker
              2017-01-01 AAPL   -1.592914  0.852830
                         TLT     0.184864  0.895534
                         XOM     0.993160  1.149353
              2017-01-02 AAPL   -0.140009 -0.524952
                         TLT    -1.066978  0.185435
                         XOM    -1.798401  0.761549
  
      Returns
      -------
      risk_exposures_portfolio : pd.DataFrame
          df indexed by datetime, with factors as columns
          - Example:
                          momentum  reversal
              dt
              2017-01-01 -0.238655  0.077123
              2017-01-02  0.821872  1.520515