API Docs
Basics
Base URL: https://blackswan-api.9cstar.com
Authentication: send X-API-Key on all authenticated endpoints.
Metering: 1 compute credit = 1 ticker ร 1 forecast. A request with N tickers consumes N compute credits (portfolio stress tests likewise charge per ticker).
Integrations
QuantConnect strategies can call the API with a simple self.Download โ see the QuantConnect integration guide.
What you can do on the Free plan
Sign up to get an API key and 50 compute credits every month โ no card required. With 50 credits you can run roughly:
- 50 single-ticker forecasts, or
- 12 portfolio stress tests with 4 tickers each, or
- one 1-year, 4-ticker monthly backtest (~48 credits).
A 3-year, 4-ticker monthly backtest costs 144 credits, so it needs the Pro plan (800 credits/mo) or purchased credits. When you run out of credits the API returns 402; rate limiting is 3 compute credits/min on Free. Upgrade or top up from the dashboard at any time.
1. Portfolio stress test
Run a set of tickers through a historical stress scenario and get the portfolio-level expected drawdown, the most vulnerable holdings, and a stability measure โ the primary defensive-composition workflow. See the Portfolio Stress Testing API landing page for a walkthrough.
curl -X POST https://blackswan-api.9cstar.com/api/v1/portfolio/forecast \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_KEY" \
-d '{
"tickers": ["SPY", "AAPL", "MSFT", "JPM"],
"scenario_id": "financial_crisis_2008",
"current_prices": {"SPY": 500, "AAPL": 200, "MSFT": 400, "JPM": 150}
}'Response includes per-ticker drawdown ranges and a portfolio summary: weighted max drawdown, most vulnerable / most resilient holdings, and stability (std-dev of per-ticker drawdowns). Charges 1 compute credit per ticker.
2. Single / batch ticker forecast
Given tickers and an optional stress scenario, returns the expected drawdown range, recovery horizon, profit probability and tail-risk score for each ticker.
curl -X POST https://blackswan-api.9cstar.com/api/v1/forecast \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_KEY" \
-d '{
"tickers": ["SPY", "AAPL"],
"scenario_id": "covid_crash_2020",
"current_prices": {"SPY": 500, "AAPL": 200}
}'GET version (QuantConnect Download compatible, params in query string):
curl "https://blackswan-api.9cstar.com/api/v1/forecast?tickers=SPY,AAPL\ &scenario_id=covid_crash_2020¤t_prices=SPY:500,AAPL:200\ &as_of_date=2026-08-01" \ -H "X-API-Key: YOUR_KEY"
Charges N compute credits for N tickers. Duplicate tickers are rejected with 422.
3. Historical market-path match
Compare a recent price path to historical long-drawdown events and get the most similar episodes โ useful for regime detection and early-warning flags.
curl "https://blackswan-api.9cstar.com/api/v1/market/match?ticker=SPY\ &days=30&as_of_date=2026-08-01" -H "X-API-Key: YOUR_KEY"
4. Usage and rate limits
- GET /api/v1/plans โ plan list (monthly compute credits, credits/min, concurrency)
- GET /api/v1/me/usage โ current user usage
- POST /api/v1/subscribe โ create Stripe checkout
Rate limits are measured in compute credits per minute, not HTTP requests. A Pro plan at 10 credits/min can send one 10-ticker forecast and then must wait for the window to reset before more credits are consumed.
5. Error handling
| Status | X-Error-Code | Meaning |
|---|---|---|
| 400 | โ | Malformed request or invalid business parameters |
| 401 | โ | Missing or invalid X-API-Key |
| 402 | โ | Monthly compute credits exhausted |
| 404 | โ | Scenario template or resource not found (e.g. bad scenario_id) |
| 422 | โ | Validation error (duplicate tickers, etc.) |
| 429 | RATE_LIMIT_EXCEEDED | Compute-credit window exceeded; retry after Retry-After seconds |
| 429 | USER_CONCURRENCY_LIMIT | Your plan's concurrent forecast limit reached |
| 429 | GLOBAL_CAPACITY_LIMIT | Instance capacity temporarily full |
429 responses include a Retry-After header. Credits are only charged once a request passes rate-limit and concurrency checks; if a prediction fails internally, the consumed credits are refunded.