13 KiB
13 KiB
0.19 (released November 19, 2025)
Breaking
TradingStatementis now an interface: Converted to an interface implemented byBaseTradingStatement. This exposes the underlyingStrategyandTradingRecordfor advanced analysis workflows. Action required: Update any code that directly instantiatesTradingStatementto useBaseTradingStatementinstead.- PnL and return criteria refactored into net/gross variants: Split
ProfitLossCriterion,ProfitCriterion,LossCriterion,AverageProfitCriterion,AverageLossCriterion,ReturnCriterion,ProfitLossRatioCriterion, andProfitLossPercentageCriterioninto separate net and gross concrete classes. This provides explicit control over whether trading costs are included in calculations. Action required: Update imports and class names to use the appropriate net or gross variant based on your analysis needs. - Indicator operation classes consolidated: #1266 Unified
BinaryOperation,UnaryOperation,TransformIndicator, andCombineIndicatorinto a cleaner API. Action required: Replace deprecatedTransformIndicatorandCombineIndicatorusage with the new consolidated classes. - Drawdown criteria moved to sub-package: Relocated
MaximumDrawdownCriterionandReturnOverMaxDrawdownCriterionto thecriteria/drawdown/sub-package for better organization. Action required: Update import statements to reflect the new package location.
Added
- Rule naming support: Added
Rule#getName()andRule#setName(String)methods to allow rules to have custom names for improved trace logging and serialization. Rules now default to JSON-formatted names that include type and component information, but can be overridden with custom labels for better readability in logs and debugging output. - Time-based trading rules: Added
HourOfDayRuleandMinuteOfHourRuleto enable trading strategies based on specific hours of the day (0-23) or minutes of the hour (0-59). These rules work withDateTimeIndicatorto filter trading signals by time, enabling time-of-day based strategies. - Time-based strategy examples: Added
HourOfDayStrategyandMinuteOfHourStrategyas example implementations demonstrating how to use the new time-based rules in complete trading strategies. - Enhanced backtesting with performance tracking: Introduced
BacktestExecutionResultandBacktestRuntimeReportwith newBacktestExecutorentry points. Users can now track per-strategy execution times, receive progress callbacks during long-running backtests, and efficiently stream top-k strategy selection for large strategy grids without loading all results into memory. - Strategy serialization for persistence: Added
StrategySerializationwithStrategy#toJson()andStrategy#fromJson(BarSeries, String)methods. This enables users to save and restore complete strategy configurations (including entry/exit rules) as JSON, making it easy to share strategies, version control configurations, and build strategy libraries. - NamedStrategy serialization with compact format: #1349 Enabled
NamedStrategyserialization/deserialization with compact labels (e.g.,ToggleNamedStrategy_true_false_u3). Users can now persist strategy presets alongside their parameters in a human-readable format. Added registry/permutation helper APIs and lazy package scanning viaNamedStrategy.initializeRegistry(...)for efficient strategy discovery. - Renko chart indicators: #1187 Added
RenkoUpIndicator,RenkoDownIndicator, andRenkoXIndicatorto detect Renko brick sequences, enabling users to build strategies based on Renko chart patterns. - Advanced drawdown analysis: Added
CumulativePnL,MaximumAbsoluteDrawdownCriterion,MaximumDrawdownBarLengthCriterion, andMonteCarloMaximumDrawdownCriterion. Users can now analyze drawdowns in absolute terms, measure drawdown duration, and estimate drawdown risk distributions through Monte Carlo simulation of different trade orderings. - Comprehensive commission tracking: Added
CommissionsCriterionto total commissions paid across positions andCommissionsImpactPercentageCriterionto measure how much trading costs reduce gross profit. This helps users understand the real impact of transaction costs on strategy performance. - Streak and extreme position analysis: Added
MaxConsecutiveLossCriterion,MaxConsecutiveProfitCriterion,MaxPositionNetLossCriterion, andMaxPositionNetProfitCriterion. Users can now identify worst loss streaks, best win streaks, and extreme per-position outcomes to better understand strategy risk and consistency. - Position timing analysis: Added
InPositionPercentageCriterionto calculate the percentage of time a strategy remains invested, helping users understand capital utilization and exposure. - Flexible bar building options: Added
AmountBarBuilderto aggregate bars after a fixed number of amount have been traded. Bars can now be built bybeginTimeinstead ofendTime, providing more flexibility in bar aggregation strategies. - Volume-weighted MACD: Added
MACDVIndicatorto volume-weight MACD calculations, providing an alternative MACD variant that incorporates volume information. - Net momentum indicator: Added
NetMomentumIndicatorfor momentum-based strategy development. - Vote-based rule composition: Added
VoteRuleclass, enabling users to create rules that trigger based on majority voting from multiple underlying rules. - Enhanced data loading: Added
AdaptiveJsonBarsSerializerto support OHLC bar data from Coinbase or Binance, and newJsonBarsSerializer.loadSeries(InputStream)overload for easier data loading from streams. - Improved charting and examples: Expanded charting utilities to overlay indicators with trading records, added
NetMomentumStrategyandTopStrategiesExample, and bundled a Coinbase ETH/USD sample data set to demonstrate the new APIs. - Automated release pipeline: Added GitHub workflow to automatically version, build, and publish artifacts to Maven Central. The pipeline uses
prepare-release.shto prepare release versions, creates release branches and tags, and publishes to Maven Central. Addedscripts/tests/test_prepare_release.shto validate release preparation functionality. - Enhanced performance reporting: Added Gson
DurationTypeAdapter,BasePerformanceReport, and revisedTradingStatementGeneratorso generated statements always carry their source strategy and trading record for complete traceability. - UnaryOperation helper: Added
substitutehelper function toUnaryOperationfor easier indicator transformations. - Testing infrastructure: Added tests for
DoubleNumFactoryandDecimalNumFactory, unit tests around indicator concurrency in preparation for future multithreading features, andDecimalNumPrecisionPerformanceTestto demonstrate precision vs performance trade-offs.
Changed
- Enhanced rule serialization with custom name preservation: Improved
RuleSerializationto preserve custom rule names set viasetName()during serialization and deserialization. Custom names are now properly distinguished from default JSON-formatted names, enabling better strategy persistence and debugging workflows. - Improved trace logging with rule names: Enhanced trace logging in
AbstractRuleandBaseStrategyto use rule names (custom or default) in log output, making it easier to identify which rules are being evaluated during strategy execution. - Unified logging backend: Replaced Logback bindings with Log4j 2
log4j-slf4j2-implso examples and tests share a single logging backend. Added Log4j 2 configurations for modules and tests. This simplifies logging configuration and ensures consistent behavior across all modules. Set unit test logging level to INFO and cleaned build output of all extraneous logging. - More accurate return calculations: Changed
AverageReturnPerBarCriterion,EnterAndHoldCriterion, andReturnOverMaxDrawdownCriterionto useNetReturnCriterioninstead ofGrossReturnCriterionto avoid optimistic bias. This provides more realistic performance metrics that account for trading costs. - Improved drawdown criterion behavior:
ReturnOverMaxDrawdownCriterionnow returns 0 instead ofNaNfor strategies that never operate, and returns net profit instead ofNaNfor strategies with no drawdown. This makes the criterion more robust and easier to use in automated analysis. - More flexible stop rules:
StopGainRuleandStopLossRulenow accept any priceIndicatorinstead of onlyClosePriceIndicator. Users can now create stop rules based on high, low, open, or custom price indicators for more sophisticated exit strategies. - Enhanced swing indicators: Reworked
RecentSwingHighIndicatorandRecentSwingLowIndicatorwith plateau-aware, NaN-safe logic and exposedgetLatestSwingIndexfor downstream analysis. This improves reliability and enables more advanced swing-based strategies. - Configurable numeric precision: Reduced default
DecimalNumprecision from 32 to 16 digits, improving performance while still maintaining sufficient accuracy for most use cases. Users can configure precision based on their specific needs. - Improved numeric indicator chaining:
NumericIndicator'spreviousmethod now returns aNumericIndicator, enabling fluent method chaining for indicator composition. - Enhanced trading statements: Added
TradingRecordproperty toTradingStatementfor more downstream flexibility around analytics, enabling users to access the full trading record from performance reports. - Better code maintainability: Removed magic number 25 in
UpTrendIndicatorandDownTrendIndicator, making the code more maintainable and self-documenting. - Modernized build infrastructure: #1399 Refreshed dependencies, plugins, and build tooling while enforcing Java 21 and Maven 3.9+. This ensures compatibility with modern development environments and security updates.
- Maven Central distribution: Changed snapshot distribution to Maven Central after OSSRH end-of-life, ensuring continued availability of snapshot builds.
- Improved bar series builder:
BaseBarSeriesBuildernow automatically uses theNumFactoryfrom given bars instead of the default one, ensuring consistent numeric types throughout bar series construction.
Fixed
- Kalman filter robustness: Guarded
KalmanFilterIndicatoragainst NaN/Infinity measurements to keep the Kalman state consistent, preventing calculation errors when input data contains invalid values. - Recursive indicator stack overflow: Fixed recursion bug in
RecursiveCachedIndicatorthat could lead to stack overflow in certain situations, improving reliability for complex indicator calculations. - Cost tracking in enter-and-hold: Fixed
EnterAndHoldCriterionto properly keep track of transaction and hold costs, ensuring accurate performance comparisons. - Convergence divergence indicator: Fixed strict rules of
ConvergenceDivergenceIndicatorfor more accurate divergence detection. - Return over max drawdown calculation: Fixed calculation for
ReturnOverMaxDrawdownCriterionandVersusEnterAndHoldCriterionto ensure accurate performance metrics. - Profit/loss percentage calculation: Refactored
ProfitLossPercentageCriterionto correctly calculate aggregated return, fixing previous calculation errors. - Bar series trade parameter order: Fixed swapped parameter naming in
BaseBarSeries#addTrade(final Number tradeVolume, final Number tradePrice)to match the method signature order. - Bar builder aggregation: Fixed aggregation of amount and trades in
VolumeBarBuilderandTickBarBuilderto ensure accurate bar construction. - SMA unstable period calculation: Corrected the calculation of unstable bars for the SMA indicator, ensuring indicators report accurate stability periods.
- Java 25 compatibility: Fixed
PivotPointIndicatorTestto work with Java 25, ensuring compatibility with the latest Java versions. Note that this does not mean Ta4j as a whole now supports Java 25, that will come in a future release. - JSON data loading: Fixed bug in
MovingAverageCrossOverRangeBacktestthat prevented successfully loading test JSON bar data. - Build performance: Updated GitHub test workflow to cache dependencies for quicker builds, reducing CI/CD execution time.
- Documentation: Updated test status badge on README and clarified PnL criterion comments about trading costs for better user understanding.
Removed/Deprecated
- Deprecated indicator classes: Removed
TransformIndicatorandCombineIndicatorin favor of the consolidatedBinaryOperationIndicatorandUnaryOperationIndicatorclasses. Action required: Migrate any code using these deprecated classes to the new consolidated API.