Use this file to discover all available pages before exploring further.
All data sources in ta4j share a single interface: BarSeriesDataSource. Every implementation loads data the same way — you pass a ticker, an interval, and a date range, and get back a BarSeries. This makes it straightforward to swap sources without touching your strategy code.
YahooFinanceHttpBarSeriesDataSource fetches OHLCV data from Yahoo Finance’s public API. No API key required.
import ta4jexamples.datasources.YahooFinanceHttpBarSeriesDataSource;import java.time.Duration;import java.time.Instant;// Enable response caching to avoid hitting API limits during developmentYahooFinanceHttpBarSeriesDataSource dataSource = new YahooFinanceHttpBarSeriesDataSource(true);// Unified interface: works with any BarSeriesDataSourceBarSeries series = dataSource.loadSeries( "AAPL", Duration.ofDays(1), Instant.parse("2023-01-01T00:00:00Z"), Instant.parse("2023-12-31T23:59:59Z"));
Convenience methods for common patterns:
// Load by bar count (730 daily bars = ~2 years)BarSeries daily = dataSource.loadSeriesInstance( "AAPL", YahooFinanceHttpBarSeriesDataSource.YahooFinanceInterval.DAY_1, 730);// Static convenience: 1 year of daily dataBarSeries aapl = YahooFinanceHttpBarSeriesDataSource.loadSeries("AAPL", 365);// Static convenience: 500 hourly barsBarSeries btc = YahooFinanceHttpBarSeriesDataSource.loadSeries( "BTC-USD", YahooFinanceHttpBarSeriesDataSource.YahooFinanceInterval.HOUR_1, 500);
Supported assets:
Stocks: "AAPL", "MSFT", "GOOGL", "TSLA", etc.
ETFs: "SPY", "QQQ", "VTI", etc.
Cryptocurrencies: "BTC-USD", "ETH-USD", "SOL-USD", etc.
Supported intervals:
Enum constant
Duration
MINUTE_1
1 minute
MINUTE_5
5 minutes
MINUTE_15
15 minutes
MINUTE_30
30 minutes
HOUR_1
1 hour
HOUR_4
4 hours
DAY_1
1 day
WEEK_1
1 week
MONTH_1
1 month
Pagination: When the requested range exceeds conservative API limits (for example, 30 days for intraday intervals, 1 year for daily), the implementation splits the request into multiple chunks automatically and merges results.
Enable caching with new YahooFinanceHttpBarSeriesDataSource(true). Responses are saved to temp/responses/ and reused. Historical data (end date in the past) is cached indefinitely; recent data respects the bar interval.
Yahoo Finance is an unofficial API. It may impose rate limits (~2000 requests/hour per IP) and availability can vary. For production systems, consider an official data provider.
CoinbaseHttpBarSeriesDataSource fetches cryptocurrency OHLCV data from Coinbase’s public market data API. No authentication required.
import ta4jexamples.datasources.CoinbaseHttpBarSeriesDataSource;import java.time.Duration;import java.time.Instant;// Enable response cachingCoinbaseHttpBarSeriesDataSource dataSource = new CoinbaseHttpBarSeriesDataSource(true);// Unified interfaceBarSeries series = dataSource.loadSeries( "BTC-USD", Duration.ofDays(1), Instant.parse("2023-01-01T00:00:00Z"), Instant.parse("2023-12-31T23:59:59Z"));
Convenience methods:
// Static convenience: 1 year of daily dataBarSeries btc = CoinbaseHttpBarSeriesDataSource.loadSeries("BTC-USD", 365);// Instance method: 500 hourly barsBarSeries eth = dataSource.loadSeriesInstance( "ETH-USD", CoinbaseHttpBarSeriesDataSource.CoinbaseInterval.ONE_HOUR, 500);
Supported intervals:
Enum constant
Duration
ONE_MINUTE
1 minute
FIVE_MINUTE
5 minutes
FIFTEEN_MINUTE
15 minutes
THIRTY_MINUTE
30 minutes
ONE_HOUR
1 hour
TWO_HOUR
2 hours
FOUR_HOUR
4 hours
SIX_HOUR
6 hours
ONE_DAY
1 day
Pagination: Coinbase limits responses to 350 candles per request. When the requested range would exceed that, the implementation paginates automatically and merges all chunks into a single BarSeries.Supported pairs: All Coinbase trading pairs — for example "BTC-USD", "ETH-USD", "SOL-USD".
Loads OHLCV bar data from CSV files. The implementation uses intelligent filename pattern matching to locate the right file based on the ticker symbol.
import ta4jexamples.datasources.CsvFileBarSeriesDataSource;BarSeriesDataSource csv = new CsvFileBarSeriesDataSource();BarSeries eth = csv.loadSeries( "ETH-USD", Duration.ofDays(1), start, end);
CSV files must contain OHLCV columns. The filename should include the ticker so the data source can match it.
JsonFileBarSeriesDataSource
Parses JSON data in Coinbase or Binance export format. Supports flexible date filtering to load a subset of the file.
Aggregates Bitstamp trade-level CSV data into OHLCV bars on the fly. This is the data source used in the ta4j quickstart example.
import ta4jexamples.datasources.BitStampCsvTradesFileBarSeriesDataSource;// Loads the bundled Bitstamp BTC trade history and aggregates into barsBarSeries series = BitStampCsvTradesFileBarSeriesDataSource.loadBitstampSeries();
This source is best for offline development and examples. It reads raw tick data and computes OHLCV candles from trade price and volume.