{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# QuantScale AI: Automated Direct Indexing & Attribution\n", "## Goldman Sachs Quant Prep Project\n", "\n", "This notebook demonstrates the end-to-end workflow:\n", "1. **Data Ingestion**: Scraping S&P 500 & fetching market data.\n", "2. **Risk Modeling**: Computing Ledoit-Wolf Shrinkage Covariance.\n", "3. **Optimization**: Minimizing Tracking Error with Sector Exclusion Constraints.\n", "4. **AI Reporting**: Using Hugging Face to generate professional commentary." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "!pip install -r requirements.txt" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from main import QuantScaleSystem\n", "from core.schema import OptimizationRequest\n", "import matplotlib.pyplot as plt\n", "\n", "# Initialize System\n", "system = QuantScaleSystem()\n", "\n", "# Test Case: Optimization with Energy Exclusion\n", "req = OptimizationRequest(client_id=\"COLAB_USER\", excluded_sectors=[\"Energy\"])\n", "result = system.run_pipeline(req)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Visualization of Weights\n", "if result:\n", " weights = result['optimization'].weights\n", " plt.figure(figsize=(12, 6))\n", " plt.bar(range(len(weights)), list(weights.values()), align='center')\n", " plt.title('Optimized Portfolio Weights (Energy Excluded)')\n", " plt.xlabel('Assets')\n", " plt.ylabel('Weight')\n", " plt.show()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# AI Commentary\n", "print(result['commentary'])" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.12" } }, "nbformat": 4, "nbformat_minor": 2 }