cvxgrp/cvxportfolio

Query: How do I use ESG scores of a company to optimize a portfolio?

Closed this issue · 3 comments

Hi,

I came across "cvxportfolio" during my research on portfolio optimization techniques. Very impressed with the library and thank you for sharing in Github.

I have an hypothesis and trying to use ESG scores of the companies as one of the risk factor, when backtesting the portfolio of stocks.

Say for example, GOOG has a ESG Risk rating of 24.5 out of 40.
MSFT has a ESG risk rating of 15.3 out of 40. (as of 07/20/2023).

How can i use these ESG Risk rating values as an input and determine an
optimized portfolio for a period start date : 01/01/2015 to 12/31/2022 (say)?

PS: I am high school student, passionate about financial markets and am still learning the quantitive finance. Appreciate any examples or guidance?

Thanks
Vedanth

enzbus commented

Hi, those scores should be factor exposures, so you can use for example the FactorMaxLimit (or the others) constraint. You pass the loadings as a pandas Series indexed by assets' names, if they are constant in time, or a dataframe indexed by time and with assets as columns if they change in time. If they change in time they must have an observation for every point in time of the backtest. (So you'll probably have to do pandas forward fills.)

Thank you. I have created series with a simple array of factors and supplied to FactorMaxLimit.
I am not really sure these factors considered anywhere and adjusted the "weights" of these stocks based on relative factor values.

Is this code valid? If yes, how can I verify that MultiPeriodOptimization is using my factor values while optimizing the portfolio.

Appreciate your help and any additional direction.

# simple array
esg_leaders_data = np.array(
    [41, 22, 33, 43, 52, 46, 56, 31, 28, 52, 46, 52, 49, 54])  # Max  60

# providing esg scores as an index
ser = pd.Series(esg_leaders_data,
                index=['AAPL', 'BA', 'CAT', 'CVX', 'DIS', 'GS', 'JNJ', 'JPM', 'MCD', 'NKE', 'PG', 'TRV', 'V', 'WBA'])
#print(ser)
gamma_risk = 2
gamma_trade = 0.5
simulator = cvx.StockMarketSimulator(universe, trading_frequency=trading_frequency)
policy = cvx.MultiPeriodOptimization(cvx.ReturnsForecast()
                                     - gamma_risk * cvx.FactorModelCovariance(num_factors=10)
                                     - gamma_trade * cvx.StocksTransactionCost(),
                                     [cvx.LongOnly(), cvx.FactorMaxLimit(ser,60)],
                                     planning_horizon=6)
enzbus commented

Yes, this code seems valid and is what I meant in my previous answer. I'll try to run it. This will guarantee that at each step the portfolio weights will satisfy w.T @ e <= 60 where e are the esg scores. If you also have long only and leverage 1 it means that the average esg score of the portfolio is less than 60. You can also have it equal to or greater than (with the others factor limit constraints). If the portfolio is long short it's the same, if the leverage is greater than one you'll need to change the limit accordingly. This is one way to use esg information, you can also use it to limit the universe (exclude stocks that don't meet your esg limits) or as a feature in a returns forecast model (see the user_provided_forecasts.py example on how to change the default returns forecaster). There are many ways...