Twelve Data Market Data Basics - Time Series, Quotes, and Prices
The foundation of any trading or investment strategy lies in reliable market data. The Twelve Data Market Data Connector provides three core operations that form the basis of market analysis: time_series for historical data, quote for comprehensive snapshots, and price for simple real-time prices. This guide walks you through each operation with step-by-step interface instructions and practical examples.
Understanding the Core Operations
Time Series - Historical OHLCV Data
The time_series operation provides historical and intraday price data in OHLCV (Open, High, Low, Close, Volume) format. This is essential for technical analysis, backtesting strategies, and understanding price movements over time.
Key Features:
- Support for intraday intervals (1 minute to 4 hours)
- Daily, weekly, and monthly data
- Custom date ranges and output sizes
- Multi-symbol batch requests
- Automatic timezone handling
Quote - Real-time Market Snapshots
The quote operation delivers comprehensive real-time market information for a single symbol, including current prices, trading volumes, and market statistics.
Key Features:
- Real-time price and volume data
- Bid/ask spreads and market depth
- Trading session information
- 52-week high/low data
- Market capitalization and averages
Price - Simple Real-time Prices
The price operation provides the most basic real-time price information - just the current price for quick checks or simple monitoring.
Key Features:
- Minimal response size
- Fastest API response
- Current price only
- Perfect for price monitoring dashboards
Step-by-Step Usage Guide
Getting Historical Time Series Data
Step 1: Select the Worker
- In your workflow interface, add a new worker
- Choose worker type:
twelve_data - Select operation:
time_series
Step 2: Configure Basic Parameters
- api_key: (Optional) Your personal Twelve Data API key
- symbol: Enter the stock ticker, forex pair, or crypto symbol (e.g.,
AAPL,EUR/USD,BTC/USD) - interval: Choose your desired time interval:
- Intraday:
1min,5min,15min,30min,45min,1h,2h,4h - Daily:
1day - Weekly:
1week - Monthly:
1month
- Intraday:
Step 3: Set Data Parameters
- outputsize: Number of data points (1-5000, default 100)
- start_date: Beginning date for historical data (YYYY-MM-DD format)
- end_date: End date for historical data (YYYY-MM-DD format)
- timezone: Target timezone (e.g.,
America/New_York,UTC)
Step 4: Advanced Options
- order: Data order (
ASCfor chronological,DESCfor reverse)
Example Configuration for Daily AAPL Data:
{
"operation": "time_series",
"symbol": "AAPL",
"interval": "1day",
"outputsize": 250,
"start_date": "2024-01-01",
"end_date": "2024-10-31",
"timezone": "America/New_York"
}
Output Structure:
{
"operation": "time_series",
"result": {
"symbol": "AAPL",
"interval": "1day",
"values": [
{
"datetime": "2024-10-31",
"open": 225.59,
"high": 229.83,
"low": 225.17,
"close": 225.91,
"volume": 64370100
}
]
}
}
Getting Real-time Quote Data
Step 1: Select the Worker
- Add worker type:
twelve_data - Select operation:
quote
Step 2: Configure Parameters
- api_key: (Optional) Your personal API key
- symbol: The symbol to quote (e.g.,
MSFT,GBP/USD)
Example Configuration:
operation: quote
symbol: MSFT
Output Structure:
{
"operation": "quote",
"quote": {
"symbol": "MSFT",
"name": "Microsoft Corporation",
"price": 415.26,
"change": 5.26,
"change_percent": 1.28,
"previous_close": 410.00,
"open": 412.50,
"day_high": 418.50,
"day_low": 410.00,
"volume": 24567890,
"average_volume": 23456789,
"market_cap": 3090000000000,
"pe_ratio": 32.45,
"week_52_high": 468.35,
"week_52_low": 362.90,
"ytd_change": 15.67,
"last_trade_time": "2024-10-31 16:00:00"
}
}
Getting Simple Price Data
Step 1: Select the Worker
- Add worker type:
twelve_data - Select operation:
price
Step 2: Configure Parameters
- api_key: (Optional) Your personal API key
- symbol: The symbol to check (e.g.,
GOOGL,ETH/USD)
Example Configuration:
operation: price
symbol: GOOGL
Output Structure:
{
"operation": "price",
"symbol": "GOOGL",
"price": 175.23
}
Practical Applications and Examples
Building a Price Monitoring Dashboard
Workflow Setup:
-
Worker 1: Time Series for historical context
- operation:
time_series - symbol:
SPY - interval:
1day - outputsize:
30
- operation:
-
Worker 2: Real-time Quote for current data
- operation:
quote - symbol:
SPY
- operation:
-
Worker 3: Price checks for related assets
- operation:
price - symbol:
QQQ,VXX
- operation:
Use Case: Monitor S&P 500 ETF with context and related volatility products.
Intraday Trading Analysis
Configuration for Scalping:
{
"operation": "time_series",
"symbol": "EUR/USD",
"interval": "1min",
"outputsize": 100,
"timezone": "UTC"
}
Configuration for Swing Trading:
{
"operation": "time_series",
"symbol": "BTC/USD",
"interval": "4h",
"outputsize": 200,
"timezone": "UTC"
}
Multi-Asset Portfolio Tracking
Batch Symbol Request:
{
"operation": "time_series",
"symbol": "AAPL,MSFT,GOOGL,AMZN",
"interval": "1day",
"outputsize": 5
}
Real-time Portfolio Check:
- Use multiple
priceworkers for instant portfolio valuation - Combine with
quotefor detailed analysis of specific holdings
Best Practices and Tips
Optimizing Time Series Requests
-
Interval Selection: Match your strategy timeframe
- Scalping: 1-5 minute intervals
- Day trading: 15-60 minute intervals
- Swing trading: 4-hour to daily
- Position trading: Daily to weekly
-
Output Size Management: Balance data needs with API limits
- Use smaller outputsize for frequent updates
- Request larger datasets for backtesting
- Consider pagination for very large datasets
-
Date Range Optimization: Specify precise ranges to reduce data transfer
- Use start_date/end_date for specific periods
- Leave blank for most recent data
Real-time Data Considerations
- Quote vs Price: Use
quotefor comprehensive data,pricefor speed - Update Frequency: Respect API rate limits (5 calls/minute on shared keys)
- Caching Strategy: Cache frequently accessed data to reduce API calls
Error Handling
- Invalid Symbols: Verify symbol format before requests
- Rate Limits: Monitor usage and implement retry logic
- Network Issues: Handle timeouts gracefully with fallback data
Common Use Cases
Technical Analysis Platform
Combine time series data with technical indicators:
- Fetch historical data with
time_series - Calculate indicators using the
indicatoroperation - Generate signals based on indicator crossovers
Algorithmic Trading Bot
Build automated strategies:
- Monitor prices with
pricefor fast updates - Get detailed quotes with
quotefor entry signals - Use historical data for strategy validation
Financial Dashboard
Create comprehensive market views:
- Multi-symbol time series for charts
- Real-time quotes for watchlists
- Price feeds for portfolio tracking
Backtesting Engine
Develop and test strategies:
- Request extensive historical data
- Apply technical analysis
- Simulate trades with realistic data
Integration Examples
With Technical Analysis
Sequential Workflow:
- Step 1: Fetch price data
- Worker:
twelve_data(time_series)
- Worker:
- Step 2: Calculate indicators
- Worker:
technical_analysis_worker - Input: Step 1 result
- Worker:
- Step 3: Generate signals
- Worker:
signal_generator - Input: Step 2 indicators
- Worker:
With Portfolio Management
Parallel Processing:
- Price Monitor: Continuous
priceupdates for all holdings - Quote Analyzer: Periodic
quotecalls for detailed analysis - Historical Tracker: Weekly
time_seriesfor performance review
Troubleshooting Common Issues
No Data Returned
- Check Symbol: Verify symbol format and exchange
- Validate Dates: Ensure date range contains trading data
- Confirm API Key: Test with a simple symbol first
Rate Limit Errors
- Use Personal Key: Higher limits with personal API keys
- Implement Delays: Add delays between frequent requests
- Batch Requests: Combine multiple symbols in single calls
Timezone Issues
- Specify Timezone: Always set explicit timezone for consistency
- Convert Locally: Handle timezone conversion in your application
- Document Assumptions: Note timezone behavior in your workflows
Performance Optimization
API Efficiency
- Batch Symbols: Use comma-separated lists for multiple assets
- Minimal Data: Request only needed fields and periods
- Cache Results: Store frequently accessed data locally
Workflow Design
- Parallel Processing: Run independent requests simultaneously
- Conditional Logic: Only fetch detailed data when needed
- Error Recovery: Implement retry mechanisms for reliability
Conclusion
Mastering the core market data operations - time_series, quote, and price - provides the foundation for any financial analysis or trading system. By understanding how to configure these operations through the interface and applying best practices for data management, you can build robust and efficient financial workflows.
The key to success lies in selecting the right operation for your specific needs, optimizing your requests for performance, and handling data appropriately for your analysis requirements. With these core operations mastered, you're ready to explore more advanced features like technical indicators and fundamental data.
For more advanced operations, check out our other guides covering technical indicators, fundamental analysis, and specialized market data.