3.8 KiB
ta4j-examples
ta4j-examples is the runnable companion module for ta4j-core.
It is organized as progressive learning tracks so production-minded Java developers can move from first run to robust execution workflows.
Prerequisites
- JDK 25+
- Maven 3.9+
- Build from the repository root where
ta4j-coreandta4j-examplesare both available
Run an example
From the repository root:
mvn -pl ta4j-examples exec:java -Dexec.mainClass=ta4jexamples.Quickstart
Replace ta4jexamples.Quickstart with any class listed below.
Verify your run succeeded
Use these quick checks before moving to the next track:
ta4jexamples.Quickstart: prints step-by-step run stages and trade/return metricsta4jexamples.backtesting.TradingRecordParityBacktest: logs execution-model comparison and parity check successta4jexamples.backtesting.TradeFillRecordingExample: logs streamed-vs-grouped fill handling and lot-matching outcomes
If chart windows do not appear, you are likely in a headless environment; switch to chart file output or run on a GUI-enabled machine.
Learning tracks
1) First strategy and metrics
ta4jexamples.Quickstartta4jexamples.analysis.StrategyAnalysis
2) Data sourcing and normalization
ta4jexamples.backtesting.YahooFinanceBacktestta4jexamples.backtesting.CoinbaseBacktestta4jexamples.datasources.YahooFinanceHttpBarSeriesDataSourceta4jexamples.datasources.CoinbaseHttpBarSeriesDataSource
3) Execution semantics and performance
ta4jexamples.backtesting.TradingRecordParityBacktestta4jexamples.backtesting.TradeFillRecordingExampleta4jexamples.backtesting.SimpleMovingAverageRangeBacktestta4jexamples.backtesting.BacktestPerformanceTuningHarness
Run a fixed throughput matrix and write matrix_performance.json:
mvn -pl ta4j-examples -am compile
mvn -pl ta4j-examples exec:java \
-Dexec.mainClass=ta4jexamples.backtesting.BacktestPerformanceTuningHarness \
-Dexec.args="--throughputControl --throughputOutputDir .agents/benchmarks/backtest-throughput/current --matrixStrategyCounts 250,500,1000 --matrixBarCounts 500,1000 --matrixMaxBarCountHints 0 --executionMode topK --topK 10 --parallelism 1"
Compare two refs on the same host/spec/dataset:
scripts/benchmark-backtest-throughput.sh HEAD^ HEAD
Both refs must include throughput-control support; use HEAD^ vs HEAD after
the harness and optimization commits are in place. The JSON artifacts include a
hashed hostId plus JVM/OS metadata so reports can be shared without exposing a
raw machine hostname.
4) Live-style workflows
ta4jexamples.bots.TradingBotOnMovingBarSeriesta4jexamples.backtesting.TradeFillRecordingExample
5) Charting and diagnostics
ta4jexamples.indicators.IndicatorsToChartta4jexamples.indicators.CandlestickChartta4jexamples.analysis.CashFlowToChart
Suggested progression
ta4jexamples.Quickstartta4jexamples.backtesting.TradingRecordParityBacktestta4jexamples.backtesting.TradeFillRecordingExampleta4jexamples.backtesting.SimpleMovingAverageRangeBacktestta4jexamples.backtesting.YahooFinanceBacktestorta4jexamples.backtesting.CoinbaseBacktestta4jexamples.bots.TradingBotOnMovingBarSeries
Companion guides
- Troubleshooting: https://ta4j.github.io/ta4j-wiki/Troubleshooting-Hub.html
- Backtesting realism gate: https://ta4j.github.io/ta4j-wiki/Backtesting-Realism-Checklist.html
- Live operations runbook: https://ta4j.github.io/ta4j-wiki/Live-Trading-Runbook.html
- Canonical end-to-end path: https://ta4j.github.io/ta4j-wiki/Canonical-User-Journey.html
- Expected example output signatures: https://ta4j.github.io/ta4j-wiki/Examples-Expected-Outputs.html
- API migration compatibility map: https://ta4j.github.io/ta4j-wiki/Migration-and-Version-Compatibility.html