Skip to content

Data source: Historical pattern similarity via Chart Library API #3371

@grahammccain

Description

@grahammccain

Summary

OctoBot supports custom evaluators and strategies. Historical chart pattern similarity could serve as an evaluator signal — instead of only computing indicators from current data, check what happened historically when the chart looked like this.

Chart Library has 24M+ pre-computed pattern embeddings across 19K US equities (10 years). The API returns the most similar historical patterns with their actual forward returns.

How it could work as an OctoBot evaluator

import requests

class PatternSimilarityEvaluator:
    """
    Query Chart Library for historical pattern matches.
    Return evaluation based on aggregate forward returns.
    """
    
    async def evaluate(self, symbol: str, date: str) -> float:
        resp = requests.get("https://chartlibrary.io/api/v1/search", params={
            "symbol": symbol, "date": date, "timeframe": "RTH"
        }, headers={"X-API-Key": "your-key"})
        
        matches = resp.json()["matches"]
        
        # Calculate weighted signal
        win_rate = sum(1 for m in matches if m["return_5d"] > 0) / len(matches)
        avg_return = sum(m["return_5d"] for m in matches) / len(matches)
        confidence = 1.0 / (1.0 + matches[0]["distance"])
        
        # Map to OctoBot evaluation scale (-1 to 1)
        if win_rate > 0.7 and avg_return > 0:
            return min(1.0, confidence * win_rate)
        elif win_rate < 0.3 and avg_return < 0:
            return max(-1.0, -confidence * (1 - win_rate))
        return 0.0

What the API provides

Each search returns 10 historical matches, each with:

  • Symbol, date, timeframe of the match
  • L2 distance (similarity score — lower is better)
  • Forward returns at 1, 3, 5, and 10 days

Additional endpoints:

  • /api/v1/anomaly/{symbol} — unusual pattern detection
  • /api/v1/volume-profile/{symbol} — volume analysis
  • /api/v1/sector-rotation — sector momentum rankings

Details

This would give OctoBot users a "what happened historically after similar patterns" evaluator to complement existing technical analysis.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions