CoolFace
Apppublic

HADIGHOREISHI/tsx-sector-rotation

sourceHugging Facemitupdated 11mo agoView on Hugging Face
0likes
App README

TSX Sector Rotation & Risk Dashboard

Live TSX sector analytics: risk/return, drawdowns, rolling volatility, correlations, momentum, and a simple rotation strategy (6/12-month momentum + drawdown filter).

Stack: Python · Streamlit · Plotly · pandas · yfinance · (optional) Tableau. Deploy: Hugging Face Spaces (Streamlit) with datasets hosted on the Hugging Face Hub (Parquet).


Features

  • Daily prices for TSX sector ETFs (default): XIU.TO, XIC.TO, XFN.TO, XMA.TO, XEG.TO, XIT.TO, XRE.TO
  • Metrics: returns, rolling volatility (21/63/252d), rolling Sharpe, max drawdown, 12- and 6-month momentum
  • Correlation heatmap, equity curve, drawdown curve
  • Rotation backtest: monthly rebalance, long top-2 momentum sectors if recent drawdown above threshold isn’t breached; otherwise defensive (XIU) or cash
  • Switch between local yfinance fetch or Hub dataset (Parquet) for fast loads in production

Quickstart (local)

bash
python -m venv .venv && source .venv/bin/activate  # Windows: .venv\Scripts\activate
pip install -r requirements.txt
streamlit run app/streamlit_app.py

Deploy to Hugging Face Spaces

  1. 1.Create a Space (type Streamlit) named your-username/tsx-sector-rotation.
  2. 2.Push this repo to that Space (connect via Git + Git LFS).
  3. 3.(Optional, recommended) Create a Datasets repo your-username/tsx-sector-rotation-data and upload data/processed/*.parquet. In app/streamlit_app.py, set Data SourceHugging Face Hub and fill in your dataset path.
  4. 4.Add your Space URL + repo link to LinkedIn Featured.

Data sources

  • Prices via yfinance (Yahoo! Finance). Data may be delayed; for production, consider a paid real-time data provider.
  • Processed snapshots can be stored as Parquet in an HF Datasets repo for versioning/reproducibility.

Project structure

tsx-sector-rotation/
├─ app/
│  └─ streamlit_app.py
├─ src/
│  ├─ data.py
│  ├─ features.py
│  ├─ backtest.py
│  └─ viz.py
├─ data/
│  ├─ raw/
│  └─ processed/
├─ notebooks/
│  └─ 01_exploration.ipynb  (placeholder)
├─ requirements.txt
├─ README.md
└─ LICENSE

I built a TSX Sector Rotation & Risk Dashboard: momentum, drawdowns, rolling risk, and a simple rotation backtest across Canadian sector ETFs (XIU, XFN, XMA, XEG, XIT, XRE).

#python #streamlit #canada #tsx #dataanalytics #finance #tableau

License

MIT — educational purposes only; not investment advice.