Skip to content

release: Version 0.2.0#8

Merged
impatient0 merged 2 commits intomainfrom
develop
Nov 7, 2025
Merged

release: Version 0.2.0#8
impatient0 merged 2 commits intomainfrom
develop

Conversation

@impatient0
Copy link
Owner

A-Zero v0.2.0 Release Notes

This release marks the first major functional milestone for the A-Zero framework, introducing a complete, end-to-end command-line backtesting suite. This version provides a robust, data-driven environment for developing, testing, and analyzing trading strategies before they are ever exposed to a live market.

Key Features & Highlights

  • Complete CLI Backtester (a0-backtester-cli):

    • A new standalone application allows users to run full trading simulations directly from the terminal. It provides a user-friendly interface for configuring a backtest with strategy files, data files, account modes, and leverage.
  • Declarative YAML Strategies (a0-strategy-rules-engine):

    • A powerful new engine allows for defining trading logic in simple, human-readable YAML files. The initial release supports:
      • Entry Rules: Based on the RSI indicator.
      • Exit Rules: Fixed percentage-based Stop Loss and Take Profit.
      • Position Sizing: Dynamic sizing based on a fixed percentage of the account's Net Asset Value.
  • Professional-Grade Simulation Engine (a0-backtester):

    • The core backtesting engine was completely overhauled to feature a sophisticated Portfolio Margin Model, accurately simulating the mechanics of a modern exchange account (e.g., Bybit UTA).
    • It manages a multi-asset wallet, tracking both owned assets and borrowed liabilities.
    • It performs pre-trade Initial Margin Rate (IMR) checks to validate trade feasibility under leverage.
    • Crucially, it simulates forced liquidations by continuously monitoring maintenance margin, providing a critical safety and realism feature that penalizes overly risky strategies.

Architectural & API Changes

  • The Strategy interface has been evolved to be more robust and extensible. The primary method is now onMarketEvent(MarketEvent event, ...) which encapsulates all market data for a given tick.
  • The TradingContext interface has been significantly expanded to provide strategies with a rich, read-only view of the account's state, including Net Asset Value, Margin Equity, and all wallet balances.

Getting Started

Please refer to the updated main README.md for detailed instructions on how to build the project and run your first backtest.

What's Next

With the backtesting foundation now complete and robust, our next major epic (v0.3) will focus on laying the groundwork for live market integration, including hooks for sentiment analysis and the initial architecture for paper trading against exchange testnets.

- Wrap the tests in a `@Nested` test class
- Rewrite test names to utilize Gherkin-style notation
* feat(backtester): create a new a0-core module

- Define a new module in the root POM
- Create module's own POM with basic dependencies

* chore: logically group dependencies

- Logically group dependencies in POMs and add comments to each group

* feat(backtester): implement model classes

- Create `Candle`, `Position` and `Trade` domain models
- Create a `TradeDirection` domain enum

* feat(backtester): implement public interfaces

- Create `Strategy` interface defining the contract for the analytical component
- Create `TradingContext` interface defining the contract for the environment `Strategy` operates within

* feat(backtester): create a new a0-backtester module

- Define a new module in the root POM
- Create module's own POM with basic dependencies

* feat(backtester): complete interface and create data model

- Add method declarations to TradingContext interface
- Create data model for backtester consisting of BacktestConfig and BacktestResult

* feat(backtester): scaffold backtesting engine

- Create initial (stubbed) implementation for BacktestEngine

* feat(core): evolve TradingContext interface

- Make TradingContext interface more flexible by introducing a submitOrder(...) method that allows opening, scaling and closing positions

* feat(backtester): update BacktestEngine

- Update BacktestEngine to implement the evolved TradingContext
- Refine position handling logic

* feat(backtester): include costs in backtest config

- Update BacktestConfig to include trading fees and slippage parameters

* feat(backtester): implement cost calculation and fix SHORT logic

- Implement logic for calculating the costs of opening and closing positions, as well as liquidation cost for the final position
- Correct the cash flow logic for opening/closing SHORT positions

* chore(backtester): add missing Javadocs

- Create descriptive Javadocs for all fields and methods in BacktestEngine that previously weren't annotated

* docs(backtester): create/update documentation

