{"openapi":"3.1.0","info":{"title":"QuantStats Analysis API","description":"API for generating portfolio analysis reports using QuantStats and yfinance data","version":"1.0.0"},"paths":{"/":{"get":{"summary":"Read Root","description":"Serve the web interface","operationId":"read_root__get","parameters":[{"name":"error","in":"query","required":false,"schema":{"type":"string","title":"Error"}},{"name":"success","in":"query","required":false,"schema":{"type":"string","title":"Success"}},{"name":"report_path","in":"query","required":false,"schema":{"type":"string","title":"Report Path"}},{"name":"symbols","in":"query","required":false,"schema":{"type":"string","title":"Symbols"}}],"responses":{"200":{"description":"Successful Response","content":{"text/html":{"schema":{"type":"string"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/analyze":{"get":{"summary":"Analyze","description":"Generate a comprehensive portfolio analysis report using QuantStats.\n\nIMPORTANT: This tool requires EXACTLY 2 Yahoo Finance symbols:\n1. Primary symbol - the stock/asset you want to analyze\n2. Benchmark symbol - the comparison benchmark (e.g., ^GSPC for S&P 500)\n\nBoth symbols are MANDATORY. You cannot perform analysis with just one symbol.\n\nThis endpoint performs detailed portfolio analysis including:\n- Performance metrics (Sharpe ratio, Sortino ratio, CAGR, etc.)\n- Risk metrics (Value at Risk, Maximum Drawdown, etc.)\n- Return analysis and distribution\n- Rolling statistics and correlations\n- Comparative analysis against benchmark\n\nThe analysis is returned as:\n- Interactive HTML report with visualizations\n- Direct URL to view the comprehensive report\n\nParameters:\n- symbols: MANDATORY - Primary stock symbol to analyze (e.g., 'AAPL', 'MSFT', 'GOOGL'). Despite the plural name, provide only one symbol.\n- benchmark: MANDATORY - Benchmark symbol for comparison (e.g., '^GSPC', '^IXIC', '^DJI'). Defaults to '^GSPC' if not specified, but a benchmark is always used.\n- start_date: MANDATORY - Analysis start date (YYYY-MM-DD format)\n- end_date: MANDATORY - Analysis end date (YYYY-MM-DD format)\n- risk_free_rate: Risk-free rate percentage for calculations (default: 5.0)\n\nReturns:\n- AnalysisResponse with html_url to access the generated HTML report\n\nNote: The analysis may take up to 2-3 minutes depending on the date range and data availability.\nBoth symbols must be valid Yahoo Finance ticker symbols.","operationId":"create_portfolio_analysis","parameters":[{"name":"symbols","in":"query","required":true,"schema":{"type":"string","description":"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.","title":"Symbols"},"description":"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."},{"name":"benchmark","in":"query","required":false,"schema":{"type":"string","description":"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.","default":"^GSPC","title":"Benchmark"},"description":"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."},{"name":"start_date","in":"query","required":true,"schema":{"type":"string","description":"MANDATORY: Start date in YYYY-MM-DD format","title":"Start Date"},"description":"MANDATORY: Start date in YYYY-MM-DD format"},{"name":"end_date","in":"query","required":true,"schema":{"type":"string","description":"MANDATORY: End date in YYYY-MM-DD format","title":"End Date"},"description":"MANDATORY: End date in YYYY-MM-DD format"},{"name":"risk_free_rate","in":"query","required":false,"schema":{"type":"number","description":"Risk-free rate as percentage (default: 5.0)","default":5.0,"title":"Risk Free Rate"},"description":"Risk-free rate as percentage (default: 5.0)"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AnalysisResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/analyze":{"post":{"summary":"Analyze Api","description":"API endpoint for analysis","operationId":"analyze_api_api_analyze_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AnalysisRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/reports/{filename}":{"get":{"summary":"Serve Report","description":"Serve report files","operationId":"serve_report_reports__filename__get","parameters":[{"name":"filename","in":"path","required":true,"schema":{"type":"string","title":"Filename"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/qpulse/analyze":{"post":{"summary":"Qpulse Analyze","description":"QPulse Tearsheet Generation - Simple API using native QuantStats\n\nThis endpoint uses quantstats' built-in download_returns() function\nto fetch data and generate tearsheets. No manual yfinance handling.\n\nParameters:\n- symbol: Stock symbol (e.g., 'AAPL', 'MSFT', 'RELIANCE.NS')\n- benchmark: Benchmark symbol (e.g., 'SPY', '^GSPC')\n- start_date: Start date (YYYY-MM-DD)\n- end_date: End date (YYYY-MM-DD)\n\nReturns:\n- html_url: URL to the generated HTML tearsheet","operationId":"qpulse_analyze_qpulse_analyze_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/QPulseAnalysisRequest"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/QPulseAnalysisResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"get":{"summary":"Qpulse Analyze Get","description":"GET version of QPulse analyze for easy browser/curl testing","operationId":"qpulse_analyze_get_qpulse_analyze_get","parameters":[{"name":"symbol","in":"query","required":true,"schema":{"type":"string","description":"Stock symbol (e.g., 'AAPL')","title":"Symbol"},"description":"Stock symbol (e.g., 'AAPL')"},{"name":"benchmark","in":"query","required":false,"schema":{"type":"string","description":"Benchmark symbol","default":"SPY","title":"Benchmark"},"description":"Benchmark symbol"},{"name":"start_date","in":"query","required":true,"schema":{"type":"string","description":"Start date (YYYY-MM-DD)","title":"Start Date"},"description":"Start date (YYYY-MM-DD)"},{"name":"end_date","in":"query","required":true,"schema":{"type":"string","description":"End date (YYYY-MM-DD)","title":"End Date"},"description":"End date (YYYY-MM-DD)"}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"AnalysisRequest":{"properties":{"stock_code":{"type":"string","title":"Stock Code","description":"MANDATORY: Primary stock symbol to analyze (e.g., 'AAPL', 'GOOG', '^NSEI'). Must be a valid Yahoo Finance ticker symbol. This is the main asset being analyzed.","example":"AAPL"},"benchmark_code":{"type":"string","title":"Benchmark Code","description":"MANDATORY: Benchmark symbol for comparison (e.g., '^GSPC' for S&P 500, '^IXIC' for NASDAQ). Must be a valid Yahoo Finance ticker symbol. While it has a default value of '^GSPC', a benchmark is always required for analysis - you cannot analyze without a benchmark.","default":"^GSPC","example":"^GSPC"},"start_date":{"type":"string","title":"Start Date","description":"Start date for analysis in YYYY-MM-DD format. Should be at least 6 months before end_date for meaningful analysis.","example":"2023-01-01"},"end_date":{"type":"string","title":"End Date","description":"End date for analysis in YYYY-MM-DD format. Must be after start_date and not in the future.","example":"2024-01-01"},"risk_free_rate":{"type":"number","maximum":100.0,"minimum":0.0,"title":"Risk Free Rate","description":"Risk-free rate as percentage (e.g., 5.0 for 5%). Used in Sharpe ratio calculations.","default":5.0,"example":5.0}},"type":"object","required":["stock_code","start_date","end_date"],"title":"AnalysisRequest","description":"Request model for portfolio analysis. Requires exactly 2 Yahoo Finance symbols: one for the asset to analyze and one for benchmark comparison."},"AnalysisResponse":{"properties":{"html_url":{"type":"string","title":"Html Url","description":"Direct URL to access the comprehensive HTML report with visualizations, performance metrics, and risk analysis comparing the primary symbol against the benchmark","example":"https://quantstat-nextjs.vercel.app/static/reports/AAPL_vs_^GSPC_20240315_123456.html"}},"type":"object","required":["html_url"],"title":"AnalysisResponse","description":"Response model for portfolio analysis. Contains URL to the comprehensive comparative analysis report generated from exactly 2 Yahoo Finance symbols."},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"QPulseAnalysisRequest":{"properties":{"symbol":{"type":"string","title":"Symbol","description":"Stock symbol to analyze (e.g., 'AAPL', 'MSFT', 'RELIANCE.NS')","example":"AAPL"},"benchmark":{"type":"string","title":"Benchmark","description":"Benchmark symbol for comparison (e.g., 'SPY', '^GSPC')","default":"SPY","example":"SPY"},"start_date":{"type":"string","title":"Start Date","description":"Start date in YYYY-MM-DD format","example":"2020-01-01"},"end_date":{"type":"string","title":"End Date","description":"End date in YYYY-MM-DD format","example":"2025-01-01"}},"type":"object","required":["symbol","start_date","end_date"],"title":"QPulseAnalysisRequest","description":"Request model for QPulse tearsheet generation"},"QPulseAnalysisResponse":{"properties":{"success":{"type":"boolean","title":"Success"},"html_url":{"type":"string","title":"Html Url","description":"URL to the generated HTML tearsheet"},"message":{"type":"string","title":"Message","description":"Status message"}},"type":"object","required":["success","html_url","message"],"title":"QPulseAnalysisResponse","description":"Response model for QPulse tearsheet"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}}}