KA Pattern Evaluation Overview
Quick Summary
- Take a recent slice of candles for one trading pair and test a simple synthetic pattern on that slice.
- Compare that pattern result with two baselines: buy-and-hold long, buy-and-hold short, and the raw price move.
- Walk forward through equally sized slices to see how the asset behaved next and store all metrics for review.
1. Data Scope
- Uses the same candle history as the legacy evaluator (
ticker_data_binance
). - Runs per trading pair and interval, honouring
primary_ticker_limit
fromconfig.yaml
. - Each evaluation pulls the latest configured packet count and sorts candles chronologically.
2. Pattern Window
- Select a random window length between
pattern_window_min
andpattern_window_max
. - Choose a starting index that keeps the window fully inside the dataset.
- Compute the short-term synthetic return by blending baseline returns plus a configurable margin (placeholder until the real pattern logic lands).
Stored values:
- short_term_return – synthetic pattern performance.
- long_return / short_return – baseline buy-and-hold results after fees.
- base_start_price / base_end_price – raw asset price for the window.
3. Projection Windows
After the short-term window we advance by the same window length and capture:
- Long baseline return.
- Short baseline return.
- Raw price change percentage.
These feed the trajectory chart on the KA detail page.
Example Pattern Trade (SOL_USDT, 2h)
This example mirrors a pattern captured in September 2025. All numbers are preserved here, so you can reference them even if the live database rotates entries.
- Window length: 258 candles (~21.5 days on 2h interval).
- Training slice: 2025-08-10 04:00 → 2025-08-31 22:00 UTC.
- Short-term pattern return:
+3.21%
. - Long baseline:
-4.20%
; Short baseline:+3.80%
. - Raw price move: from 209.91 → 216.65 (+3.21%).
- Projection windows: 20 steps forward (each 258 candles). Long baseline stayed positive 7 times; short baseline 13 times; price drifted upward 12 times.
Trading walkthrough
- Entry: With the short-term return beating both baselines, bias is long. Wait for a 1–2 candle pullback toward the window low, then enter long, targeting a move back toward recent highs (around 216–218).
- Risk: Size the trade so that a full reversion to the long baseline (−4.2%) equals your 1R. Place a stop just under the training slice low (≈204) or 1R below entry, whichever is closer.
- Exit: Monitor projection windows—if the long baseline dips negative or price fails to hold above the short baseline for two consecutive projections, close the position. Otherwise trail a stop under higher lows.
- Optional short play: Should the short baseline stay dominant while price projections roll over (as around projection #8 above), look for a short entry near prior resistance (~226) with a stop above 228 and targets back to the long baseline trajectory.
These steps align with the guidance shown on the KA detail page’s “How to Trade This Pattern” section.
4. Scoring
- score equals the short-term synthetic return (rounded to 6 decimals).
- Metadata tracks counts/averages of positive windows for long, short, and price projections.
5. Persistence Contract
KaEvaluationStorage
writes:
candidate_id
,trading_pair
,interval_name
,packets
score
,reference_price
metadata_json
,reasoning_json
,simulation_json
created_at
,updated_at
simulation_json
contains the short-term window, baselines, price anchors, and the projection array.
6. UI Notes
- Performance summary shows short-term vs. long/short baselines and raw price move.
- Performance trajectory plots projection windows alongside the short-term point.
- Metadata mirrors DB fields so you can cross-check stored values.
7. Future Hooks
- Replace the placeholder margin with real anomaly/pattern detection.
- Add templated trade decisions (e.g., enter long when pattern beats long baseline by X%).
- Allow per-interval projection horizons.
If you need to trace a candidate end-to-end, start with the candidate_id
in ka_pattern_candidates
, open the KA detail view, and refer back to this summary.