04-data-hub

04-data-hub is a cursor rule for Cursor from juandoroteoflesiauni-lang/Market-options-stocks-Scanner. It costs 25 tokens per session (1,370 once invoked), scanned A, original, Apache-2.0.

A set of rules for a market-data component that keeps external financial APIs behind one internal interface. The component selects providers, handles keys and retries, normalizes responses, and attaches information about where data came from.

In plain words
What is it for?
Use it when working on MarketDataHub, external market-data integrations, data normalization, API-key handling, retry logic, circuit breakers, and data lineage.
Why use it?
It prevents calculation code from depending directly on changing network APIs. It also keeps provider selection, secret handling, retries, and response cleanup in one place.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it when working on MarketDataHub, external market-data integrations, data normalization, API-key handling, retry logic, circuit breakers, and data lineage.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/juandoroteoflesiauni-lang/market-options-stocks-scanner/04-data-hub
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/juandoroteoflesiauni-lang/Market-options-stocks-Scanner

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for 04-data-hub

README.md
[![agentmods](https://agentmods.dev/badge/rules/juandoroteoflesiauni-lang/market-options-stocks-scanner/04-data-hub/github.svg)](https://agentmods.dev/rules/juandoroteoflesiauni-lang/market-options-stocks-scanner/04-data-hub)
Your own site
<a href="https://agentmods.dev/rules/juandoroteoflesiauni-lang/market-options-stocks-scanner/04-data-hub"><img src="https://agentmods.dev/badge/rules/juandoroteoflesiauni-lang/market-options-stocks-scanner/04-data-hub/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for 04-data-hub

Your own site · 80×15
<a href="https://agentmods.dev/rules/juandoroteoflesiauni-lang/market-options-stocks-scanner/04-data-hub"><img src="https://agentmods.dev/badge/rules/juandoroteoflesiauni-lang/market-options-stocks-scanner/04-data-hub.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 25 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,370 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00025 $0.01370
Opus 5 $0.00013 $0.00685
Sonnet 5 $0.00005 $0.00274
Haiku 4.5 $0.00003 $0.00137

Measured 12d ago against content hash ac82a75c5920, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

04-data-hub scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 12d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/04-data-hub.mdc · 163 lines

How it starts

The opening of the file, as written. The whole thing — 163 lines — stays where its author put it; the contents beside it link to each section on GitHub.

🛡️ DATA HUB — ANTI-CORRUPTION LAYER v3.0

MISIÓN

MarketDataHub es el ÚNICO componente que toca APIs externas. Fases B/C son motores de cálculo aislados de la red. Si ves import httpx en backend/phases/phase_b/RECHAZAR inmediatamente.

PATRÓN DE LLAMADA — Los motores solo ven esto:

# Lo que el motor recibe — nada más:
snapshot: MarketSnapshot = await hub.get_market_snapshot(ticker="AAPL")

# Lo que el Hub hace internamente (invisible para el motor):
# 1. Selecciona proveedor (FMP / Massive)
# 2. Rota API keys
# 3. Aplica exponential backoff
# 4. Verifica circuit breaker
# 5. Normaliza respuesta → MarketSnapshot
# 6. Adjunta data_lineage
# 7. Retorna Result[MarketSnapshot]

GESTIÓN DE SECRETOS — REGLAS CRÍTICAS

# ✅ CORRECTO — pydantic-settings con SecretStr
from pydantic import SecretStr
from pydantic_settings import BaseSettings, SettingsConfigDict

class MarketDataSettings(BaseSettings):
    model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8")
    fmp_api_key: SecretStr      # repr() muestra "**********"
    massive_api_key: SecretStr

# Acceso al valor:
key = settings.fmp_api_key.get_secret_value()

# ❌ PROHIBIDO — hardcodeado
API_KEY = "sk-abc123"

# ❌ PROHIBIDO — sin validación
key = os.getenv("API_KEY")  # Puede ser None, vacío, o formato incorrecto

RESILIENCIA — Backoff + Circuit Breaker

# Exponential backoff con jitter:
@exponential_backoff(
    max_retries=3,
    base_delay_seconds=1.0,
    max_delay_seconds=30.0,
    jitter=True,
)
async def _call_fmp_api(self, endpoint: str, params: dict[str, str]) -> dict:
    ...

# Circuit breaker:
# CLOSED → OPEN (5 fallos en 60s) → HALF-OPEN (probe) → CLOSED
# Cuando OPEN: retorna Result.failure() sin llamar la API

RESULTADO — NUNCA LANZAR EXCEPCIONES A CALLERS

# ✅ CORRECTO — Hub retorna Result, nunca lanza
async def get_market_snapshot(self, ticker: str) -> Result[MarketSnapshot]:
    try:
        raw = await self._call_fmp_api(f"/quote/{ticker}", {})
        snapshot = self._fmp_normalizer.normalize(raw, time.time_ns())
        return Result.success(snapshot)
    except (httpx.TimeoutException, ValidationError) as exc:
        logger.error("Hub falló para %s", ticker, exc_info=True)
        return Result.failure(reason=str(exc))

# ❌ PROHIBIDO — excepción cruda al caller
    raise Exception("API no disponible")

Read the full file on GitHub · 163 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 12d ago First seen · 163 lines · 1,370 tokens per session scan A ac82a75c5920

Subscribe to this mod's changes

04-data-hub is a cursor rule published in the GitHub repository juandoroteoflesiauni-lang/Market-options-stocks-Scanner (11 stars, last pushed 2mo ago), licensed Apache-2.0. It adds 25 tokens to every session and 1,370 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.