Skip to content

Black-Litterman model application for S&P/TSX 60 index using Bloomberg API: data scraping, return expectations, portfolio optimization, and visualization.

Notifications You must be signed in to change notification settings

Claire7288/black-litterman-tsx60-with-website-scraping-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Black-Litterman Model on S&P/TSX 60 Index

This project implements the Black-Litterman asset allocation model on the S&P/TSX 60 Index, combining financial theory with real market data using Python and the Bloomberg Terminal API.

It is designed to help finance students and professionals understand how to integrate market equilibrium returns with personal investment views using real-world Canadian equity data.


Overview

This project is divided into two key stages:

  1. Ticker Scraping

    • Scrapes the latest list of TSX 60 constituents from The Globe and Mail website (not Wikipedia).
    • Uses selenium and webdriver to navigate and extract tickers dynamically.
  2. Data Download & Black-Litterman Modeling

    • Downloads daily stock price and market cap data using the Bloomberg Python API (blpapi and xbbg).
    • Computes covariance and correlation matrices, constructs the market-cap weighted portfolio, and applies the Black-Litterman model with and without active views.
    • Visualizes correlation heatmaps, market weight pie charts, and weight shifts from views.

Active Views Modeled

As a portfolio manager, we assume the following active investment views:

  1. Shopify will outperform Rogers by 5%.
  2. Loblaw's return will be 1% higher than its average over the past 5 years (2020–2025).

Using these views, we generate three optimized portfolios:

  • Based on View 1 only
  • Based on View 2 only
  • Based on both views combined

Visual Outputs

  • Correlation matrix (Seaborn heatmap)
  • Market cap weights (Pie chart)
  • Portfolio weight changes (Bar chart comparison)

Tools & Libraries

  • Python 3.x
  • blpapi, xbbg – Bloomberg API access
  • selenium, bs4, requests – Web scraping
  • pandas, numpy, matplotlib, seaborn – Data analysis & plotting
  • yfinance

Project Structure

scrape_tsx60_tickers.ipynb - Web scraping from Globe and Mail

black_litterman_model.ipynb - Data download, modeling, visualization


Requirements & Access Notes

  • To run the Black-Litterman model, your machine must:
    • Have access to a Bloomberg Terminal
    • Be configured with blpapi and valid Bloomberg credentials
  • The scraping module (scrape_tsx60_tickers.py) does not require Bloomberg.

Contributions

Pull requests are welcome! If you want to add new views, extend the model, or enhance visuals, feel free to contribute.


About

Black-Litterman model application for S&P/TSX 60 index using Bloomberg API: data scraping, return expectations, portfolio optimization, and visualization.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published