Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
973 B
2
Indexable
Never
import esg_data_api
import financial_modeling as fm

# Pull ESG scores for a list of companies
companies = ["Apple", "Nike", "Coca-Cola"]    
esg_scores = esg_data_api.get_scores(companies)

# Create financial risk models that incorporate ESG scores  
for company in companies:
  financials = fm.pull_financials(company) 
  model = fm.create_model(financials, esg_scores[company])
  
  # Estimate impact on valuation 
  valuation = model.estimate_value()  
  
  # Recommend investment if ESG score is high
  if esg_scores[company] > 80:
    print(f"Recommend {company} based on high ESG score of {esg_scores[company]}")
    
# Backtest portfolio returns with ESG tilt    
esg_portfolio = fm.create_portfolio(companies, weights="esg_score")
performance = esg_portfolio.backtest(5_years)
risk_metrics = esg_portfolio.analyze_risk(5_years)

print(f"ESG Portfolio 5 Year Returns: {performance}")  
print(f"ESG Portfolio Risk Metrics: {risk_metrics}")
Leave a Comment