Trading Intel API
Auto-generated from
openapi-snapshot.json. Do not edit by hand — changes are overwritten byscripts/docs/generate_api_reference.py.
63 endpoints in this group.
POST /api/trading-intel/backtest
Run Backtest
Simulate a strategy over the requested date range using realized_trades.
Returns equity curve, CAGR, Sharpe, Sortino, max drawdown, win rate, profit factor, and a per-trade log.
Request body: application/json
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/correlation
Get Correlation
Pearson correlation matrix for portfolio holdings + major benchmark indices.
Fetches the latest snapshot holdings (up to 20 symbols by market value), combines with SPY / QQQ / IWM / GLD / TLT / UUP benchmarks, then pulls 90-day daily closes via the market-data factory (ThetaData -> yfinance fallback). Returns an NxN matrix of Pearson r values rounded to 3 decimal places.
Issue #238: response is cached in Redis under
bp:corr:v1:{tenant}:{account}:{symbols_hash}:{lookback} with a TTL of
~15 min during RTH and ~24h overnight. Cache hit served with X-Cache: HIT;
cache miss computes, writes back, and serves with X-Cache: MISS.
ETag (MD5 of response body) is always set; If-None-Match returns 304.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional | Tenant ID |
account_id | query | — | optional | Optional broker account scope |
lookback_days | query | integer | optional | Rolling window length in calendar days (default 90). |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
POST /api/trading-intel/email-briefing
Send Email Briefing
Compose and send a daily trading briefing email via SendGrid.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
account_id | query | — | optional |
Request body: application/json
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/eod/history
Get Eod History
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional | |
account_id | query | — | optional | |
days | query | integer | optional |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/eod/review
Get Eod Review
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional | |
account_id | query | — | optional | |
review_date | query | — | optional | YYYY-MM-DD, defaults to today |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/exit
Get Exit Strategies
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
POST /api/trading-intel/exit/compute
Compute Exit
Compute ATR-based stop-loss and trailing stops for open positions.
Request body: application/json
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/extended-hours
Get Extended Hours
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional | |
limit | query | integer | optional |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/feedback
Get Feedback Stats
Feedback loop: compare recommendations to realized outcomes.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional | |
days | query | integer | optional |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/gameplan
Get Game Plan
Pre-market game plan: signals + enriched market events with portfolio tagging.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional | |
account_id | query | — | optional |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/hedging
Get Hedge Recommendations
Suggest inverse-ETF hedges for concentrated positions (>10% weight).
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional | |
account_id | query | — | optional |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/intel-feed
Get Intel Feed
Unified chronological intelligence feed.
Aggregates from four sources into a single time-ordered stream:
- intraday_signals → tag SIGNAL
- options_flow_signals → tag FLOW
- recommendations → tag ALERT (conf ≥ 0.80) or SIGNAL
- external_intel → tag NEWS
Each item: id, tag, symbol, text, confidence, source, created_at.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional | |
hours | query | integer | optional | Look-back window in hours |
limit | query | integer | optional | |
tag | query | — | optional | Filter by category: SIGNAL |
symbol | query | — | optional | Filter to a single ticker |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/intraday/bars
Get Intraday Bars
Return today’s OHLCV + VWAP/RSI/MACD bars for a symbol, oldest-first.
Sourced from market_data_intraday populated by fetch_and_store_bars(). Suitable for feeding directly to a charting library.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
symbol | query | string | required | Ticker symbol |
limit | query | integer | optional | Max bars to return |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
POST /api/trading-intel/intraday/detect
Detect Intraday
Fetch live bars from yfinance, compute indicators, run setup detectors.
Steps:
- fetch_and_store_bars — pull OHLCV, compute VWAP/RSI/MACD, upsert market_data_intraday.
- detect_setups — run ORB / VWAP-reclaim / gap / volume-spike detectors, write results to intraday_signals.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
session | query | — | optional | REGULAR |
asof | query | — | optional | YYYY-MM-DD anchor date |
Request body: application/json
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
POST /api/trading-intel/intraday/detect/portfolio
Detect Intraday Portfolio
Run intraday detection against the user’s current portfolio positions.
Fetches the latest position symbols (up to limit, ordered by market_value DESC),
then delegates to the same bar-fetch + setup-detect pipeline as /intraday/detect.
Returns an empty result (not an error) when no positions are held.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional | |
account_id | query | — | optional | |
interval | query | string | optional | |
period | query | string | optional | |
limit | query | integer | optional |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/intraday/discovery
Get Discovery Dashboard
Discovery dashboard: stats, scan breakdown, and full result feed.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional | |
scan_type | query | — | optional | Filter by scan type |
hours | query | integer | optional | |
universe | query | — | optional | Filter by universe |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/intraday/discovery/opportunities
Get Opportunities
Return ranked market opportunities filtered by minimum composite score.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional | |
min_score | query | number | optional | |
limit | query | integer | optional |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
POST /api/trading-intel/intraday/discovery/opportunities/compute
Compute Opportunities
Compute composite opportunity scores from recent scanner signals.
Request body: application/json
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
POST /api/trading-intel/intraday/discovery/scan
Run Discovery Scan
Run a live market scan using yfinance data.
Fetches OHLCV + indicators for the chosen universe, ranks by scan_type, upserts into scanner_results, and returns ranked results.
Request body: application/json
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/intraday/discovery/watchlist
Get Discovery Watchlist
Return opportunity-scored symbols NOT currently in the user’s portfolio.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional | |
limit | query | integer | optional |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/intraday/flow
Get Flow Dashboard
Aggregated Flow Intelligence dashboard: stats, direction_breakdown, flow list.
Ported from legacy MTM_CLAUDE options_intel.get_options_signals and extended with KPI aggregation (total, direction split, avg P/C ratio, avg confidence).
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional | |
hours | query | integer | optional | Look-back window in hours |
symbol | query | — | optional | Optional single-ticker filter |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
POST /api/trading-intel/intraday/flow/detect
Detect Flow
Fetch live option chains from yfinance, compute P/C ratios, upsert flow signals.
Steps:
- For each symbol, download nearest-expiry option chain via yfinance.
- Compute put_volume / call_volume ratio → classify as CALL_DOMINANCE / PUT_DOMINANCE / NEUTRAL_FLOW.
- Upsert result into options_flow_signals (unique per tenant+symbol+date).
Request body: application/json
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/intraday/signal-dashboard
Get Intraday Signal Dashboard
Aggregated Signal Dashboard payload: stats, setup_breakdown, full signal list.
Extracted from legacy MTM_CLAUDE trading_intel/intraday_engine.get_intraday_signals and extended with KPI aggregation for the dashboard surface.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional | |
hours | query | integer | optional | Look-back window in hours |
symbol | query | — | optional | Optional single-ticker filter |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/intraday/signals
Get Intraday Signals
Return recent intraday setup signals from the database.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional | |
symbol | query | — | optional | Filter to a single ticker |
hours | query | integer | optional | Look-back window in hours |
limit | query | integer | optional |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/market-context/indices
Get Market Indices
Return current price, change, and % change for SPY, QQQ, DIA, and ^VIX.
Previously did 4 sequential yf.Ticker(sym).fast_info calls on every
request (~3.5s). Now: one batched yf.download over 5d of daily bars,
cached 60s in Redis. Typical cold path ~400ms, warm path <10ms.
Responses
| Code | Description |
|---|---|
200 | Successful Response |
GET /api/trading-intel/mtm/election
Get Election
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
POST /api/trading-intel/mtm/election
Upsert Election
Request body: application/json
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/mtm/form-4797.csv
Form 4797 Csv
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional | |
year | query | integer | required | |
account_id | query | — | optional | |
source_policy | query | string | optional | |
taxpayer_name | query | string | optional | |
ein | query | string | optional |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/mtm/form-4797.pdf
Form 4797 Pdf
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional | |
year | query | integer | required | |
account_id | query | — | optional | |
source_policy | query | string | optional | |
taxpayer_name | query | string | optional | |
ein | query | string | optional |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
POST /api/trading-intel/mtm/reconcile
Reconcile
Run §475(f) MTM reconciliation against realized_trades for the year. Returns totals + equity/option split + any per-trade errors.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional | |
year | query | integer | required | |
account_id | query | — | optional | |
source_policy | query | string | optional |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/mtm/section-481
Get Section 481
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
POST /api/trading-intel/mtm/section-481/compute
Compute Section 481
Compute the §481(a) adjustment for the tenant’s active MTM election. Pulls open positions as of 12/31/<prior_year>, resolves year-end FMV, runs the pure calculator, and (optionally) persists to section_481_adjustments.
Request body: application/json
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/mtm/securities-mtm.csv
Securities Mtm Csv
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional | |
year | query | integer | required | |
taxpayer_name | query | string | optional | |
ein | query | string | optional |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/mtm/securities-mtm.pdf
Securities Mtm Pdf
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional | |
year | query | integer | required | |
taxpayer_name | query | string | optional | |
ein | query | string | optional |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/mtm/year-end-marks
List Year End Marks
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional | |
year | query | integer | required |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
POST /api/trading-intel/mtm/year-end-marks/fetch
Fetch Year End Marks
Resolve year-end FMV for the given symbols (or all currently-open Schwab positions if symbols omitted). Falls back yfinance → alpha_vantage → manual. When persist=True, writes results to year_end_marks.
Request body: application/json
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/options/flow
Get Options Flow
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional | |
limit | query | integer | optional |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/position-mgmt/allocation
Get Allocations
Fetch stored allocation recommendations.
Default: latest compute only — one row per (symbol, method) ordered by
most-recent created_at. This avoids piling up multiple days of stale
recommendations in the UI and ends the schema-bifurcation drift the older
lookback window was masking (#211).
Back-compat: passing ?days=N restores the legacy “last N days” window.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional | |
days | query | — | optional | Legacy: include the last N days of compute runs. When omitted (default), returns only the latest run per (symbol, method) — the normal UI path (#211). |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
POST /api/trading-intel/position-mgmt/allocation/compute
Compute Allocations
Compute and persist allocation recommendations for one method.
Request body: application/json
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/position-mgmt/exit
Get Exit Strategies
Fetch stored ATR-based exit strategies.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional | |
symbol | query | — | optional | |
days | query | integer | optional |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
POST /api/trading-intel/position-mgmt/exit/compute
Compute Exit Strategies
Compute ATR-based stop-loss and exit levels for portfolio positions.
Request body: application/json
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/position-mgmt/exit/triggers
Get Stop Triggers
Return positions where current price is at or below the stored stop-loss.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
POST /api/trading-intel/position-mgmt/schwab/ingest
Run Schwab Ingest
Pull Schwab transactions for the given year and persist to schwab_transactions, schwab_closed_lots, schwab_open_lots.
Idempotent — re-running refreshes raw_json and rebuilds open-lot snapshot. Safe to invoke repeatedly during Schwab session hours.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
year | query | — | optional | YYYY, defaults to current year |
account_id | query | — | optional | broker_accounts.id; when omitted, ingest every Schwab-connected account |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/position-mgmt/strategy/by-symbol/{symbol}
Get Strategy By Symbol
Drill-down for a single symbol — lot-level trade list + KPIs.
Response shape matches frontend StrategyBySymbolResponse:
- trades[]: side, quantity, cost_basis, acquired_date, sold_date, holding_days, entry_price, exit_price, proceeds, fees, pnl, pnl_pct, multiplier, source, confidence, rationale, is_orphan, is_unknown_basis, is_partial
- summary: window_days, total_rows, kpi_rows, total_pnl, win_rate, avg_win, avg_loss, low_sample
- data_quality: orphan_count, unknown_basis_count, partial_count, full_match_count, low_sample, low_sample_threshold
KPI eligibility: excludes rows with cost<=0 (orphans + unknown-basis) so win rate and P&L reflect only computable trades.
TODO(mobile): This endpoint is mobile-consumed via @nocookiespot/shared-types. Before P1, tighten to an explicit Pydantic v2 response_model with:
- money fields (proceeds/cost/pnl/cum_pnl) as MoneyString (see packages/shared-types/src/schemas/money.ts in the mobile repo)
- date fields as ISO-8601 with offset
- summary/data_quality as named BaseModel subtypes Current shape is web-compatible (floats) and stable; coordinate the switch with mobile-claude when ready to regenerate shared-types.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
symbol | path | string | required | |
tenant_id | query | integer | optional | |
account_id | query | — | optional | |
days | query | integer | optional | |
source_policy | query | string | optional | ’all’ returns every source (legacy CSV + Schwab lot-match). ‘trusted’ filters to Schwab lot-match only. Default ‘all’ until Schwab ingest replaces legacy CSV as the primary source. |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/position-mgmt/strategy/live
Get Live Strategy
Sharpe / Sortino / drawdown / win-rate analytics on realized_trades.
Default source_policy=‘trusted’ excludes csv_upload and orphan rows, so KPIs
reflect only broker-verified closed lots. The excluded slice is surfaced as
unreliable_excluded for UI transparency.
Filtering precedence: when year is supplied, uses the explicit year range
(optionally narrowed by month); otherwise falls back to rolling days.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional | |
account_id | query | — | optional | |
days | query | integer | optional | |
year | query | — | optional | |
month | query | — | optional | |
symbol | query | — | optional | |
source_policy | query | string | optional | ’trusted’ = only Schwab FIFO matches (authoritative). ‘all’ = include csv_upload + orphan rows (legacy view). |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/recommendations
Get Recommendations
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional | |
status | query | string | optional | |
limit | query | integer | optional |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
POST /api/trading-intel/recommendations/generate
Generate Recommendations
Run NBA engine (stored signals) + live Schwab quotes to create recommendations.
Request body: application/json
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/recommendations/history
Recommendation History
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional | |
days | query | integer | optional | |
limit | query | integer | optional |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
PATCH /api/trading-intel/recommendations/{rec_id}/ack
Ack Recommendation
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
rec_id | path | integer | required | |
tenant_id | query | integer | optional |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/risk
Get Portfolio Risk
Portfolio concentration + volatility risk analysis with HHI.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional | |
account_id | query | — | optional |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/risk/portfolio-metrics
Get Risk Portfolio Metrics
Sharpe, Sortino, max drawdown, CAGR, win rate, profit factor from trade history.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional | |
account_id | query | — | optional | |
days | query | integer | optional |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/scanner
Get Scanner
Market scanner — returns symbols matching the requested scan type.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional | |
scan_type | query | string | optional | TOP_GAINERS |
limit | query | integer | optional |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
POST /api/trading-intel/signals/refresh-market-wide
Refresh Market Wide Signals
Queue ML forecast generation for a market universe.
Returns immediately; forecasts run in the background. New signals appear in the pre-market gameplan within 1–3 minutes.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
universe | query | string | optional | portfolio |
tenant_id | query | integer | optional | |
account_id | query | — | optional | |
return_pct_threshold | query | number | optional | Min absolute predicted return %% to generate a signal |
limit | query | integer | optional | Max symbols to process in this run (1–50) |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/ta/analyze
Get Ta Analysis
Full technical analysis for a symbol.
Fetches OHLCV (yfinance primary, Alpaca fallback) and computes: RSI(14), MACD(12/26/9), SMA(20), SMA(50), Bollinger Bands(20,2), VWAP.
Also returns:
- Recent news/events from market_intel for the symbol
- Existing intraday AI signals for the symbol
- Live market index quotes (SPY, QQQ, DIA, ^VIX) for macro context
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
symbol | query | string | required | Ticker symbol, e.g. AAPL |
interval | query | string | optional | Bar interval: 1m 5m 15m 30m 1h 1d 1wk |
period | query | string | optional | Look-back period: 1d 5d 1mo 3mo 6mo 1y 2y 5y |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
POST /api/trading-intel/ta/ask
Ta Ask
Ask Claude a free-form question about a symbol using live market context.
Accepts optional pre-fetched context (indicators, news, market_indices, bars_tail) to avoid a duplicate yfinance call when the frontend already has the data loaded. If not provided, falls back to a fresh fetch.
Request body: application/json
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/ta/chart
Get Ta Chart
OHLCV bars formatted for lightweight-charts (time = Unix seconds).
Returns a minimal payload suited for charting: no indicators, no news. Use /ta/analyze for the full analysis payload.
Future-ready: set the provider param to switch data source.
Implement stubs in ohlcv_provider.py then set the required env var.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
symbol | query | string | required | Ticker symbol, e.g. AAPL |
interval | query | string | optional | Bar interval: 1m 5m 15m 30m 1h 1d 1wk |
period | query | string | optional | Look-back period: 1d 5d 1mo 3mo 6mo 1y 2y 5y |
provider | query | string | optional | Data provider: auto |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/ta/ml-forecast
Get Ml Forecast
ML-powered 5-day price target range.
TA-031: Trained models are persisted to disk and reused for <200 ms warm-path responses (cache TTL = 24 h, keyed by symbol + interval + feature_version).
TA-030: Pass features=extended to enable VP / FVG / sweep-distance features.
Extended features are also gated by the user pref ml_extended_features
(default false); both conditions must be true.
Trains a Random Forest Regressor on the requested OHLCV history using lagged returns + RSI / MACD / Bollinger Bands / VWAP / volume features. Returns target_low / target_high (±1σ tree spread) and a confidence score derived from test-set R² and prediction-interval tightness.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
symbol | query | string | required | Ticker symbol, e.g. AAPL |
interval | query | string | optional | Bar interval: 1d 1wk (daily recommended for RF) |
period | query | string | optional | Look-back period: 3mo 6mo 1y 2y |
tenant_id | query | integer | optional | Tenant ID |
features | query | string | optional | TA-030: Feature set. ‘baseline’ (default) uses OHLCV + TA indicators. ‘extended’ adds VP distances + FVG zone + sweep features. Extended features also require the user pref ml_extended_features=true. |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
POST /api/trading-intel/ta/options-payoff
Compute Options Payoff
Compute expiry P&L payoff for a portfolio of option contracts.
Returns 120-point price curve, max profit/loss, breakevens, and current PnL. Values are per strategy (quantity × 100 shares per contract).
Request body: application/json
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/ta/providers
List Ta Providers
List all registered OHLCV providers and whether their credentials are set.
Responses
| Code | Description |
|---|---|
200 | Successful Response |
GET /api/trading-intel/timing
Get Timing Insights
Return timing insights derived from signal generation patterns.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional | |
account_id | query | — | optional | |
limit | query | integer | optional |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/trade-quality
Get Trade Quality
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional | |
account_id | query | — | optional | |
limit | query | integer | optional |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
POST /api/trading-intel/volume/detect
Detect Volume
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/trading-intel/volume/signals
Get Volume Signals
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | integer | optional | |
limit | query | integer | optional |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |