# QRep Portfolio Profiling API (QuantStats-Lumi) - Single-Symbol Analytics

Open, no-auth HTTP API and MCP server for single-symbol portfolio profiling against a benchmark - Sharpe, Sortino, Max Drawdown, Value at Risk, rolling statistics and return-distribution analysis, delivered as a professional HTML report. Powered by QuantStats-Lumi (the Lumiwealth fork of QuantStats). Built for AI agents first, humans second: every page here has a Copy-as-Markdown button so you can hand it straight to your agent.

Kind: REST / HTTP API, MCP Server (AI agents), Analytics API, Open - no auth
Base URL: https://quantstats-h.tigzig.com
Docs: https://quantstats-h.tigzig.com/docs  ·  OpenAPI: https://quantstats-h.tigzig.com/openapi.json
Full page: https://www.tigzig.com/apis/quantstats

## Overview

QRep Portfolio Profiling analyzes a single symbol against a benchmark and returns a professional HTML report with Sharpe/Sortino ratios, Max Drawdown, Value at Risk, rolling statistics, correlations and return-distribution analysis. Powered by QuantStats-Lumi (the Lumiwealth fork with bug fixes). Two access shapes over one backend:
- REST - GET /analyze with symbols, benchmark (default ^GSPC), start_date, end_date, optional risk_free_rate.
- MCP - the same report as an agent tool call (see below).

AI agents: open (no auth), listed in the RFC 9727 catalog at https://api.tigzig.com/.well-known/api-catalog ; OpenAPI at https://quantstats-h.tigzig.com/openapi.json .

Two QuantStats versions exist. This is the older single-symbol profiling server on the QuantStats-Lumi fork. The newer QREP - Compare Securities server (/apis/qrep) runs the original ranaroussi/quantstats for multi-security comparison. For multi-symbol portfolio reports, see SPR (/apis/ffn).

## MCP Server (for AI agents)

Connect an AI agent and let it profile a security. No auth. Three transports:
- https://quantstats-h.tigzig.com/v1/mcp/http - Streamable HTTP (recommended; MCP 2025-03-26).
- https://quantstats-h.tigzig.com/v1/mcp/sse - SSE (legacy fallback).
- https://quantstats-h.tigzig.com/mcp - original SSE endpoint (back-compat).

Example prompt: "Profile AAPL against QQQ from January 2020 to March 2023."
Add to Claude.ai: Settings -> Connectors -> Add custom connector -> paste the Streamable HTTP URL (fall back to SSE) -> approve. Same URLs work for Cursor, n8n, any MCP client.

## How it works

- Historical price data for the symbol + benchmark is fetched from Yahoo Finance and aligned.
- QuantStats-Lumi computes the metrics and renders the HTML report with visualizations.
- FastAPI + fastapi-mcp, Flask web UI, deployed on Coolify (Hetzner) behind Cloudflare.

Informational only, not investment advice. Metrics use the open-source QuantStats-Lumi version; some calculations rely on assumptions (trading days, compounding). Always validate outputs.

## Build your own (open source)

Clone and run your own:
1. Clone https://github.com/amararun/shared-quantstats
2. pip install -r requirements.txt
3. Set IS_LOCAL_DEVELOPMENT=1 (0 for production) and BASE_URL_FOR_REPORTS.
4. uvicorn main:app --host 0.0.0.0 --port 8000

Self-hosting a public MCP server is your responsibility for security - a public endpoint needs edge rate limiting, abuse detection, secret hygiene. Full checklist: https://www.tigzig.com/security

## API Endpoints (REST / HTTP)

Base URL: `https://quantstats-h.tigzig.com`

### GET /analyze
Analyze
Params:
  - `symbols` (query, required): MANDATORY: Primary stock symbol to analyze (e.g., 'AAPL', 'MSFT', 'GOOGL'). Must be a valid Yahoo Finance ticker symbol. This is the main asset being analyzed. Note: Despite the plural name, only one symbol should be provided.
  - `benchmark` (query): MANDATORY: Benchmark symbol for comparison (e.g., '^GSPC' for S&P 500, '^IXIC' for NASDAQ, '^DJI' for Dow Jones). Must be a valid Yahoo Finance ticker symbol. While this defaults to '^GSPC', a benchmark is ALWAYS used in analysis - this tool requires exactly 2 symbols for comparative analysis. If you don't specify a benchmark, '^GSPC' (S&P 500) will be used automatically.
  - `start_date` (query, required): MANDATORY: Start date in YYYY-MM-DD format
  - `end_date` (query, required): MANDATORY: End date in YYYY-MM-DD format
  - `risk_free_rate` (query): Risk-free rate as percentage (default: 5.0)
Example: curl "https://quantstats-h.tigzig.com/analyze?symbols=AAPL,MSFT&start_date=2020-01-01&end_date=2024-12-31"
### POST /api/analyze
Analyze Api
Example: curl -X POST "https://quantstats-h.tigzig.com/api/analyze"
### POST /qpulse/analyze
Qpulse Analyze
Example: curl -X POST "https://quantstats-h.tigzig.com/qpulse/analyze"
### GET /qpulse/analyze
Qpulse Analyze Get
Params:
  - `symbol` (query, required): Stock symbol (e.g., 'AAPL')
  - `benchmark` (query): Benchmark symbol
  - `start_date` (query, required): Start date (YYYY-MM-DD)
  - `end_date` (query, required): End date (YYYY-MM-DD)
Example: curl "https://quantstats-h.tigzig.com/qpulse/analyze?symbol=AAPL&start_date=2020-01-01&end_date=2024-12-31"