- Create a0-backtester/README.md with a detailed description of module's functionality
- Update README.md and ARCHITECTURE.md to reflect the changes to project's current state and roadmap

* chore(backtester): use getLast()

- replace `get(....size() - 1)` with `getLast()`

* feat(backtester): replace stub with actual strategy

- Replace the stubbing `Object` with an actual `Strategy` field in BacktestConfig
- Use the `Strategy` object in the engine's main loop

* test(backtester): create utility classes for unit tests

- Create ConfigurableTestStrategy that executes a predefined set of actions
- Create TestDataFactory that produces test candle data

* build(backtester): add SLF4J provider dependency

* test(backtester): create the "happy path" test

- Implement a test verifying that P/L is calculated correctly if a strategy opens one LONG position and never closes it

* feat(backtester): improve logging for opening positions

- Log message for opening a position now indicates the volume of the asset

* feat(backtester): implement more test for edge cases

- Add test verifying that orders with a cost exceeding available balance are ignored
- Add test verifying that orders for a new symbol are ignored if another position is already open
- Add test verifying that scale-out order exceeding position size closes the position
- Add test verifying that closing a position and opening a new one on a different symbol is handled correctly

* docs(backtester): update documentation

- Update backtester's own README.md to reflect the implemented functionality
- Tick off the corresponding item in the project-level README.md roadmap list

* docs(backtester): clarify strategy mutation

- Add a note to the BacktestConfig Javadoc indicating that it requires a fresh instance of a `Strategy` object
- Add a similar note to backtester's README.md

* docs(backtester): update documentation to reflect roadmap change

- Update project-level README.md and ARCHITECTURE.md to reflect the revised implementation plan, introducing a new `a0-strategy-rules-engine` module

* docs(backtester): update strategy snippet

- Update strategy example in ARCHITECTURE.md to reflect the new architecture

* feat(backtester): incorporate collateral calculation

- Implement logic that calculates and locks the collateral for SHORT trades. All LONG trades are considered spot trades, and SHORT trades are considered margin trades for the purpose of simplicity

* feat(backtester): introduce the AccountMode concept

- Create an AccountMode enum
- Add a corresponding field to BacktestConfig

* feat(backtester): refactor engine for two account modes

- Make the engine aware of account mode and have business logic branch accordingly

* feat(backtester): introduce collateral ratios

- Define collateral ratios in a dedicated YAML file
- Create a CollateralRatioLoader config class

* feat(backtester): evolve state and configuration

- Update BacktestConfig to store multiple streams of candle data
- Rename `collateral` to `costBasis` in Position for clarity in context of spot positions
- Adapt TradingContext for positions in multiple symbols

* feat(backtester): clean up TradingContext interface

- Remove the `updateCurrentPrices` as it should be package-private
- Update Javadocs to be more clear

* feat(backtester): refactor BacktestEngine for margin trading

- Now able to simulate against multiple streams of candle data
- Includes Maintenance Margin logic and simulates forced liquidation on margin calls
- Logic for order execution has been rewritten

* test(backtester): refactor test utility for new data model

- Refactor TestDataFactory to produce multiple streams of candle data

* fix(backtester): correct trade recording

- Ensure that a trade is recorded upon closing/scaling out of SPOT positions

* test(backtester): replace the test suite

- Scrap the old tests as they are no longer compatible with the engine
- Create new tests focused on the SPOT_ONLY trading mode

* feat(backtester): relax encapsulation to enable white box testing

- Make `BacktestTradingContext` and its constructor package-private
- Make all calculation methods package-private
- Create dedicated `getWalletBalanceForTest` and `setupMarginPositionForTest` test access methods

* chore(backtester): update collateral ratios

- Update collateral-ratios.yaml with more accurate values

* test(backtester): add tests for MARGIN mode

- Implement test scenarios for MARGIN mode trades

* test(backtester): make executed trades accessible for tests

- Add a package-private `getExecutedTradesForTest` method that returns a copy of the `executedTrades` list

* test(backtester): expand the test suite

- Implement additional tests focused on scaling positions and various edge cases

* docs(backtester): update README.md

- Update module-level README.md to accurately describe the current state of the backtest engine

* feat(strategy-rules-engine): configure new module

- Create new Maven module `a0-strategy-rules-engine`
- Define necessary dependencies in module's POM

