Developers

API Reference

Comprehensive documentation for the rlx-search HTTP API. Manage datasets, compute pattern matches, run ANN searches, and train RL agents.

Backtesting

Simulate historical performance of the pattern matching engine to validate predictive power. The system walks forward through history, performing a search at each step using only data available at that time.

GET/api/patterns/backtest

Run Simulation

Runs a backtest simulation over a time range.

Example Request

Simulation Engine: The Reality Check

This tool prevents you from fooling yourself. It simulates what would have happened if you had traded this strategy over the last N months. It strictly respects Time Causality — meaning it never peeks into the future.

How it works (The Walk-Forward Loop)
  • 1. It starts at a historical point (e.g., 1 year ago).
  • 2. It runs a pattern search using only data available then.
  • 3. It records the prediction vs. what actually happened.
  • 4. It jumps forward by step candles and repeats.
Key Metrics (The Report Card)
  • Accuracy: How often did the price actually go in the predicted direction?
  • Profit Factor: Gross Wins / Gross Losses. > 1.5 is usually good.
  • Smart Exit Levels: Probabilistic SL/TP levels (80/60/40%) based on historical excursions of the matches.
  • Avg Return: The average % gain per trade.
Pro Tip: The "Step" Parameter

If step equals your forecast horizon f, you are simulating continuous trading (always in a trade). If step is small (e.g., 1), you are simulating a high-frequency check every hour. This is slower but more granular.

POST/api/patterns/backtest/specific

Specific Pattern Backtest

Runs a backtest for a specific pattern configuration with fees and slippage.

Example Request

Precision Testing: The "What If" Machine

While the general backtest scans a whole year, this endpoint is for Micro-Validation. It answers: "If I had entered a trade at this EXACT timestamp with these EXACT fees, would I have made money?"

Real-World Friction

Most backtests fail because they ignore costs. This endpoint forces you to be honest by including:

  • Fee %: Exchange commissions (e.g., 0.04%).
  • Slippage %: The price drift between signal and execution (e.g., 0.02%).
Use Case: Signal Auditing

Did your bot lose money on a trade last week? Plug that timestamp into this endpoint. It will replay the pattern match logic from that exact moment and tell you if the signal was bad or if it was just bad luck/execution.

Why "Specific"?

This is useful for Unit Testing your strategy. You can build a test suite of 50 "known difficult moments" (e.g., flash crashes) and run this endpoint against them to ensure your algorithm handles them correctly before deploying capital.