File size: 1,360 Bytes
9e89154
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Quantum Portfolio Product API Guide

## Integration Modes

- **Production mode (recommended):** send `returns` + `covariance` directly.
- **Research/demo mode:** send `tickers` + dates (uses yfinance fallback).

Set `REQUIRE_MATRIX_INPUT=true` in production to disable yfinance path.

## Core Endpoints

- `POST /api/portfolio/optimize`
- `POST /api/portfolio/optimize/batch`
- `POST /api/portfolio/backtest`
- `POST /api/portfolio/efficient-frontier`

## Async Jobs

- Submit optimization: `POST /api/jobs/optimize`
- Submit backtest: `POST /api/jobs/backtest`
- Poll status: `GET /api/jobs/{job_id}`

Each async submit endpoint accepts:

```json
{
  "payload": { "...": "endpoint payload" },
  "webhook_url": "https://your-system/callback"
}
```

## Authentication

Use `X-API-Key` header.

- Static mode: `API_KEY=<secret>`
- Multi-tenant mode: store hashed keys in `api_keys` table in `data/api.sqlite3`.

Admin key management endpoints:
- `POST /api/admin/api-keys` with `X-Admin-Key` header (`ADMIN_API_KEY` env var)
- `GET /api/admin/api-keys` with `X-Admin-Key` header

## SDK

Use `quantum_portfolio_sdk.QuantumPortfolioClient`:

```python
from quantum_portfolio_sdk import QuantumPortfolioClient

client = QuantumPortfolioClient("http://localhost:5000", api_key="...")
res = client.optimize({...})
```

See `examples/sdk/basic_client_example.py`.