{"components":{"responses":{"BadRequest":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ValidationError"}}},"description":"Bad Request - invalid parameters or payload"},"NotFoundError":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/NotFoundError"}}},"description":"Requested resource was not found."},"PermissionDenied":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PermissionDenied"}}},"description":"Permission denied or missing authentication token."},"RateLimitExceeded":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RateLimitExceeded"}}},"description":"Daily usage-token allowance exhausted. Upgrade to Pro or Admin for higher limits.","headers":{"Retry-After":{"description":"Seconds until the allowance resets","schema":{"type":"integer"}},"X-Usage-Tokens-Limit":{"description":"Daily usage-token allowance","schema":{"type":"string"}},"X-Usage-Tokens-Remaining":{"description":"Remaining usage tokens for today","schema":{"type":"string"}},"X-Usage-Tokens-Reset":{"description":"When the allowance resets (00:00 Europe/Berlin)","schema":{"type":"string"}}}}},"schemas":{"ApiToken":{"properties":{"create_dt":{"format":"date-time","type":"string"},"id":{"type":"integer"},"is_active":{"type":"boolean"},"last_used_at":{"format":"date-time","type":"string"},"name":{"type":"string"},"tier":{"enum":["free","pro","adm"],"type":"string"},"token_prefix":{"type":"string"}},"type":"object"},"AssetItem":{"properties":{"api":{"example":"tv","type":"string"},"description":{"example":"Bitcoin (USD)","type":"string"},"exchange":{"example":"coinbase","type":"string"},"label":{"example":"Bitcoin (USD)","type":"string"},"symbol":{"example":"btcusd:coinbase:1D","type":"string"},"ticker":{"example":"btcusd","type":"string"}},"type":"object"},"BotHubItem":{"properties":{"id":{"example":4,"type":"integer"},"interval":{"example":"1D","type":"string"},"is_active":{"example":true,"type":"boolean"},"last_run":{"format":"date-time","type":"string"},"status":{"example":"idle","type":"string"},"strategy_id":{"example":12,"type":"integer"},"symbol":{"example":"btcusd:coinbase:1D","type":"string"}},"type":"object"},"BotPositionItem":{"properties":{"current_price":{"example":67800.0,"type":"number"},"direction":{"enum":["long","short"],"example":"long","type":"string"},"entry_price":{"example":64200.0,"type":"number"},"id":{"example":10,"type":"integer"},"open_time":{"format":"date-time","type":"string"},"quantity":{"example":0.5,"type":"number"},"symbol":{"example":"btcusd:coinbase:1D","type":"string"},"unrealized_pnl":{"example":1800.0,"type":"number"}},"type":"object"},"MetadataBlock":{"description":"Standard metadata block attached to data responses.","properties":{"is_live_download":{"example":false,"type":"boolean"},"provider":{"example":"coinbase","type":"string"},"sample_count":{"example":2480,"type":"integer"},"sample_end_date":{"example":"2026-10-15","type":"string"},"sample_start_date":{"example":"2018-01-01","type":"string"},"symbol":{"example":"btcusd:coinbase:1D","type":"string"},"timezone":{"example":"UTC","type":"string"}},"type":"object"},"NotFoundError":{"properties":{"error":{"example":"Not Found","type":"string"},"message":{"example":"The requested resource was not found.","type":"string"}},"type":"object"},"OhlcBar":{"description":"Candlestick price bar.","properties":{"close":{"example":16750.8,"type":"number"},"high":{"example":16800.5,"type":"number"},"low":{"example":16480.0,"type":"number"},"open":{"example":16540.2,"type":"number"},"time":{"description":"Unix timestamp in seconds (UTC)","example":1672531200,"type":"integer"},"volume":{"example":124800.0,"type":"number"}},"type":"object"},"PerformanceMetrics":{"description":"Comprehensive statistical, performance, and risk metrics calculated over the period.","properties":{"+str":{"description":"Max Consecutive Wins \u2014 longest sequence of winning cycles","example":8,"type":"integer"},"-str":{"description":"Max Consecutive Losses \u2014 longest sequence of losing cycles","example":4,"type":"integer"},"cagr":{"description":"Compound Annual Growth Rate (%) \u2014 annualized geometric growth rate","example":24.8,"type":"number"},"cnt":{"description":"Count / Sample Size \u2014 total number of occurrences or trades analyzed","example":245,"type":"integer"},"dd":{"description":"Current Drawdown (%) from recent peak","example":-4.2,"type":"number"},"dd_max":{"description":"Maximum Drawdown (%) \u2014 largest peak-to-trough decline over the entire horizon","example":-14.6,"type":"number"},"end":{"description":"Latest date included in analysis","example":"2026-10-15","type":"string"},"lmax":{"description":"Maximum Single Loss (%)","example":-9.2,"type":"number"},"name":{"description":"Period label (e.g. 'Monday', 'January', '2024')","example":"Monday","type":"string"},"perfm":{"description":"Monthly Performance (%) \u2014 average expanding mean return per monthly cycle","example":3.12,"type":"number"},"pfac":{"description":"Profit Factor \u2014 ratio of gross gains to gross losses (sum gains / sum losses). >1.5 indicates a robust statistical edge","example":2.15,"type":"number"},"r2":{"description":"R\u00b2 Linearity Score (0.0 to 1.0) \u2014 coefficient of determination measuring consistency and smoothness of the cumulative curve","example":0.91,"type":"number"},"roi":{"description":"Return on Investment (%) \u2014 total cumulative percentage return across the period","example":142.5,"type":"number"},"sor":{"description":"Sortino Ratio \u2014 excess return penalized only by downside standard deviation","example":2.41,"type":"number"},"sr":{"description":"Sharpe Ratio \u2014 annualized excess return per unit of volatility (risk-adjusted return metric)","example":1.84,"type":"number"},"start":{"description":"Earliest date included in analysis","example":"2018-01-01","type":"string"},"str":{"description":"Current Streak \u2014 positive for winning streak, negative for losing streak","example":3,"type":"integer"},"ticker":{"description":"Asset ticker symbol","example":"btcusd","type":"string"},"vola":{"description":"Annualized Volatility (%) \u2014 standard deviation of percentage returns","example":38.2,"type":"number"},"win":{"description":"Win Rate (%) \u2014 percentage of cycles or trades with positive returns","example":68.5,"type":"number"},"wmax":{"description":"Maximum Single Win (%)","example":18.5,"type":"number"}},"type":"object"},"PermissionDenied":{"properties":{"current_permission":{"example":"free","type":"string"},"docs_url":{"example":"https://metaduro.com/api/docs","type":"string"},"error":{"example":"Permission Denied","type":"string"},"hint":{"type":"string"},"message":{"example":"Live historical downloads require 'pro' or 'adm' permission.","type":"string"},"required_permission":{"example":"pro","type":"string"},"token_url":{"example":"https://metaduro.com/user/tokens","type":"string"}},"type":"object"},"RateLimitExceeded":{"description":"Returned when client IP exceeds 10 requests per day on free/anonymous tiers.","properties":{"current_permission":{"example":"free","type":"string"},"docs_url":{"example":"https://metaduro.com/api/docs","type":"string"},"error":{"example":"Rate Limit Exceeded","type":"string"},"hint":{"example":"Pro and Admin tokens have unlimited API access. Generate or upgrade your token at https://metaduro.com/user/tokens","type":"string"},"limit":{"example":10,"type":"integer"},"message":{"example":"Daily API rate limit of 10 requests per day exceeded for IP 203.0.113.195. Upgrade to Pro or Admin for unlimited API access.","type":"string"},"remaining":{"example":0,"type":"integer"},"required_permission":{"example":"pro","type":"string"},"reset_at":{"example":"2026-10-18T00:00:00Z","format":"date-time","type":"string"},"reset_seconds":{"example":43200,"type":"integer"},"reset_timestamp":{"example":1776470400,"type":"integer"},"token_url":{"example":"https://metaduro.com/user/tokens","type":"string"}},"type":"object"},"StrategyMetrics":{"description":"Backtest execution summary metrics.","properties":{"cagr":{"example":31.2,"type":"number"},"gross_loss":{"example":-22960.0,"type":"number"},"gross_profit":{"example":44800.0,"type":"number"},"linearity_r2":{"example":0.88,"type":"number"},"max_dd":{"example":-16.8,"type":"number"},"net_profit":{"example":21840.0,"type":"number"},"pfac":{"example":1.95,"type":"number"},"roi":{"example":218.4,"type":"number"},"sr":{"example":1.62,"type":"number"},"trades_count":{"example":78,"type":"integer"},"win":{"example":61.5,"type":"number"}},"type":"object"},"TableColumn":{"description":"Column descriptor for tabular display.","properties":{"Header":{"example":"Win Rate (%)","type":"string"},"accessor":{"example":"win","type":"string"}},"type":"object"},"TradeLog":{"description":"Individual simulated trade record.","properties":{"bars_held":{"example":12,"type":"integer"},"direction":{"enum":["long","short"],"example":"long","type":"string"},"entry_price":{"example":20450.0,"type":"number"},"entry_time":{"example":"2023-03-12T00:00:00Z","type":"string"},"exit_price":{"example":24200.0,"type":"number"},"exit_reason":{"enum":["rule_close","take_profit","stop_loss","max_bars","end_of_data"],"example":"take_profit","type":"string"},"exit_time":{"example":"2023-03-24T00:00:00Z","type":"string"},"pnl_amount":{"example":1834.0,"type":"number"},"pnl_percent":{"example":18.34,"type":"number"}},"type":"object"},"TradingAccount":{"properties":{"broker":{"example":"coinbase","type":"string"},"create_dt":{"format":"date-time","type":"string"},"environment":{"enum":["paper","live"],"example":"paper","type":"string"},"id":{"example":1,"type":"integer"},"is_active":{"example":true,"type":"boolean"},"name":{"example":"Coinbase Pro Main","type":"string"}},"type":"object"},"TradingViewPoint":{"description":"Single coordinate point for lightweight financial charts.","properties":{"time":{"description":"Unix timestamp in seconds or ISO date string (YYYY-MM-DD)","example":1672531200,"oneOf":[{"type":"integer"},{"type":"string"}]},"value":{"description":"Metric or price value at this point in time","example":142.5,"type":"number"}},"required":["time","value"],"type":"object"},"TradingViewSeries":{"description":"Chart line or histogram series compatible with TradingView Lightweight Charts.","properties":{"id":{"example":"btcusd","type":"string"},"name":{"example":"Bitcoin Equity Curve","type":"string"},"type":{"example":"line","type":"string"},"value":{"items":{"$ref":"#/components/schemas/TradingViewPoint"},"type":"array"}},"required":["name","value"],"type":"object"},"ValidationError":{"properties":{"error":{"example":"Bad Request","type":"string"},"message":{"example":"Invalid symbol format. Expected 'ticker:exchange:interval' (e.g. 'btcusd:coinbase:1D').","type":"string"}},"type":"object"}},"securitySchemes":{"ApiKeyAuth":{"description":"Alternative header: `X-API-Key: mtd_live_...`.","in":"header","name":"X-API-Key","type":"apiKey"},"BearerAuth":{"bearerFormat":"API Token / JWT","description":"Recommended: Pass your API token (`mtd_live_...`) or session JWT in the Authorization header: `Authorization: Bearer <token>`.","scheme":"bearer","type":"http"},"QueryTokenAuth":{"description":"DEPRECATED: Query string token (`?token=mtd_live_...`). Discouraged because tokens may leak into server access logs. Maintained for legacy compatibility.","in":"query","name":"token","type":"apiKey"}}},"externalDocs":{"description":"MetaDuro MCP server for AI assistants (Claude, Cursor, ChatGPT)","url":"https://metaduro.com/mcp"},"info":{"contact":{"email":"info@metaduro.com","name":"MetaDuro","url":"https://metaduro.com"},"description":"Interactive, production-ready REST API for cryptocurrency and equity seasonality analysis, algorithmic strategy backtesting, technical indicator scans, and automated trading management.\n\n### 1. Authentication & API Tokens\nMetaDuro supports three authentication headers:\n- **`Authorization: Bearer <token>`** (Recommended)\n- **`X-API-Key: <token>`** (Alternative)\n- **`?token=<token>`** (*Deprecated* - query parameters are logged in intermediaries. Deprecated in docs but supported for legacy clients)\n\nGenerate API tokens at: [https://metaduro.com/user/tokens](https://metaduro.com/user/tokens)\n\n### Daily Usage-Token Allowances & Reset\nMetaDuro features a daily compute usage-token system (distinct from authentication API tokens):\n- **`free`**: Anonymous visitors \u2014 **10 tokens/day** (secured via cryptographic cookies & IP abuse controls).\n- **`plus`**: Registered users \u2014 **50 tokens/day** (shared across all browser sessions and API keys for the account).\n- **`pro`**: Upgraded users \u2014 **100 tokens/day**.\n- **`adm`**: Administrators \u2014 **10,000 tokens/day**.\n\n- **Reset Time**: All allowances reset daily at **00:00 Europe/Berlin** (respecting CET/CEST daylight-saving time).\n- **Route Costs**: Metered quantitative operations (backtests, scans, seasonality curves) cost 1 token by default (`x-token-cost`).\n- **Unmetered Endpoints**: Documentation, authentication, and usage balance checks (`/api/user/usage`) cost **0 tokens**.\n- **Response Headers**: `X-Usage-Tokens-Cost`, `X-Usage-Tokens-Remaining`, `X-Usage-Tokens-Limit`, `X-Usage-Tokens-Reset`.\n\n### 2. Financial & Time-Series Semantics\n- **Symbol Convention**: Uniform format `ticker:exchange:interval` (e.g. `btcusd:coinbase:1D`, `spy:amex:1D`, `aapl:nasdaq:1D`). Default interval is `1D` (Daily).\n- **Local Historical Datasets (`local` exchange)**: For select assets, extensive preloaded multi-year tick/bar archives are stored in the local tickdata history repository. Use `local` as the exchange identifier (e.g. `xauusd:local:4h`, `btcusd:local:4h`) to run high-depth simulations without live provider bar caps or network overhead.\n- **Timezone & Candles**: All candle timestamps and session dates are in **UTC**. Equities align with exchange trading sessions (09:30-16:00 EST / UTC-5); crypto is 24/7.\n- **Incomplete Bar Handling**: Active/current incomplete candles are **strictly excluded** from seasonal statistics and backtests to avoid forward-looking bias (repaint).\n- **Data Freshness & Caching**: Cached historical OHLC bars are served instantly. Passing `dl=1` (or `download=true`) executes an on-demand exchange fetch and updates local storage (requires `pro` or `adm`).\n- **Boolean Parameters**: `dl`, `download`, and boolean flags accept `1`, `true`, `yes`, `on` or integer bar count (e.g. `dl=500` for 500 bars), and `0`, `false`, `no`, `off`.\n\n### 3. Quantitative Performance Metrics Reference\nSummary tables (`tblSum.rows` and `tbl.rows`) across seasonality, scans, and strategies return standardized metrics:\n\n| Metric | Name | Definition & Unit |\n|---|---|---|\n| `perfm` | Monthly Performance | Expanding mean return per monthly cycle or trade (%) |\n| `pfac` | Profit Factor | Ratio of gross profits to gross losses (`sum gains / sum losses`). Values >1.5 indicate a strong edge. |\n| `sr` | Sharpe Ratio | Annualized excess return per unit of volatility (`(mean excess return / std_dev) * sqrt(252)`). |\n| `sor` | Sortino Ratio | Annualized excess return penalized only by downside standard deviation. |\n| `r2` | Linearity Score (R\u00b2) | Coefficient of determination (0.0 to 1.0) assessing smoothness and linear consistency of the cumulative equity curve. |\n| `roi` | Return on Investment | Cumulative percentage return over the evaluated backtest horizon (%). |\n| `cagr` | Compound Annual Growth Rate | Annualized geometric growth rate of capital (%). |\n| `win` | Win Rate | Percentage of holding periods or trades that closed in profit (0.0 to 100.0%). |\n| `cnt` | Sample Size / Count | Total number of evaluated cycles, trades, or periods. |\n| `dd` | Current Drawdown | Percentage decline from the recent equity all-time high (negative %, e.g. `-4.2%`). |\n| `dd_max` | Maximum Drawdown | Largest historical peak-to-trough decline over the entire horizon (negative %, e.g. `-21.4%`). |\n| `vola` | Volatility | Annualized standard deviation of percentage returns (%). |\n| `str` | Current Streak | Active run of consecutive winning (+) or losing (-) periods. |\n| `+str` / `-str` | Max Streaks | Longest historical run of consecutive winning or losing cycles. |\n| `wmax` / `lmax` | Max Gain / Loss | Largest single period positive gain (%) and negative loss (%). |\n| `start` / `end` | Horizon Dates | Earliest and latest historical dates included in the sample (YYYY-MM-DD). |\n\n### 4. Strategy Backtesting DSL Reference\n\nMetaDuro features an event-driven backtesting engine powered by a high-level Domain-Specific Language (DSL). Strategies are submitted via `POST /api/data/str` (JSON body) or `GET /api/data/str` (query parameters). To retrieve TradingView candle/trade overlay series, use `POST /api/data/tvstr`. To look up parameter names, formulas, and defaults across all 160+ mathematical indicators, query `/api/data/ta/docs` (or `/api/ta/docs`).\n\n#### 4.1 Complete Strategy DSL Parameters Reference\nA strategy payload configures asset discovery, signal rule trees, risk parameters, execution sizing, and simulation controls. Every parameter below is supported across `POST /api/data/str`, `GET /api/data/str`, and `POST /api/data/tvstr`:\n\n| Parameter | Category | Type | Default | Required | Description |\n|---|---|---|---|---|---|\n| `s` | Asset & Universe | string | \u2014 | **Yes** | Asset identifier: `ticker:exchange:interval` (e.g. `btcusd:coinbase:1D`, `xauusd:local:4h`, `aapl:nasdaq:1h`, `spy:amex:1D`, `ethusd:hyperliquid:15m`). Also accepts inline calendar filters like `spy:amex:1D:weekday:4` (Friday entries) or `btcusd:coinbase:1D:month:10` (October entries). |\n| `e` | Asset & Universe | string | \u2014 | No | Exchange identifier (e.g. `coinbase`, `nasdaq`, `amex`, `nyse`, `binance`, `hyperliquid`, `fx`, `local`). Use `local` to query preloaded deep historical archives directly (e.g. `xauusd:local:4h`). Optional when specified inside `s`. |\n| `i` | Asset & Universe | string | \u2014 | No | Timeframe / bar interval (e.g. `1D`, `4h`, `1h`, `15m`, `5m`, `1m`). Optional when specified inside `s`. |\n| `l` | Asset & Universe | string | \u2014 | No | Tickerlist or market basket name (e.g. `top-crypto20`, `nasdaq100`, `sp500`) to execute multi-asset batch scans or universe backtests. |\n| `api` | Asset & Universe | string | `\"tv\"` | No | Market data provider feed engine (`\"tv\"` for TradingView, `\"alp\"` for Alpaca, `\"hl\"` for Hyperliquid, `\"bin\"` for Binance, `\"cc\"` for CryptoCompare). |\n| `acc` | Asset & Universe | string | \u2014 | No | Account identifier or broker sub-account routing selector (aliases: `account`, `account_id`, `endpoint`). |\n| `o` | Signals & Entry | array | \u2014 | **Yes** | Entry / Open conditions tree. Evaluated on candle close; triggers a trade entry when evaluated to `true`. Supports both Array syntax (`[[\"rsi\", \"<\", 30], \"and\", [\"close\", \">\", [\"sma\", 200]]]`) and Object syntax (`[{\"<\": [{\"rsi\": 14}, {\"value\": 30}]}]`). |\n| `c` | Signals & Exit | array | \u2014 | No | Conditional Exit / Close rule tree. Evaluated on each bar while in an open trade; closes position at market when evaluated to `true`. |\n| `slt` | Signals & Exit | array | \u2014 | No | Dynamic Stop-Loss Trigger rule tree. Evaluated on every bar (e.g. price breaches prior swing low or Opening Range Breakout boundary). Immediately liquidates position. |\n| `ttp` | Signals & Exit | array / number | \u2014 | No | Trailing Take-Profit rule tree or dynamic profit lock. When passed as a numeric float (e.g. `2.5`), operates as an alias for `rr` (risk-to-reward multiple). |\n| `sl` | Risk Management | number | \u2014 | No | Fixed percentage Stop-Loss (e.g. `5` for 5% maximum adverse excursion from entry price). Exits trade at loss boundary. |\n| `tp` | Risk Management | number | \u2014 | No | Fixed percentage Take-Profit target (e.g. `15` for 15% profit target above entry price). Exits trade at target price. |\n| `rr` | Risk Management | number | \u2014 | No | Risk-to-Reward ratio multiplier (e.g. `2.0` targets twice the stop-loss distance). Dynamically computes take-profit level based on initial stop distance. |\n| `n` | Risk Management | integer | \u2014 | No | Maximum holding duration in bars (time-based stop). Position automatically closes at market after `n` bars if not already exited via SL, TP, or `c`. |\n| `t` | Position & Sizing | integer / number | `1` | No | Trade direction and exposure weight: `1` for Long, `-1` for Short. Can also be fractional (e.g. `0.5` for 50% capital exposure). |\n| `h` | Position & Sizing | integer | `1` | No | Hedging / parallel trade allowance. Maximum number of concurrent simultaneous positions allowed for this strategy. |\n| `bal` | Position & Sizing | number | `10000` | No | Starting cash account capital in base currency used for trade sizing, compounding, and drawdown calculations. |\n| `spread` | Position & Sizing | number | `0.0` | No | Bid-ask spread slippage cost percentage per trade (e.g. `0.05` for 5 bps slippage penalty subtracted on entry and exit). |\n| `bm` | Portfolio & Meta | string | \u2014 | No | Benchmark asset symbol (e.g. `spy:amex:1D`, `btcusd:coinbase:1D`) for alpha, beta, and comparative buy-and-hold equity curves. |\n| `name` | Portfolio & Meta | string | \u2014 | No | Human-readable strategy name or description displayed in summary tables, trade logs, and charts. |\n| `str` | Portfolio & Meta | array | \u2014 | No | Composite / multi-strategy portfolio array. When provided, evaluates multiple child strategies together into a blended portfolio equity curve. |\n| `dl` | Engine & Fetching | integer / bool | `0` | No | On-demand bar fetch: pass `1` (or count like `500`) to force fresh bar retrieval from live market feeds. |\n| `nbars` | Engine & Fetching | integer | \u2014 | No | Total historical bar count to fetch and evaluate (e.g. `nbars=5000` evaluates the most recent 5,000 bars). |\n| `tail` | Engine & Fetching | integer | \u2014 | No | Excludes the newest N bars of history from simulation (e.g. `tail=5000` trims off the latest 5,000 bars to evaluate older historical data or out-of-sample periods). |\n| `try` | Engine & Fetching | integer | \u2014 | No | Maximum retry attempts for connecting to external data feeds. |\n| `nocache` | Engine & Fetching | boolean | `false` | No | Bypass server-side backtest cache: pass `true` or `1` to force recomputation. |\n\n#### 4.2 Dual Syntax: Array vs Dict\nThe engine accepts two equivalent syntax representations:\n1. **Array / Tuple Syntax** (Clean, concise, human- & AI-friendly):\n   `[[\"rsi\", \"<\", 30], \"and\", [\"close\", \">\", [\"sma\", 200]]]`\n2. **Native JSON Object Syntax** (Explicit tree structure):\n   `[{\"<\": [{\"rsi\": 14}, {\"value\": 30}]}, {\">\": [{\"close\": 0}, {\"sma\": 200}]}]`\n\nBoth formats are fully parsed, validated, and normalized by the backtesting engine.\n\n#### 4.3 Condition Grammar & Comparison Operators\nEach condition compares two time-series operands or a time-series against a scalar threshold:\n\n- **Array format**: `[left_operand, operator, right_operand]`\n- **Object format**: `{\"operator\": [left_operand, right_operand]}`\n\n| Operator | Alias | Description | Example |\n|---|---|---|---|\n| `<` | | Less than | `[\"rsi\", \"<\", 30]` or `{\"<\": [{\"rsi\": 14}, 30]}` |\n| `<=` | | Less than or equal to | `[[\"close\", 0], \"<=\", [\"bbands_low\", 20]]` |\n| `>` | | Greater than | `[[\"close\", 0], \">\", [\"sma\", 200]]` |\n| `>=` | | Greater than or equal to | `[\"rsi\", \">=\", 70]` |\n| `==` | `=` | Equal to | `[\"stoch\", \"==\", 50]` |\n| `!=` | | Not equal to | `[\"volume\", \"!=\", 0]` |\n| `crosses_above` | `x` | Left crosses above Right (bullish cross) | `[[\"sma\", 50], \"crosses_above\", [\"sma\", 200]]` or `{\"x\": [{\"sma\": 50}, {\"sma\": 200}]}` |\n| `crosses_below` | `y` | Left crosses below Right (bearish cross) | `[[\"sma\", 50], \"crosses_below\", [\"sma\", 200]]` or `{\"y\": [{\"sma\": 50}, {\"sma\": 200}]}` |\n\n#### 4.4 Seasonality Filters\nStrategies can restrict entries to specific calendar and intraday windows:\n- **Weekday**: `{\"s\": {\"weekday\": [0, 4]}}` (0 = Monday, 1 = Tuesday, 2 = Wednesday, 3 = Thursday, 4 = Friday)\n- **Month**: `{\"s\": {\"month\": [10, 11, 12]}}` (1 = January ... 12 = December)\n- **Hour**: `{\"s\": {\"hour\": [9, 10, 15]}}` (Intraday bar hours)\n\n#### 4.5 Operands (Prices, Constants, Indicators)\nOperands on either side of an operator can be:\n1. **Price Columns**: `\"close\"` (or `\"c\"`), `\"open\"` (or `\"o\"`), `\"high\"` (or `\"h\"`), `\"low\"` (or `\"l\"`), `\"volume\"` (or `\"v\"`). Use `[\"close\", 1]` for 1-bar shifted prior close.\n2. **Constants**: Bare numbers in array format (e.g. `30`, `70.5`, `0.02`) or `{\"value\": 30}` in object format.\n3. **Indicators**: `[\"name\", arg1, arg2]` (e.g. `[\"rsi\", 14]`, `[\"sma\", 200]`, `[\"ema\", 50]`, `[\"bbands_low\", 20]`, `[\"macd\", 12, 26, 9]`, `[\"atr\", 14]`). See `/api/data/ta/docs` for all 160+ supported indicators.\n4. **Multipliers & Math**: In object syntax, scale indicators with `{\"*\": [{\"atr\": 14}, 2.5]}` or math nodes `_add`, `_sub`, `_mul`, `_div`.\n\n#### 4.6 Boolean Composition (AND / OR)\n- **Array Syntax**:\n  - Explicit AND: `[[\"rsi\", \"<\", 30], \"and\", [\"close\", \">\", [\"sma\", 200]]]`\n  - Explicit OR: `[[\"rsi\", \"<\", 20], \"or\", [\"close\", \"<\", [\"bbands_low\", 20]]]]`\n  - Multi-condition lists without connector default to logical AND: `[[\"rsi\", \"<\", 30], [\"close\", \">\", [\"sma\", 200]]]`\n- **Object Syntax**:\n  - Explicit AND: `{\"and\": [{\"<\": [{\"rsi\": 14}, 30]}, {\">\": [{\"close\": 0}, {\"sma\": 200}]}]}`\n  - Explicit OR: `{\"or\": [{\"<\": [{\"rsi\": 14}, 20]}, {\"<\": [{\"close\": 0}, {\"bbands_low\": [20]}]}]}`\n\n#### 4.7 Concrete Production Examples\n\n**Example 1: RSI Oversold Pullback in Bull Trend (Long)**\n```json\n{\n  \"s\": \"btcusd:coinbase:1D\",\n  \"o\": [[\"rsi\", \"<\", 30], \"and\", [\"close\", \">\", [\"sma\", 200]]],\n  \"c\": [[\"rsi\", \">\", 70]],\n  \"sl\": 5.0,\n  \"tp\": 15.0,\n  \"bal\": 10000.0,\n  \"t\": 1,\n  \"bm\": \"btcusd:coinbase:1D\"\n}\n```\n\n**Example 2: Moving Average Crossover (Golden Cross / Death Cross)**\n```json\n{\n  \"s\": \"btcusd:coinbase:1D\",\n  \"o\": [[[\"sma\", 50], \"crosses_above\", [\"sma\", 200]]],\n  \"c\": [[[\"sma\", 50], \"crosses_below\", [\"sma\", 200]]],\n  \"bal\": 10000.0,\n  \"bm\": \"btcusd:coinbase:1D\"\n}\n```\n\n**Example 3: Bollinger Band Mean Reversion with Time Stop**\n```json\n{\n  \"s\": \"ethusd:coinbase:1D\",\n  \"o\": [[\"close\", \"<\", [\"bbands_low\", 20]]],\n  \"c\": [[\"close\", \">\", [\"sma\", 20]]],\n  \"sl\": 4.0,\n  \"tp\": 10.0,\n  \"n\": 15,\n  \"bal\": 10000.0\n}\n```\n\n**Example 4: Weekday Seasonality Strategy**\n```json\n{\n  \"s\": \"xauusd:fx:1D\",\n  \"o\": [{\"s\": {\"weekday\": [2]}}],\n  \"n\": 2,\n  \"sl\": 2.0,\n  \"tp\": 5.0,\n  \"bal\": 10000.0\n}\n```\n\n**Example 5: Short Strategy with ATR Volatility Stop**\n```json\n{\n  \"s\": \"spy:amex:1D\",\n  \"o\": [[\"rsi\", \">\", 75], \"and\", [\"macd\", \"<\", 0]],\n  \"c\": [[\"rsi\", \"<\", 40]],\n  \"t\": -1,\n  \"sl\": 3.0,\n  \"tp\": 8.0,\n  \"bal\": 25000.0\n}\n```\n\n### 5. Practical Usage Examples\nSee the interactive explorer below and the static guide for complete examples of:\n1. Asset Discovery for Bitcoin (`/api/data/assets?search=btc`)\n2. Monthly & Weekday Seasonality (`/api/data/seasonality?s=btcusd:coinbase:1D&datet=weekday`)\n3. Reading a Saved Strategy (`/api/data/mystr/bitcoin-rsi-oversold-daily-u-btcrsi`)\n4. Running a Custom Backtest (`POST /api/data/str`)\n5. Comparing Against Buy and Hold (`/api/data/str?s=btcusd:coinbase:1D&bm=btcusd:coinbase:1D`)","license":{"name":"Proprietary - MetaDuro terms apply","url":"https://metaduro.com/terms"},"termsOfService":"https://metaduro.com/terms","title":"MetaDuro / Coindicator Financial Analytics API","version":"1.0.0","x-logo":{"altText":"MetaDuro","url":"https://metaduro.com/img/logo/logo_192.png"}},"openapi":"3.0.3","paths":{"/data/account":{"delete":{"description":"Deletes broker credentials and disconnects the account.","operationId":"disconnectTradingAccount","parameters":[{"in":"query","name":"id","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Account disconnected"},"404":{"$ref":"#/components/responses/NotFoundError"}},"summary":"Disconnect Trading Account","tags":["Trading Accounts & Automation"],"x-token-cost":0},"get":{"description":"Returns connected exchange and broker accounts for the caller. Requires `pro` or `adm` tier.","operationId":"listTradingAccounts","responses":{"200":{"content":{"application/json":{"schema":{"items":{"$ref":"#/components/schemas/TradingAccount"},"type":"array"}}},"description":"List of connected broker accounts"},"403":{"$ref":"#/components/responses/PermissionDenied"}},"summary":"List Connected Broker Accounts","tags":["Trading Accounts & Automation"],"x-token-cost":0},"post":{"description":"Registers API keys for a new broker connection (Coinbase, Binance, Alpaca, etc.). Requires `pro` or `adm` tier.","operationId":"registerTradingAccount","requestBody":{"content":{"application/json":{"schema":{"properties":{"api_key":{"example":"your_broker_key","type":"string"},"api_secret":{"example":"your_broker_secret","type":"string"},"broker":{"example":"coinbase","type":"string"},"environment":{"enum":["paper","live"],"example":"paper","type":"string"},"name":{"example":"Coinbase Main","type":"string"}},"required":["name","broker","api_key","api_secret"],"type":"object"}}},"required":true},"responses":{"201":{"description":"Account connected successfully"},"403":{"$ref":"#/components/responses/PermissionDenied"}},"summary":"Connect Trading Account","tags":["Trading Accounts & Automation"],"x-token-cost":0}},"/data/account/order/{id}":{"post":{"description":"**CRITICAL ACTION**: Submits an execution order directly to the configured broker account.\n\nStrictly requires administrative (`adm`) permissions. Affects real capital or live paper balance.","operationId":"submitBrokerOrder","parameters":[{"description":"Trading account ID","in":"path","name":"id","required":true,"schema":{"example":1,"type":"integer"}}],"requestBody":{"content":{"application/json":{"schema":{"properties":{"price":{"example":65000.0,"type":"number"},"quantity":{"example":0.05,"type":"number"},"side":{"enum":["buy","sell"],"example":"buy","type":"string"},"symbol":{"example":"btcusd","type":"string"},"type":{"enum":["market","limit"],"example":"market","type":"string"}},"required":["symbol","side","type","quantity"],"type":"object"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"properties":{"order_id":{"example":"ord_81923","type":"string"},"status":{"example":"filled","type":"string"}},"type":"object"}}},"description":"Order submitted to broker"},"403":{"$ref":"#/components/responses/PermissionDenied"}},"summary":"Submit Live Broker Order","tags":["Trading Accounts & Automation"],"x-token-cost":0}},"/data/assets":{"get":{"description":"Returns all available trading assets, tickers, and exchanges from the master 'all' universe list (user 1), including live exchange assets and preloaded deep-history 'local' folder datasets (e.g. `xauusd:local:4h`, `btcusd:local:4h`).\n\nPublicly accessible without authentication.","operationId":"listAssets","parameters":[{"description":"Filter by ticker, exchange, or asset description (case-insensitive)","in":"query","name":"search","schema":{"example":"btc","type":"string"}},{"description":"Filter by exchange (e.g. `coinbase`, `binance`, `amex`, `nasdaq`, `local`)","in":"query","name":"exchange","schema":{"example":"local","type":"string"}},{"description":"Max number of assets to return (default 500, max 2000)","in":"query","name":"limit","schema":{"default":500,"type":"integer"}}],"responses":{"200":{"content":{"application/json":{"schema":{"properties":{"assets":{"items":{"$ref":"#/components/schemas/AssetItem"},"type":"array"},"total":{"example":150,"type":"integer"}},"type":"object"}}},"description":"List of usable assets matching criteria"},"429":{"$ref":"#/components/responses/RateLimitExceeded"}},"security":[],"summary":"List Usable Assets and Symbols","tags":["Assets & Universe"],"x-token-cost":1}},"/data/bot_positions/self":{"get":{"description":"Returns open positions actively managed by automated bots. Requires `pro` or `adm`.","operationId":"listBotPositions","responses":{"200":{"content":{"application/json":{"schema":{"items":{"$ref":"#/components/schemas/BotPositionItem"},"type":"array"}}},"description":"Array of active positions"},"403":{"$ref":"#/components/responses/PermissionDenied"}},"summary":"List Active Bot Positions","tags":["Trading Accounts & Automation"],"x-token-cost":0}},"/data/bot_runtime/status":{"get":{"description":"Returns execution heartbeat, active loop counts, and error state of the bot runtime worker.","operationId":"getBotRuntimeStatus","responses":{"200":{"content":{"application/json":{"schema":{"properties":{"active_bots":{"example":3,"type":"integer"},"last_beat":{"format":"date-time","type":"string"},"status":{"example":"running","type":"string"}},"type":"object"}}},"description":"Bot runtime execution state"},"403":{"$ref":"#/components/responses/PermissionDenied"}},"summary":"Get Live Bot Runtime Status","tags":["Trading Accounts & Automation"],"x-token-cost":0}},"/data/bothub":{"get":{"description":"Lists configured trading bots and automated strategy runners. Requires `pro` or `adm`.","operationId":"listBotHubs","responses":{"200":{"content":{"application/json":{"schema":{"items":{"$ref":"#/components/schemas/BotHubItem"},"type":"array"}}},"description":"List of bot hubs"},"403":{"$ref":"#/components/responses/PermissionDenied"}},"summary":"List Automated Bot Hub Configurations","tags":["Trading Accounts & Automation"],"x-token-cost":0},"post":{"description":"Sets up an automated strategy bot runner. Requires `pro` or `adm`.","operationId":"configureBotHub","requestBody":{"content":{"application/json":{"schema":{"properties":{"account_id":{"example":1,"type":"integer"},"is_active":{"example":true,"type":"boolean"},"strategy_id":{"example":5,"type":"integer"},"symbol":{"example":"btcusd:coinbase:1D","type":"string"}},"required":["strategy_id","symbol"],"type":"object"}}},"required":true},"responses":{"201":{"description":"Bot hub configured"},"403":{"$ref":"#/components/responses/PermissionDenied"}},"summary":"Create or Update Bot Hub Configuration","tags":["Trading Accounts & Automation"],"x-token-cost":0}},"/data/finta/methods":{"get":{"description":"Returns all mathematical indicators, parameters, and descriptions available in the strategy DSL engine.","operationId":"listTechnicalIndicators","responses":{"200":{"content":{"application/json":{"schema":{"additionalProperties":{"properties":{"description":{"type":"string"},"name":{"example":"RSI","type":"string"},"params":{"type":"object"}},"type":"object"},"type":"object"}}},"description":"Catalog of technical indicators"},"4XX":{"$ref":"#/components/responses/BadRequest"}},"security":[],"summary":"List Supported Technical Analysis Indicators","tags":["Strategy Backtesting & DSL"],"x-token-cost":0}},"/data/history":{"get":{"description":"Retrieves historical candlestick price bars (time, open, high, low, close, volume) for any supported symbol.\n\n- **Cache vs. Download**: Serves cached bars instantly. Set `dl=1` to force fresh market downloads (requires `pro` or `adm`).\n- **Timezone**: Bar timestamps are Unix UTC seconds.\n- **Incomplete Bar**: The active incomplete candle is omitted by default.","operationId":"getHistoricalOhlc","parameters":[{"description":"Symbol string format `ticker:exchange:interval` (e.g. `btcusd:coinbase:1D`)","in":"query","name":"s","schema":{"default":"btcusd:coinbase:1D","type":"string"}},{"description":"Alias for `s` (when both provided, `s` takes precedence)","in":"query","name":"symbol","schema":{"type":"string"}},{"description":"Start date boundary (YYYY-MM-DD)","in":"query","name":"start","schema":{"example":"2020-01-01","type":"string"}},{"description":"End date boundary (YYYY-MM-DD)","in":"query","name":"end","schema":{"example":"2026-10-15","type":"string"}},{"description":"Download fresh bars from provider (`1`, `true` requires `pro` or `adm` token)","in":"query","name":"dl","schema":{"default":false,"type":"boolean"}},{"description":"Alias for `dl`","in":"query","name":"download","schema":{"default":false,"type":"boolean"}},{"description":"Maximum number of candles to return (default: 1000, max: 5000)","in":"query","name":"limit","schema":{"default":1000,"type":"integer"}}],"responses":{"200":{"content":{"application/json":{"schema":{"properties":{"bars":{"items":{"$ref":"#/components/schemas/OhlcBar"},"type":"array"},"meta":{"$ref":"#/components/schemas/MetadataBlock"},"total":{"example":1000,"type":"integer"}},"type":"object"}}},"description":"Historical candlestick data with metadata"},"403":{"$ref":"#/components/responses/PermissionDenied"},"429":{"$ref":"#/components/responses/RateLimitExceeded"}},"summary":"Get Historical OHLC Bar Data","tags":["Market Data & OHLC"],"x-token-cost":1}},"/data/mystr/{slug}":{"get":{"description":"Retrieves a saved public trading strategy, its rule definition, and historical backtest performance.\n\nPublicly readable without credentials.","operationId":"getPublicStrategyBySlug","parameters":[{"description":"Public strategy slug identifier","in":"path","name":"slug","required":true,"schema":{"example":"bitcoin-rsi-oversold-daily-u-btcrsi","type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"properties":{"data":{"properties":{"tblSum":{"properties":{"rows":{"items":{"$ref":"#/components/schemas/PerformanceMetrics"},"type":"array"}},"type":"object"}},"type":"object"},"meta":{"$ref":"#/components/schemas/MetadataBlock"},"strategy":{"properties":{"rules":{"type":"object"},"symbol":{"example":"btcusd:coinbase:1D","type":"string"},"title":{"example":"Bitcoin RSI Oversold Daily","type":"string"}},"type":"object"}},"type":"object"}}},"description":"Saved strategy backtest details and metrics"},"404":{"$ref":"#/components/responses/NotFoundError"},"429":{"$ref":"#/components/responses/RateLimitExceeded"}},"security":[],"summary":"Get Public Strategy by Slug","tags":["Strategy Backtesting & DSL"],"x-token-cost":0}},"/data/scan":{"get":{"description":"Scans predefined ticker lists (`sp10`, `crypto`, `dji`, `all`) for significant seasonal patterns.\n\nReturns a ranked summary table where each row represents an asset with key metrics: `perfm`, `pfac`, `sr`, `win`, `r2`, and `dd_max`.","operationId":"scanSeasonalAnomalies","parameters":[{"description":"Predefined ticker basket identifier (e.g. `sp10`, `crypto`, `dji`)","in":"query","name":"tlist","schema":{"default":"sp10","type":"string"}},{"description":"Grouping type","in":"query","name":"datet","schema":{"default":"weekday","enum":["weekday","day","month","bday","year"],"type":"string"}},{"description":"Live download during scan (Requires `pro` token)","in":"query","name":"dl","schema":{"default":false,"type":"boolean"}},{"description":"Sorting metric column (`roi`, `cagr`, `perfm`, `win`, `pfac`, `sr`)","in":"query","name":"col","schema":{"default":"roi","type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"properties":{"tbl":{"properties":{"columns":{"items":{"$ref":"#/components/schemas/TableColumn"},"type":"array"},"rows":{"items":{"$ref":"#/components/schemas/PerformanceMetrics"},"type":"array"}},"type":"object"}},"type":"object"}}},"description":"Scan summary table containing performance metrics per symbol"},"403":{"$ref":"#/components/responses/PermissionDenied"},"429":{"$ref":"#/components/responses/RateLimitExceeded"}},"summary":"Scan Tickers for Seasonal Anomalies","tags":["Seasonality & Analysis"],"x-token-cost":1}},"/data/seasonality":{"get":{"description":"Calculates historical win rates, cumulative returns, and seasonal charts for a symbol.\n\n**Performance & Risk Metrics returned in `tblSum.rows`**:\n- `perfm`: Monthly Performance (%) \u2014 average expanding mean return per monthly cycle.\n- `pfac`: Profit Factor \u2014 ratio of gross profits to gross losses (`sum gains / sum losses`). Values >1.5 indicate a strong statistical edge.\n- `sr`: Sharpe Ratio \u2014 annualized risk-adjusted return ratio (`excess return / volatility`).\n- `sor`: Sortino Ratio \u2014 downside risk-adjusted return ratio.\n- `r2`: Linearity Score (0.0 to 1.0) \u2014 consistency and smoothness of cumulative equity progression.\n- `cagr`: Compound Annual Growth Rate (%) \u2014 annualized geometric growth rate.\n- `roi`: Return on Investment (%) \u2014 total cumulative percentage return.\n- `win`: Win rate percentage (%) of positive periods or trades.\n- `dd_max`: Maximum Drawdown (%) \u2014 largest peak-to-trough decline over the period.\n\n**Permissions & Downloads**:\n- `dl=0` (read cached/saved bars): Allowed on `free` tier.\n- `dl=1` (live market download): Requires `pro` or `adm` token.","operationId":"getSeasonalityData","parameters":[{"description":"Symbol string format `ticker:exchange:interval` (e.g. `btcusd:coinbase:1D` or `spy:amex:1D`)","in":"query","name":"s","schema":{"default":"btcusd:coinbase:1D","type":"string"}},{"description":"Alias for `s` (when both provided, `s` takes precedence)","in":"query","name":"symbol","schema":{"type":"string"}},{"description":"Seasonality grouping type","in":"query","name":"datet","schema":{"default":"weekday","enum":["weekday","day","month","bday","year"],"type":"string"}},{"description":"Alias for `datet` (when both provided, `datet` takes precedence)","in":"query","name":"date_type","schema":{"type":"string"}},{"description":"Download fresh bars from provider (`1`, `true` requires `pro` token)","in":"query","name":"dl","schema":{"default":false,"type":"boolean"}},{"description":"Alias for `dl`","in":"query","name":"download","schema":{"default":false,"type":"boolean"}},{"description":"Return column for curve calculation (`roi`, `cagr`, `perf%`)","in":"query","name":"col","schema":{"default":"roi","type":"string"}},{"description":"Comma-separated filter for specific periods (e.g. `Monday,Wednesday` or `November,December`)","in":"query","name":"sel","schema":{"type":"string"}},{"description":"Start date boundary (YYYY-MM-DD)","in":"query","name":"start","schema":{"example":"2018-01-01","type":"string"}},{"description":"End date boundary (YYYY-MM-DD)","in":"query","name":"end","schema":{"example":"2026-10-15","type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"properties":{"data":{"properties":{"tblSum":{"description":"Summary statistics table per period bucket (weekday, month, etc.)","properties":{"columns":{"items":{"$ref":"#/components/schemas/TableColumn"},"type":"array"},"rows":{"items":{"$ref":"#/components/schemas/PerformanceMetrics"},"type":"array"}},"type":"object"},"tvSeas":{"description":"TradingView-compatible charting series for seasonal equity curves","items":{"$ref":"#/components/schemas/TradingViewSeries"},"type":"array"}},"type":"object"},"meta":{"$ref":"#/components/schemas/MetadataBlock"}},"type":"object"}}},"description":"Seasonality analysis data including curves, summary tables, and metadata"},"401":{"$ref":"#/components/responses/PermissionDenied"},"403":{"$ref":"#/components/responses/PermissionDenied"},"429":{"$ref":"#/components/responses/RateLimitExceeded"}},"summary":"Get Seasonality Data","tags":["Seasonality & Analysis"],"x-token-cost":1},"post":{"description":"Same quantitative calculation as GET `/data/seasonality`, accepting parameters in a structured JSON body.","operationId":"postSeasonalityData","requestBody":{"content":{"application/json":{"schema":{"properties":{"col":{"example":"roi","type":"string"},"datet":{"enum":["weekday","day","month","bday","year"],"example":"month","type":"string"},"dl":{"description":"Download fresh bars (Requires pro)","example":false,"type":"boolean"},"end":{"example":"2026-10-15","type":"string"},"s":{"description":"Symbol string","example":"btcusd:coinbase:1D","type":"string"},"sel":{"example":"November,December","type":"string"},"start":{"example":"2018-01-01","type":"string"}},"type":"object"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"properties":{"data":{"type":"object"},"meta":{"$ref":"#/components/schemas/MetadataBlock"}},"type":"object"}}},"description":"Seasonality analysis data"},"403":{"$ref":"#/components/responses/PermissionDenied"},"429":{"$ref":"#/components/responses/RateLimitExceeded"}},"summary":"Get Seasonality Data (JSON Body)","tags":["Seasonality & Analysis"],"x-token-cost":1}},"/data/slug":{"get":{"description":"Returns saved seasonal slugs for the current user.","operationId":"listSeasonalSlugs","responses":{"200":{"content":{"application/json":{"schema":{"items":{"properties":{"id":{"type":"integer"},"slug":{"type":"string"},"symbol":{"type":"string"},"title":{"type":"string"}},"type":"object"},"type":"array"}}},"description":"List of saved seasonal slugs"},"4XX":{"$ref":"#/components/responses/BadRequest"}},"summary":"List Saved Seasonal Slugs","tags":["Saved Research & Slugs"],"x-token-cost":0},"post":{"description":"Publishes a new permanent seasonal slug. Requires `pro` or `adm` permission.","operationId":"createSeasonalSlug","requestBody":{"content":{"application/json":{"schema":{"properties":{"datet":{"example":"month","type":"string"},"s":{"example":"btcusd:coinbase:1D","type":"string"},"title":{"example":"Bitcoin November Strength","type":"string"}},"required":["title","s"],"type":"object"}}},"required":true},"responses":{"201":{"description":"Slug published successfully"},"403":{"$ref":"#/components/responses/PermissionDenied"}},"summary":"Save Seasonal Slug Configuration","tags":["Saved Research & Slugs"],"x-token-cost":0}},"/data/storeurl":{"get":{"description":"Returns saved backtest configurations belonging to the caller.","operationId":"listSavedStrategies","responses":{"200":{"content":{"application/json":{"schema":{"items":{"properties":{"create_dt":{"type":"string"},"id":{"type":"integer"},"name":{"type":"string"},"symbol":{"type":"string"}},"type":"object"},"type":"array"}}},"description":"Array of saved strategies"},"4XX":{"$ref":"#/components/responses/BadRequest"}},"summary":"List User Saved Strategies","tags":["Strategy Backtesting & DSL"],"x-token-cost":0},"post":{"description":"Saves a strategy backtest configuration. Requires `pro` or `adm` tier.","operationId":"saveStrategyConfig","requestBody":{"content":{"application/json":{"schema":{"properties":{"c":{"example":[["rsi",">",70]],"type":"array"},"name":{"example":"My Strategy","type":"string"},"o":{"example":[["rsi","<",30]],"type":"array"},"s":{"example":"btcusd:coinbase:1D","type":"string"}},"required":["name","s","o"],"type":"object"}}},"required":true},"responses":{"201":{"description":"Strategy saved successfully"},"403":{"$ref":"#/components/responses/PermissionDenied"}},"summary":"Save Strategy Backtest Configuration","tags":["Strategy Backtesting & DSL"],"x-token-cost":0}},"/data/str":{"get":{"description":"Runs an event-driven historical simulation of a quantitative trading strategy defined with rules and parameters.\n\n**Supported DSL Parameters**:\n- `s`: Asset identifier `ticker:exchange:interval` (e.g. `btcusd:coinbase:1D`, `aapl:nasdaq:1h`, `spy:amex:1D`).\n- `o`: Entry open rules array (e.g. `[[\"rsi\", \"<\", 30], \"and\", [\"close\", \">\", [\"sma\", 200]]]`). Supports both array syntax (`[\"rsi\", \"<\", 30]`) and object syntax (`{\"<\": [{\"rsi\": 14}, 30]}`). Explore 160+ indicators via `/api/data/ta/docs`.\n- `c`: Exit close rules array (e.g. `[[\"rsi\", \">\", 70]]` or `[[[\"sma\", 50], \"crosses_below\", [\"sma\", 200]]]`).\n- `slt`: Dynamic stop-loss trigger conditions.\n- `ttp`: Trailing take-profit rules or multiplier.\n- `sl`: Fixed stop loss % (e.g. `5` for 5% maximum adverse excursion).\n- `tp`: Fixed take profit % (e.g. `15` for 15% profit target).\n- `rr`: Risk-to-Reward ratio (e.g. `2.0` to target twice the stop-loss risk distance).\n- `n`: Max holding bars before forced time-based exit.\n- `t`: Direction (`1` for Long, `-1` for Short; default `1`).\n- `h`: Max concurrent positions / hedging allowance (default `1`).\n- `bal`: Initial cash balance for compounding equity calculation (default `10000`).\n- `bm`: Benchmark symbol for buy & hold comparison (e.g. `spy:amex:1D`).\n- `name`: Custom strategy label.\n- `dl`: Force on-demand bar fetch (`1` or count like `500`).","operationId":"executeStrategyBacktest","parameters":[{"description":"Asset symbol (e.g. `btcusd:coinbase:1D`)","in":"query","name":"s","schema":{"default":"btcusd:coinbase:1D","type":"string"}},{"description":"Exchange identifier (e.g. `coinbase`, `nasdaq`, `binance`)","in":"query","name":"e","schema":{"type":"string"}},{"description":"Timeframe / bar interval (e.g. `1D`, `4h`, `1h`, `15m`)","in":"query","name":"i","schema":{"type":"string"}},{"description":"Tickerlist / universe name (e.g. `top-crypto20`) for multi-asset scan","in":"query","name":"l","schema":{"type":"string"}},{"description":"Data provider engine (`tv`, `alp`, `hl`, `bin`)","in":"query","name":"api","schema":{"default":"tv","enum":["tv","alp","hl","bin","cc"],"type":"string"}},{"description":"Broker account selector or sub-account routing","in":"query","name":"acc","schema":{"type":"string"}},{"description":"Entry open conditions serialized as JSON string (e.g. `[[\"rsi\", \"<\", 30]]`)","in":"query","name":"o","schema":{"type":"string"}},{"description":"Exit close conditions serialized as JSON string (e.g. `[[\"rsi\", \">\", 70]]`)","in":"query","name":"c","schema":{"type":"string"}},{"description":"Dynamic stop-loss trigger rules serialized as JSON string","in":"query","name":"slt","schema":{"type":"string"}},{"description":"Trailing take profit rules (JSON) or risk-reward multiple (float)","in":"query","name":"ttp","schema":{"type":"string"}},{"description":"Stop loss percentage (e.g. 5 for 5%)","in":"query","name":"sl","schema":{"type":"number"}},{"description":"Take profit percentage (e.g. 15 for 15%)","in":"query","name":"tp","schema":{"type":"number"}},{"description":"Risk-to-reward ratio multiplier (e.g. 2.0)","in":"query","name":"rr","schema":{"type":"number"}},{"description":"Max holding period in bars (time-based stop)","in":"query","name":"n","schema":{"type":"integer"}},{"description":"Trade direction (1 = Long, -1 = Short)","in":"query","name":"t","schema":{"default":1,"enum":[1,-1],"type":"integer"}},{"description":"Hedging / max concurrent parallel positions (default: 1)","in":"query","name":"h","schema":{"default":1,"type":"integer"}},{"description":"Initial capital balance (default: 10000)","in":"query","name":"bal","schema":{"default":10000,"type":"number"}},{"description":"Bid-ask spread slippage cost percentage per trade (e.g. 0.05 for 5 bps)","in":"query","name":"spread","schema":{"default":0.0,"type":"number"}},{"description":"Benchmark symbol for buy-and-hold comparison (e.g. `spy:amex:1D`)","in":"query","name":"bm","schema":{"type":"string"}},{"description":"Custom strategy label","in":"query","name":"name","schema":{"type":"string"}},{"description":"Download fresh bars (Requires `pro` token)","in":"query","name":"dl","schema":{"default":false,"type":"boolean"}},{"description":"Total historical bar count to evaluate","in":"query","name":"nbars","schema":{"type":"integer"}},{"description":"Exclude / trim the newest N bars of history (evaluates older data up to N bars before present)","in":"query","name":"tail","schema":{"type":"integer"}},{"description":"Data feed connection retry attempts","in":"query","name":"try","schema":{"type":"integer"}},{"description":"Bypass server-side cache","in":"query","name":"nocache","schema":{"default":false,"type":"boolean"}}],"responses":{"200":{"content":{"application/json":{"schema":{"properties":{"meta":{"$ref":"#/components/schemas/MetadataBlock"},"tbl":{"properties":{"columns":{"items":{"type":"string"},"type":"array"},"rows":{"items":{"$ref":"#/components/schemas/PerformanceMetrics"},"type":"array"}},"type":"object"}},"type":"object"}}},"description":"Backtest equity curves, summary metrics, and trade logs"},"400":{"$ref":"#/components/responses/BadRequest"},"403":{"$ref":"#/components/responses/PermissionDenied"},"429":{"$ref":"#/components/responses/RateLimitExceeded"}},"summary":"Execute Quantitative Strategy Backtest","tags":["Strategy Backtesting & DSL"],"x-token-cost":1},"post":{"description":"Executes a strategy backtest using a structured JSON body containing indicators, entry/exit rules, and position parameters.\n\nSupports both **Array Syntax** (e.g. `[[\"rsi\", \"<\", 30], \"and\", [\"close\", \">\", [\"sma\", 200]]]`) and **Object Syntax** (e.g. `[{\"<\": [{\"rsi\": 14}, {\"value\": 30}]}]`). See Section 4 in the documentation header for complete DSL grammar and operator details.","operationId":"executeStrategyBacktestPost","requestBody":{"content":{"application/json":{"examples":{"bollinger_mean_reversion":{"summary":"Bollinger Bands Mean Reversion with Time Stop","value":{"bal":10000.0,"c":[["close",">",["sma",20]]],"n":15,"o":[["close","<",["bbands_low",20]]],"s":"ethusd:coinbase:1D","sl":4.0,"tp":10.0}},"golden_cross":{"summary":"Moving Average Crossover (Golden Cross)","value":{"bal":10000.0,"bm":"btcusd:coinbase:1D","c":[[["sma",50],"crosses_below",["sma",200]]],"o":[[["sma",50],"crosses_above",["sma",200]]],"s":"btcusd:coinbase:1D"}},"rsi_oversold_pullback":{"summary":"RSI Oversold Pullback + 200 SMA Trend Filter (Long)","value":{"bal":10000.0,"bm":"btcusd:coinbase:1D","c":[["rsi",">",70]],"o":[["rsi","<",30],"and",["close",">",["sma",200]]],"s":"btcusd:coinbase:1D","sl":5.0,"t":1,"tp":15.0}}},"schema":{"properties":{"acc":{"description":"Broker account selector or sub-account routing identifier","type":"string"},"api":{"default":"tv","description":"Market data provider feed engine (tv, alp, hl, bin, cc)","enum":["tv","alp","hl","bin","cc"],"type":"string"},"bal":{"description":"Starting capital for compounding simulation","example":10000.0,"type":"number"},"bm":{"description":"Benchmark symbol for buy & hold comparison","example":"btcusd:coinbase:1D","type":"string"},"c":{"description":"Exit / Close conditions tree","example":[["rsi",">",70]],"type":"array"},"dl":{"description":"On-demand bar fetch count (e.g. 1 or 500)","type":"integer"},"e":{"description":"Exchange identifier (e.g. coinbase, nasdaq, binance, hyperliquid)","example":"coinbase","type":"string"},"h":{"description":"Hedging / max concurrent positions","example":1,"type":"integer"},"i":{"description":"Bar interval / timeframe (e.g. 1D, 4h, 1h, 15m)","example":"1D","type":"string"},"l":{"description":"Tickerlist or market basket name for multi-asset scans (e.g. top-crypto20)","example":"top-crypto20","type":"string"},"n":{"description":"Holding period limit in bars","example":20,"type":"integer"},"name":{"description":"Custom strategy label","example":"BTC - RSI Pullback in Bull Trend","type":"string"},"nbars":{"description":"Total historical bar count to evaluate","type":"integer"},"nocache":{"description":"Bypass server-side cache","type":"boolean"},"o":{"description":"Entry / Open conditions tree","example":[["rsi","<",30],"and",["close",">",["sma",200]]],"type":"array"},"rr":{"description":"Risk-to-reward ratio multiplier (e.g. 2.0)","example":2.0,"type":"number"},"s":{"description":"Asset identifier formatted as ticker:exchange:interval","example":"btcusd:coinbase:1D","type":"string"},"sl":{"description":"Fixed stop loss percentage (e.g. 5 for 5%)","example":5.0,"type":"number"},"slt":{"description":"Dynamic stop-loss trigger conditions","type":"array"},"spread":{"description":"Bid-ask spread slippage cost percentage per trade (e.g. 0.05 for 5 bps)","example":0.0,"type":"number"},"str":{"description":"Composite portfolio strategies array evaluated into a blended equity curve","type":"array"},"t":{"description":"Trade direction (1 = Long, -1 = Short) or exposure multiplier","enum":[1,-1],"example":1,"type":"integer"},"tail":{"description":"Exclude / trim the newest N bars of history (evaluates older data up to N bars before present)","type":"integer"},"tp":{"description":"Fixed take profit percentage (e.g. 15 for 15%)","example":15.0,"type":"number"},"try":{"description":"External data feed connection retry attempts","type":"integer"},"ttp":{"description":"Trailing take profit rules (JSON) or risk-reward multiple (float)"}},"required":["s","o"],"type":"object"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"properties":{"meta":{"$ref":"#/components/schemas/MetadataBlock"},"tbl":{"properties":{"columns":{"items":{"type":"string"},"type":"array"},"rows":{"items":{"$ref":"#/components/schemas/PerformanceMetrics"},"type":"array"}},"type":"object"}},"type":"object"}}},"description":"Backtest simulation results with metrics table and metadata"},"400":{"$ref":"#/components/responses/BadRequest"},"403":{"$ref":"#/components/responses/PermissionDenied"},"429":{"$ref":"#/components/responses/RateLimitExceeded"}},"summary":"Execute Quantitative Strategy Backtest (JSON Body)","tags":["Strategy Backtesting & DSL"],"x-token-cost":1}},"/data/strategy-builder-presets":{"get":{"description":"Returns curated strategy templates (Mean Reversion, Trend Following, Momentum, Breakout).","operationId":"listStrategyPresets","responses":{"200":{"content":{"application/json":{"schema":{"items":{"properties":{"description":{"example":"Enters when RSI < 30, exits when RSI > 70","type":"string"},"id":{"example":"rsi_reversal","type":"string"},"name":{"example":"RSI Mean Reversion","type":"string"}},"type":"object"},"type":"array"}}},"description":"List of strategy builder presets"},"4XX":{"$ref":"#/components/responses/BadRequest"}},"security":[],"summary":"List Strategy Builder Presets","tags":["Strategy Backtesting & DSL"],"x-token-cost":0}},"/data/ta/docs":{"get":{"description":"Machine- and AI-readable documentation endpoint returning metadata, required DataFrame columns, parameter types and default values, return schemas, and strategy DSL examples for 160+ indicators.\n\nUnmetered (0 tokens). Pass `?name=RSI` for a single indicator, `?category=Momentum` to filter, or `?format=markdown` for direct LLM system prompt injection.","operationId":"getTaDocumentation","parameters":[{"description":"Specific indicator name (e.g. 'RSI', 'BBANDS', 'MACD', 'SMA')","in":"query","name":"name","schema":{"example":"RSI","type":"string"}},{"description":"Filter by indicator category","in":"query","name":"category","schema":{"enum":["Moving Averages","Momentum & Oscillators","Volatility & Bands","Trend & Direction","Volume & Money Flow","Price & Candle Transform","Extremas & Patterns","Cycles & Session Timing"],"type":"string"}},{"description":"Keyword search across indicator names, summaries, and descriptions","in":"query","name":"search","schema":{"example":"bollinger","type":"string"}},{"description":"Output format: 'json' (default structured JSON) or 'markdown' (LLM prompt-friendly)","in":"query","name":"format","schema":{"default":"json","enum":["json","markdown"],"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"properties":{"data":{"properties":{"categories":{"items":{"type":"string"},"type":"array"},"indicators":{"items":{"type":"object"},"type":"array"},"total":{"example":166,"type":"integer"}},"type":"object"},"success":{"example":true,"type":"boolean"}},"type":"object"}},"text/markdown":{"schema":{"type":"string"}}},"description":"Indicator schemas and documentation"},"4XX":{"$ref":"#/components/responses/BadRequest"}},"security":[],"summary":"Technical Analysis Indicator Documentation & Machine-Readable Schemas","tags":["Technical Analysis (TA)"],"x-token-cost":0}},"/data/ticker/exchange/options":{"get":{"description":"Returns exchanges supporting the given ticker (including live feeds and preloaded 'local' historical archives).","operationId":"listTickerExchanges","parameters":[{"description":"Ticker symbol (e.g. `btcusd`)","in":"query","name":"ticker","required":true,"schema":{"example":"btcusd","type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"items":{"properties":{"label":{"example":"Coinbase","type":"string"},"value":{"example":"coinbase","type":"string"}},"type":"object"},"type":"array"}}},"description":"Array of available exchange options"},"4XX":{"$ref":"#/components/responses/BadRequest"}},"security":[],"summary":"List Exchanges for a Specific Ticker","tags":["Assets & Universe"],"x-token-cost":0}},"/data/ticker/options":{"get":{"description":"Quick autocomplete for search boxes returning distinct tickers and names.","operationId":"searchTickerOptions","parameters":[{"description":"Query string","in":"query","name":"search","schema":{"example":"eth","type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"items":{"properties":{"label":{"example":"Ethereum (USD)","type":"string"},"value":{"example":"ethusd","type":"string"}},"type":"object"},"type":"array"}}},"description":"Array of ticker option objects"},"4XX":{"$ref":"#/components/responses/BadRequest"}},"security":[],"summary":"Search Ticker Options Autocomplete","tags":["Assets & Universe"],"x-token-cost":0}},"/data/tickerlist/options":{"get":{"description":"Returns predefined market lists (`sp10`, `crypto`, `dji`, `all`) usable in `/data/scan`.","operationId":"listTickerLists","responses":{"200":{"content":{"application/json":{"schema":{"items":{"properties":{"label":{"example":"S&P 10 Leaders","type":"string"},"value":{"example":"sp10","type":"string"}},"type":"object"},"type":"array"}}},"description":"List of available ticker lists"},"4XX":{"$ref":"#/components/responses/BadRequest"}},"security":[],"summary":"List Predefined Ticker Baskets","tags":["Assets & Universe"],"x-token-cost":0}},"/data/user/usage":{"get":{"description":"Unmetered endpoint returning caller's authoritative daily token balance, spent tokens, remaining allowance, and countdown to 00:00 Europe/Berlin reset.\n\nWorks for both authenticated accounts (sharing balance across sessions/keys) and anonymous visitors.","operationId":"getCurrentUserUsage","responses":{"200":{"content":{"application/json":{"schema":{"properties":{"authenticated":{"example":true,"type":"boolean"},"daily_allowance":{"example":50,"type":"integer"},"next_reset_iso":{"example":"2026-10-18T00:00:00+02:00","type":"string"},"next_reset_seconds":{"example":8900,"type":"integer"},"next_reset_timestamp":{"example":1776470400,"type":"integer"},"tier":{"example":"plus","type":"string"},"timezone":{"example":"Europe/Berlin","type":"string"},"tokens_remaining":{"example":38,"type":"integer"},"tokens_used":{"example":12,"type":"integer"}},"type":"object"}}},"description":"Daily usage balance and reset timing"},"4XX":{"$ref":"#/components/responses/BadRequest"}},"security":[],"summary":"Get Caller Daily Usage-Token Balance","tags":["Usage & Rate Limits"],"x-token-cost":0}},"/seasonal/{slug}":{"get":{"description":"Retrieves the seasonality analysis for a public saved slug URL (e.g. `/seasonal/SPY-November-Seasonality...`).\n\nPublicly readable without credentials.","operationId":"getSeasonalBySlug","parameters":[{"description":"Slug identifier","in":"path","name":"slug","required":true,"schema":{"example":"SPY-November-Seasonality-Year-End-Strength-19932026-AMEX-Backtest-u-yzrh1t","type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"properties":{"data":{"properties":{"tblSum":{"properties":{"rows":{"items":{"$ref":"#/components/schemas/PerformanceMetrics"},"type":"array"}},"type":"object"},"tvSeas":{"items":{"$ref":"#/components/schemas/TradingViewSeries"},"type":"array"}},"type":"object"}},"type":"object"}}},"description":"Slug seasonality data including chart series and metric summary rows"},"404":{"$ref":"#/components/responses/NotFoundError"},"429":{"$ref":"#/components/responses/RateLimitExceeded"}},"security":[],"summary":"Get Public Seasonal Slug Data","tags":["Saved Research & Slugs"],"x-token-cost":1}},"/user/tokens":{"get":{"description":"Returns all API tokens generated by the currently authenticated user.","operationId":"listUserApiTokens","responses":{"200":{"content":{"application/json":{"schema":{"properties":{"tokens":{"items":{"$ref":"#/components/schemas/ApiToken"},"type":"array"},"user_tier":{"type":"string"}},"type":"object"}}},"description":"List of user tokens"},"4XX":{"$ref":"#/components/responses/BadRequest"}},"summary":"List User API Tokens","tags":["Authentication & API Tokens"],"x-token-cost":0},"post":{"description":"Generates a personal API token (`mtd_live_...`). Save this token immediately as the raw secret is only displayed once.\n\nToken tier cannot exceed caller's account permission.","operationId":"createUserApiToken","requestBody":{"content":{"application/json":{"schema":{"properties":{"expires_days":{"example":90,"type":"integer"},"name":{"example":"AI Agent Assistant","type":"string"},"tier":{"enum":["free","pro","adm"],"example":"pro","type":"string"}},"required":["name"],"type":"object"}}},"required":true},"responses":{"201":{"content":{"application/json":{"schema":{"properties":{"details":{"$ref":"#/components/schemas/ApiToken"},"message":{"type":"string"},"token":{"example":"mtd_live_abc123...","type":"string"}},"type":"object"}}},"description":"Token created successfully"},"403":{"$ref":"#/components/responses/PermissionDenied"}},"summary":"Generate New API Token","tags":["Authentication & API Tokens"],"x-token-cost":0}},"/user/tokens/{id}":{"delete":{"description":"Deactivates and revokes an API token. Callers can only revoke their own tokens.","operationId":"revokeUserApiToken","parameters":[{"in":"path","name":"id","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Token deleted successfully"},"404":{"$ref":"#/components/responses/NotFoundError"}},"summary":"Revoke API Token","tags":["Authentication & API Tokens"],"x-token-cost":0}}},"security":[{"BearerAuth":[]},{"ApiKeyAuth":[]}],"servers":[{"description":"Production","url":"https://metaduro.com/api"}]}
