--- name: twelvedata version: 2.0.2 description: "Stocks, forex, and commodities price data โ€” real-time quotes, historical time series, and reference data" delivery: script metadata: starchild: emoji: "๐Ÿ“Š" skillKey: twelvedata requires: env: - TWELVEDATA_API_KEY user-invocable: false disable-model-invocation: false --- # Twelve Data Stocks, forex, and commodities price data. **Traditional markets only โ€” not for crypto.** ## Script Usage This skill ships a single `exports.py` with all functions. Call it from a `bash` block: ```bash python3 - <<'EOF' import sys, json sys.path.insert(0, "/data/workspace/skills/twelvedata") from exports import twelvedata_price, twelvedata_quote, twelvedata_time_series # Single quote print(twelvedata_quote(symbol="AAPL")) # Time series (last 30 daily candles) series = twelvedata_time_series(symbol="AAPL", interval="1day", outputsize=30) print(json.dumps(series.get("values", [])[:3], indent=2)) EOF ``` Available functions in `exports.py`: `twelvedata_price`, `twelvedata_quote`, `twelvedata_time_series`, `twelvedata_eod`, `twelvedata_quote_batch`, `twelvedata_price_batch`, `twelvedata_search`, `twelvedata_stocks`, `twelvedata_forex_pairs`, `twelvedata_exchanges`. Read `exports.py` directly when you need exact signatures. ## Function Reference (signatures) All functions are in `exports.py`. Symbols use TwelveData format (e.g. `AAPL`, `EUR/USD`, `XAU/USD`). Use `prepost=True` for pre/post-market data on US stocks. | Function | Description | |---|---| | `twelvedata_price(symbol, prepost=False)` | Current price for one symbol. | | `twelvedata_price_batch(symbols, prepost=False)` | Prices for multiple symbols (`symbols` = comma-separated string). | | `twelvedata_quote(symbol, prepost=False)` | Detailed quote: price, volume, 52w high/low, change %. | | `twelvedata_quote_batch(symbols, prepost=False)` | Detailed quotes for multiple symbols. | | `twelvedata_time_series(symbol, interval='1day', outputsize=30, start_date=None, end_date=None, prepost=False)` | OHLCV bars. `interval` = `1min`/`5min`/`15min`/`30min`/`1h`/`2h`/`4h`/`1day`/`1week`/`1month`. | | `twelvedata_eod(symbol, date=None, prepost=False)` | End-of-day price for a date (default: latest). | | `twelvedata_search(query)` | Search symbols by name or ticker. | | `twelvedata_stocks(exchange=None, country=None)` | List supported stocks (filterable). | | `twelvedata_forex_pairs()` | List all supported forex pairs. | | `twelvedata_exchanges()` | List supported exchanges. | ## Keyword โ†’ Tool Lookup | User asks about | Tool | NOT this | |----------------|------|----------| | "AAPL ่‚กไปท", "current price" (single) | `twelvedata_quote` | Not `twelvedata_price` (less detail) | | "just the price number" | `twelvedata_price` | โ€” | | "ๅคšๅช่‚ก็ฅจๅฏนๆฏ”" (2+ symbols) | `twelvedata_quote_batch` | Not multiple `twelvedata_quote` calls | | "K็บฟ", "ๅކๅฒๆ•ฐๆฎ", "time series" | `twelvedata_time_series` | โ€” | | "ๆ”ถ็›˜ไปท" | `twelvedata_eod` | โ€” | | "ๆ‰พ่‚ก็ฅจไปฃ็ " | `twelvedata_search` | โ€” | | "NASDAQ ๆœ‰ๅ“ชไบ›่‚ก็ฅจ" | `twelvedata_stocks` | โ€” | | "ๆฑ‡็އ", "EUR/USD" | `twelvedata_quote(symbol="EUR/USD")` | โ€” | | "ๅค–ๆฑ‡ๅฏนๅˆ—่กจ" | `twelvedata_forex_pairs` | โ€” | | "้‡‘ไปท", "oil price" | `twelvedata_quote(symbol="XAU/USD")` | Not CoinGecko | | "BTC price", any crypto | **CoinGecko** `coin_price` | โŒ Never twelvedata for crypto | ## TwelveData vs CoinGecko โ€” Boundary | Asset class | Use | Why | |-------------|-----|-----| | Stocks (AAPL, TSLA) | **TwelveData** | CoinGecko has no stocks | | Forex (EUR/USD) | **TwelveData** | CoinGecko has no forex | | Commodities (gold, oil) | **TwelveData** | CoinGecko has no commodities | | Crypto (BTC, ETH, SOL) | **CoinGecko** | TwelveData crypto data is limited/unreliable | ## MISTAKES โ€” Read Before Calling ### โŒ MISTAKE 1: Using TwelveData for crypto ``` User: "BTC ไปทๆ ผ" โŒ WRONG: twelvedata_quote(symbol="BTC/USD") โœ… RIGHT: coin_price(ids="bitcoin") โ† CoinGecko ``` ### โŒ MISTAKE 2: Calling quote individually for multiple stocks ``` User: "AAPL MSFT GOOGL ็Žฐๅœจไป€ไนˆไปท" โŒ WRONG: twelvedata_quote("AAPL"), twelvedata_quote("MSFT"), twelvedata_quote("GOOGL") โ† 3 calls โœ… RIGHT: twelvedata_quote_batch(symbols=["AAPL", "MSFT", "GOOGL"]) โ† 1 call, up to 120 symbols ``` ### โŒ MISTAKE 3: Forex without slash ``` โŒ WRONG: twelvedata_quote(symbol="EURUSD") โœ… RIGHT: twelvedata_quote(symbol="EUR/USD") โ† always slash format ``` Also: `USD/CNH` not `USDCNH`, `GBP/JPY` not `GBPJPY`. ### โŒ MISTAKE 4: Expecting bid/ask from quote ``` โŒ WRONG: "EUR/USD bid: 1.0850, ask: 1.0852" โ† quote only returns close โœ… RIGHT: "EUR/USD current price: 1.0851 (close/last price โ€” bid/ask spread not available)" ``` ### โŒ MISTAKE 5: Wrong interval format ``` โŒ WRONG: twelvedata_time_series(interval="1D") โ† uppercase โœ… RIGHT: twelvedata_time_series(interval="1day") ``` Valid: `1min`, `5min`, `15min`, `30min`, `1h`, `2h`, `4h`, `8h`, `1day`, `1week`, `1month` ### โŒ MISTAKE 6: Using full output when compact suffices ``` User: "AAPL ๆœ€่ฟ‘่ตฐๅŠฟ" โŒ WRONG: twelvedata_time_series(symbol="AAPL", interval="1day", outputsize="full") โ† 5000 candles โœ… RIGHT: twelvedata_time_series(symbol="AAPL", interval="1day", outputsize="compact") โ† 30 candles ``` Use `full` only when user explicitly needs deep history. ## Symbol Reference ### Commodities (verified) | Asset | Symbol | |-------|--------| | Gold | `XAU/USD` | | Silver | `XAG/USD` | | Platinum | `XPT/USD` | | Palladium | `XPD/USD` | | Crude Oil (WTI) | `WTI/USD` | | Natural Gas | `NG/USD` | ### Popular Forex Pairs | Pair | Symbol | |------|--------| | Euro / USD | `EUR/USD` | | GBP / USD | `GBP/USD` | | USD / JPY | `USD/JPY` | | USD / CNH | `USD/CNH` | Use `twelvedata_search` to discover others. ## Pre/Post-Market Data ``` twelvedata_quote(symbol="AAPL", prepost=true) twelvedata_time_series(symbol="AAPL", interval="1min", prepost=true) ``` Returns `premarket_change`, `premarket_change_percent`, `postmarket_change`, `postmarket_change_percent` when available. ## Output Sizes - `compact` โ€” Last 30 data points (default, faster). Use for "ๆœ€่ฟ‘่ตฐๅŠฟ". - `full` โ€” Up to 5000 data points. Use for deep analysis / charting. ## Proxy-Safe Usage 1. **Agent tool calls**: Always prefer `twelvedata_*` tools (this skill). 2. **Platform code** (`skills/`, `tools/`): use `core.http_client`. 3. **Workspace scripts** (`bash`): Do NOT call TwelveData directly. Use skill tools. ## Compound Queries ### Stock Comparison ``` 1. twelvedata_quote_batch(symbols=["AAPL", "MSFT", "GOOGL", "TSLA"]) 2. twelvedata_time_series(symbol="AAPL", interval="1day", outputsize="compact") โ† only for the one user cares most about ``` ### Macro Dashboard (stocks + forex + commodities) ``` 1. twelvedata_quote_batch(symbols=["SPY", "QQQ"]) โ†’ US indices 2. twelvedata_quote_batch(symbols=["EUR/USD", "USD/JPY"]) โ†’ Forex 3. twelvedata_quote(symbol="XAU/USD") โ†’ Gold ```