Skip to main content

113. AI-Powered Market Comparisons

Status: Accepted Date: 2025-07-06

Context

The Tyche module needs to compare two financial markets (e.g., BTC/USDT vs. ETH/USDT) to determine which one is "better" according to a specific, often qualitative, set of criteria (an "opportunity pattern" or "spell"). For example, "which of these two markets shows a more promising setup for a mean-reversion trade on the 4-hour chart?"

A traditional approach would involve creating a complex, rigid scoring system based on various technical indicators. This is brittle, hard to maintain, and struggles to capture the nuanced, holistic "feel" of a market chart that an experienced trader uses.

Decision

The Tyche module will use a Large Language Model (LLM) to perform the pairwise market comparisons.

The process will be as follows:

  1. Gather relevant data for both markets, including technical analysis indicators from Minerva and current price data.
  2. Format this data into a structured prompt for the LLM.
  3. The prompt will ask the LLM to act as an expert trader and, based on the provided data and a specific "spell" (the opportunity criteria), determine which market is the superior choice.
  4. The LLM's response will be requested in a structured JSON format, including the winner, a confidence score, and the reasoning behind its decision.

This leverages the LLM's ability to perform nuanced, qualitative reasoning and pattern recognition that would be nearly impossible to codify in a traditional rule-based system.

Consequences

Positive:

  • Nuanced Analysis: The LLM can capture subtle, holistic patterns in the data that a simple scoring algorithm would miss, leading to more sophisticated market comparisons.
  • Flexibility: Opportunity patterns ("spells") can be defined using natural language in the prompt, making the system incredibly flexible. We can create new comparison strategies without writing any new code, simply by writing a new prompt.
  • Explainability: The LLM is required to provide its reasoning, which gives us valuable insight into why a particular market was chosen, making the system's decisions more transparent.

Negative:

  • Non-Determinism: LLM responses can have a degree of variability. The same comparison run twice might yield slightly different reasoning or confidence scores.
  • Latency & Cost: LLM inferences are slower and more expensive than running a local, deterministic algorithm.
  • Prompt Engineering Overhead: The quality of the comparison is highly dependent on the quality of the prompt. Crafting effective prompts is a critical and ongoing task.

Mitigation:

  • Confidence Scoring: We mitigate non-determinism by requiring a confidence score in the response. Low-confidence results can be flagged for review or discarded. We can also run the same comparison multiple times to check for consistency.
  • Targeted Application: This powerful but expensive tool is used within the Dike tournament structure, which is designed to find the single best market. It is not used for continuous, real-time analysis of all markets simultaneously.
  • Structured JSON Output: By requiring a strict JSON output schema (enforced with Zod), we ensure that even if the reasoning text varies, the core result (winner, confidence) is always machine-readable.