Tradebot-Java is a high-performance algorithmic trading engine built with Quarkus (the Supersonic Subatomic Java Framework). It provides a robust, real-time pipeline for market data ingestion, technical indicator calculation, and automated strategy execution, specifically tailored for the XTS API.
- Live Trading: Real-time socket-based execution with automated instrument subscription.
- Backtesting: High-fidelity backtesting against historical tick data stored in MongoDB.
- Data Synchronization: Synchronous master data and historical OHLC sync from XTS.
- Dynamic Strategies: Pluggable strategy engine with support for complex multi-indicator setups (EMA, VWAP, OBV, etc.).
- Risk Management: Automated SL/TP, Trailing Stop-Loss (TSL), and Breakeven (BE) logic.
- Structured Logging: Beautifully formatted, colorized logs for market heartbeats, signals, and trade execution.
- Java: JDK 21 or higher.
- Build Tool: Maven 3.9+ (included wrapper
./mvnwis recommended). - Database: MongoDB 6.0+ (running locally or via URI).
- API Credentials: Active XTS API credentials (Market and Interactive).
The project uses a hybrid configuration model:
- .env File: Create a
.envfile in the root directory for secrets (Template in.env.example).XTS_ROOT_URL=https://... MARKET_API_KEY=your_key MARKET_API_SECRET=your_secret ...
- application.properties: Standard configuration for market constants, strategy defaults, and MongoDB URIs located
in
src/main/resources/application.properties.
Run the application in dev mode with live reloading:
./mvnw quarkus:devTo run specific subcommands in dev mode:
./mvnw quarkus:dev -Dquarkus.args="[subcommand] [args]"To build a runnable JAR:
./mvnw clean packageTo build without running tests:
./mvnw clean package -DskipTestsThis produces the quarkus-run.jar in target/quarkus-app/.
java -jar target/quarkus-app/quarkus-run.jar [subcommand] [args]./mvnw package -Dquarkus.package.jar.type=uber-jar
java -jar target/*-runner.jar [subcommand] [args]# Sync instrument master data from XTS
./mvnw quarkus:dev -Dquarkus.args="sync-master"
# Sync last 20 days of Nifty history
./mvnw quarkus:dev -Dquarkus.args="sync-history -s 2026-03-19 -e 2026-03-19"# Run live trading with default triple-confirmation strategy
./mvnw quarkus:dev -Dquarkus.args="live"
# Run with specific strategy, budget, and risk parameters
./mvnw quarkus:dev -Dquarkus.args="live --strategy-id triple-confirmation --budget 10-lots --sl 4.0 --targets 3.0 --tsl 0.5 --log-active-indicator"# Run a backtest for a specific date range
./mvnw quarkus:dev -Dquarkus.args="backtest --start 2026-03-19 --end 2026-03-19"
# Run backtest with custom risk parameters
./mvnw quarkus:dev -Dquarkus.args="backtest --start 2026-03-23 --end 2026-03-25 --sl 4.0 --targets 3.0 --budget 3-lots --use-be --verbose"The REST API server is the default entry point. If you start the application without any subcommand, it will stay alive to serve the UI on port 8080.
The CLI is now fully independent of the API server. When you run a subcommand (like backtest or live), the application automatically disables its internal HTTP server.
This means:
- You can keep the API server running for the UI in one terminal.
- You can start/stop as many CLI tasks as you want in other terminals.
- No port conflicts (
8080is reserved only for the base API process).
| Goal | Command | API Server Status |
|---|---|---|
| Serve UI / REST | java -jar .../quarkus-run.jar |
Enabled (Port 8080) |
| Live Trading | java -jar .../quarkus-run.jar live |
Disabled (Task only) |
| Backtest | java -jar .../quarkus-run.jar backtest ... |
Disabled (Task only) |
| Data Sync | java -jar .../quarkus-run.jar sync-master |
Disabled (Task only) |
Tip
To see live updates in the UI while running a CLI task, simply keep one terminal running the base API server. The UI will fetch the latest state from MongoDB as the independent CLI process updates it.
# Test XTS socket connectivity and watch incoming stream (reduced output)
./mvnw quarkus:dev -Dquarkus.args="debug-socket --print-mode reduced"Tradebot-Java is driven by a powerful CLI.
| Subcommand | Description | Example Usage |
|---|---|---|
live |
Run live trading engine | ... live --strategy-id triple-confirmation --budget 10-lots --log-active-indicator |
backtest |
Run historical backtest | ... backtest --start 2026-03-23 --end 2026-03-25 --budget 3-lots |
sync-master |
Sync instrument master data | ... sync-master |
sync-history |
Sync historical OHLC data | ... sync-history -s 2026-03-23 -e 2026-03-25 |
analyze |
Analyze crossovers/indicators | ... analyze -i NIFTY -d 2026-03-25 |
debug-socket |
Test XTS socket connectivity | ... debug-socket --print-mode reduced |
The project uses JUnit 5 and Mockito for testing.
- Run all tests:
./mvnw test - Run specific test package:
./mvnw test -Dtest=org.tradebot.logic.*
./mvnw clean package -DskipTests
./mvnw checkstyle:check
./mvnw checkstyle:checkstyle <<< generates html report under target/reports
./mvnw spotbugs:check
./mvnw spotbugs:spotbugs <<< generates html report under target/reports
./mvnw rewrite:run
./mvnw test
java -jar target/quarkus-app/quarkus-run.jar backtest --start 2026-03-18
java -jar target/quarkus-app/quarkus-run.jar live --log-active-indicatororg.tradebot.core: Orchestration logic and CLI runners.org.tradebot.services: Core business logic (Ingestion, Resampling, Strategy, Position Mgmt).- See Live Trading Documentation for details on live execution.
org.tradebot.xts: Low-level XTS API client and socket handling.org.tradebot.models: Domain models and event definitions.org.tradebot.repository: MongoDB data access layer.
For more information on Quarkus, visit quarkus.io.