* fix(strategy-rules-engine): fix jackson dependency group id

- Update group ID for Jackson dependencies from legacy `com.fasterxml.jackson...` to `tools.jackson...`

* feat(strategy-rules-engine): create DTOs

- Implement data transfer objects for strategy configuration

* refactor(strategy-rules-engine): refactor StrategyConfig

- Refactor StrategyConfig into a record class and include a new `timeframe` field

* feat(strategy-rules-engine): create RSI indicator

- Create an Indicator interface defining the contract for an indicator
- Implement an RsiIndicator using the TA4j library

* refactor(core): evolve Strategy interface

- Introduce a new MarketEvent record class carrying candle and symbol information
- Strategy now has a `void onMarketEvent(...)` method instead of the `void onCandle(...)`

* refactor(backtester): refactor BacktestEngine for MarketEvent

- Refactor the main loop to feed MarketEvents into strategies

* refactor(backtester): refactor tests for MarketEvent

- Refactor tests to correctly use MarketEvent

* refactor(core): evolve TradingContext interface

- Refactor TradingContext by introducing more methods to provide detailed read-only view of the trading account state

* refactor(backtester): refactor BacktestEngine and its tests

- Implement the new methods from TradingContext in the BacktestTradingContext
- Replace the `getWalletBalanceForTest` method usage with `getAssetBalance`

* feat(strategy-rules-engine): implement RulesBasedStrategy

- Expand config to include position sizing
- Implement exit and sizing logic
- Implement the strategy class

* feat(strategy-rules-engine): implement strategy loader

- Create TimeframeParser utility class
- Implement StrategyLoader able to load strategies from YAML configs

* test(strategy-rules-engine): create tests for TimeframeParser

- Implement the TimeframeParserTest class
- Add a `junit-jupiter-params` dependency

* feat(core): add withers to Candle

- Add Lombok `@With` annotation to generate corresponding methods in Candle class

* test(strategy-rules-engine): add TP/SL rules tests

- Create TakeProfitRuleTest and StopLossRuleTest verifying that the rules trigger correctly

* test(strategy-rules-engine): add RSI indicator tests

- Create RsiIndicatorTest verifying that signals are being triggered correctly

* feat(strategy-rules-engine): relax encapsulation for testability

- Add package-private getters to RulesBasedStrategy to enable integration testing of StrategyLoader

* test(strategy-rules-engine): create integration tests for StrategyLoader

- Verify happy path of successfully loading a strategy
- Verify graceful failure when loading from incorrect or malformed config

* test(strategy-rules-engine): create behavioral tests for RulesBasedStrategy

- Using mocked strategy components (indicators, sizers, exit rules), verify that the strategy operates them correctly

* docs(strategy-rules-engine): create/update documentation

- Create module-level README.md providing detailed description of `a0-strategy-rules-engine` functionality
- Update project-level documentation, detailing architecture changes and roadmap progress

* build(a0-backtester-cli): create new module

- Create new module, initialize necessary dependencies and configure build

* feat(a0-backtester-cli): create main CLI class

- Implement a BacktesterCli class with a stubbed `call()` method for now

* feat(a0-backtester-cli): implement a CSV loader

- Implement CsvDataLoader class that reads data from a CSV file and converts it to a `List<Candle>`

* feat(a0-backtester-cli): add actual logic in the CLI

- Fully implement the `call()` method inside the BacktesterCli class

* feat(a0-backtester-cli): make error messages more friendly

- Wrap the `call()` method body in `try-catch` and print more user friendly error messages

* test(a0-backtester-cli): implement a complete test suite

- Verify various scenarios, including a "happy path", malformed data, incorrect command-line arguments, etc.

* build(a0-backtester-cli): reduce shade warnings

- Configure build to eliminate some artifact clash shade warnings (some are still present though)

* docs(a0-backtester-cli): create/update documentation

- Create module-level README.md providing detailed description of `a0-backtester-cli` functionality
- Update project-level documentation, detailing architecture changes and roadmap progress

* chore(a0-backtester-cli): code cleanup

- Remove unused imports
- Replace statement lambdas with expressions for conciseness
@impatient0 impatient0 merged commit 3740d34 into main Nov 7, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant