AI4Finance-Foundation / AI4Finance-Foundation/FinRL

Feature: Chart pattern similarity as observation/state for RL agents

Offen
#1,411 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Jupyter Notebook
Sterne
16.3k
Forks
3.5k
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

## Idea

FinRL agents currently use price/volume/technical indicators as state observations. Historical chart pattern similarity could add a useful signal — essentially asking "when the chart looked like this before, what happened next?"

[Chart Library](https://chartlibrary.io) has 24M+ pre-computed pattern embeddings across 19K US equities (10 years). The API returns the top-K most similar historical patterns and their forward returns, which could serve as additional state features for RL agents.

## How it could work in FinRL

```python
import requests

def get_pattern_features(symbol: str, date: str) -> dict:
"""Add pattern similarity features to FinRL state space."""
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"]

# Extract features for RL state
avg_1d_return = sum(m["return_1d"] for m in matches) / len(matches)
avg_5d_return = sum(m["return_5d"] for m in matches) / len(matches)
avg_10d_return = sum(m["return_10d"] for m in matches) / len(matches)
win_rate = sum(1 for m in matches if m["return_5d"] > 0) / len(matches)
avg_distance = sum(m["distance"] for m in matches) / len(matches)

return {
"pattern_avg_1d": avg_1d_return,
"pattern_avg_5d": avg_5d_return,
"pattern_avg_10d": avg_10d_return,
"pattern_win_rate": win_rate,
"pattern_confidence": 1.0 / (1.0 + avg_distance), # closer = more confident
}

# These features could be added to StockTradingEnv observation space
```

## Why this might help

- Pattern similarity captures non-linear chart structure that moving averages and RSI miss
- The forward returns from historical matches act as a "base rate" prior
- Low-distance matches (high confidence) correlate with more predictable outcomes
- Could be especially useful for the regime-switching aspects of trading

## Practical details

- **Free tier**: 200 calls/day, enough for daily rebalancing experiments
- **Response time**: ~100ms per search
- **Docs**: https://chartlibrary.io/developers
- **Coverage**: 19K US equities, 8 timeframes, 10 years

Curious if the team has considered pattern-based features in the observation space. Happy to discuss.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.