Skip to main content

115. Tournament-Based Market Selection

Status: Accepted Date: 2025-07-06

Context

The Tyche module, using its inverted opportunity discovery model (adr://inverted-opportunity), needs a way to apply its pairwise AI comparison (adr://ai-powered-comparisons) to a large pool of potential markets (e.g., 50+) to find the single best one that matches a given "spell".

Doing a full round-robin comparison, where every market is compared to every other market, would require N * (N-1) / 2 comparisons. For 50 markets, this is 1225 comparisons, which would be prohibitively slow and expensive using an LLM. We need a more efficient method.

Decision

The Tyche module will leverage the existing Dike tournament engine (fdd://mercury-dike) to perform market selection.

The process will work as follows:

  1. A new tournament is created in Dike.
  2. The "participants" of this tournament are not traders, but the market symbols themselves (e.g., BTC/USDT, ETH/USDT, etc.).
  3. The Dike engine is configured to use Tyche's compareMarkets function as its method for determining the winner of each "match".
  4. Dike then runs its standard tournament flow (e.g., single-elimination, swiss, or round-robin, depending on the tournament configuration).

This reuses the robust, battle-tested orchestration logic of the Dike module (which is built on BullMQ Flows) to efficiently manage the large number of comparison tasks. A single-elimination tournament, for example, would only require N-1 comparisons (49 for 50 markets) to find the winner, a massive improvement.

Consequences

Positive:

  • Massive Efficiency Gain: Reduces the number of expensive AI comparisons required to find the best market from O(N^2) to O(N) for a single-elimination tournament, making the process viable at scale.
  • High Code Reuse: We are reusing the entire Dike module, a complex and critical piece of infrastructure, for a new purpose with minimal new code. We get its queuing, job orchestration, state management, and error handling for free.
  • Flexibility: We can leverage all the different tournament formats supported by Dike for different market selection scenarios. A quick "playoff" can use single-elimination, while a more thorough "regular season" could use a Swiss or Round-Robin format on a smaller pool of pre-qualified markets.
  • Separation of Concerns: Tyche remains focused on the logic of comparing two markets. Dike remains focused on the logic of running a tournament. The integration is clean and respects the boundaries of each module.

Negative:

  • Conceptual Coupling: Creates a strong coupling between the Tyche (market analysis) and Dike (tournament engine) modules. A change in the Dike tournament flow could potentially affect market selection.
  • Potential for Early Elimination: In a single-elimination tournament, the second-best market might be eliminated early if it happens to face the best market in the first round.

Mitigation:

  • Well-Defined Interface: The integration happens through a clean, stable public API on both services. Dike is configured with a generic "comparison function", it doesn't need to know the internal details of Tyche.
  • Seeding and Tournament Formats: For scenarios where finding the top N markets is important (not just the single best), we can use seeding strategies or more robust tournament formats like Swiss or multiple single-elimination brackets to mitigate the risk of early elimination.