080-python-backend

080-python-backend is a cursor rule for Cursor from juandoroteoflesiauni-lang/Market-options-stocks-Scanner. It costs 0 tokens per session (2,089 once invoked), scanned A, original, Apache-2.0.

Python and FastAPI development rules for a trading-terminal backend. FastAPI is a Python framework for building web APIs, and the configuration keeps database, security, cache, and exchange settings in environment variables.

In plain words
What is it for?
Use them to set up production and development dependencies, configure PostgreSQL, Redis, JWT authentication, Binance access, logging, validation, formatting, type checking, and automated tests.
Why use it?
They provide a consistent dependency and configuration structure for the backend. Keeping secrets and deployment-specific values outside the source code reduces accidental exposure and makes environments easier to change.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use them to set up production and development dependencies, configure PostgreSQL, Redis, JWT authentication, Binance access, logging, validation, formatting, type checking, and automated tests.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/juandoroteoflesiauni-lang/market-options-stocks-scanner/080-python-backend
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 080-python-backend

README.md
[![agentmods](https://agentmods.dev/badge/rules/juandoroteoflesiauni-lang/market-options-stocks-scanner/080-python-backend/github.svg)](https://agentmods.dev/rules/juandoroteoflesiauni-lang/market-options-stocks-scanner/080-python-backend)
Your own site
<a href="https://agentmods.dev/rules/juandoroteoflesiauni-lang/market-options-stocks-scanner/080-python-backend"><img src="https://agentmods.dev/badge/rules/juandoroteoflesiauni-lang/market-options-stocks-scanner/080-python-backend/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 080-python-backend

Your own site · 80×15
<a href="https://agentmods.dev/rules/juandoroteoflesiauni-lang/market-options-stocks-scanner/080-python-backend"><img src="https://agentmods.dev/badge/rules/juandoroteoflesiauni-lang/market-options-stocks-scanner/080-python-backend.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 2,089 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.00000 $0.02089
Opus 5 $0.00000 $0.01045
Sonnet 5 $0.00000 $0.00418
Haiku 4.5 $0.00000 $0.00209

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

Security

Grade A, and why

080-python-backend 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 9d 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/080-python-backend.mdc · 311 lines

How it starts

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

🐍 PYTHON/FASTAPI — TRADING TERMINAL BACKEND

CONFIGURACIÓN DEL PROYECTO PYTHON

Estructura de dependencias:

requirements.txt          ← Producción
requirements-dev.txt      ← Solo desarrollo
# requirements.txt
fastapi==0.111.0
uvicorn[standard]==0.29.0
sqlalchemy[asyncio]==2.0.29
asyncpg==0.29.0
alembic==1.13.1
pydantic==2.7.1
pydantic-settings==2.2.1
python-jose[cryptography]==3.3.0
passlib[bcrypt]==1.7.4
redis[asyncio]==5.0.4
httpx==0.27.0
structlog==24.1.0
python-binance==1.0.19
slowapi==0.1.9

# requirements-dev.txt
pytest==8.1.1
pytest-asyncio==0.23.6
pytest-cov==5.0.0
black==24.4.2
ruff==0.4.2
mypy==1.10.0

⚙️ CONFIGURACIÓN (Settings Pattern)

# core/config.py — PATRÓN OBLIGATORIO

from pydantic_settings import BaseSettings
from pydantic import validator
from typing import Optional

class Settings(BaseSettings):
    """
    Todas las configuraciones vienen de variables de entorno.
    Nunca valores hardcodeados aquí.
    """
    # Base de datos
    DATABASE_URL: str
    REDIS_URL: str = "redis://localhost:6379/0"

    # Seguridad
    SECRET_KEY: str
    JWT_ALGORITHM: str = "HS256"
    JWT_EXPIRE_MINUTES: int = 60

    # APIs de Trading
    BINANCE_API_KEY: Optional[str] = None
    BINANCE_API_SECRET: Optional[str] = None
    MT5_LOGIN: Optional[str] = None
    MT5_PASSWORD: Optional[str] = None
    MT5_SERVER: Optional[str] = None

    # App
    ENVIRONMENT: str = "development"
    DEBUG: bool = False
    ALLOWED_ORIGINS: str = "http://localhost:5173"

    @validator('SECRET_KEY')
    def secret_key_must_be_strong(cls, v):
        if len(v) < 32:
            raise ValueError('SECRET_KEY debe tener al menos 32 caracteres')
        return v

    class Config:
        env_file = ".env"
        case_sensitive = True

settings = Settings()  # Singleton — importar este objeto

🗄️ MODELOS DE BASE DE DATOS

# models/order.py — SQLAlchemy async

from sqlalchemy import Column, String, Numeric, Enum, DateTime, ForeignKey
from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.orm import relationship
from datetime import datetime
import uuid
import enum

from core.database import Base

class OrderStatus(str, enum.Enum):
    PENDING = "pending"
    OPEN = "open"
    FILLED = "filled"
    CANCELLED = "cancelled"
    REJECTED = "rejected"

class Order(Base):
    __tablename__ = "orders"

    id = Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
    user_id = Column(UUID(as_uuid=True), ForeignKey("users.id"), nullable=False)

    symbol = Column(String(20), nullable=False, index=True)
    side = Column(String(4), nullable=False)          # BUY / SELL
    order_type = Column(String(20), nullable=False)   # MARKET / LIMIT
    status = Column(String(20), nullable=False, default=OrderStatus.PENDING)

    quantity = Column(Numeric(precision=20, scale=8), nullable=False)
    price = Column(Numeric(precision=20, scale=8), nullable=True)
    fill_price = Column(Numeric(precision=20, scale=8), nullable=True)

    created_at = Column(DateTime(timezone=True), default=datetime.utcnow)
    updated_at = Column(DateTime(timezone=True), default=datetime.utcnow, onupdate=datetime.utcnow)
    filled_at = Column(DateTime(timezone=True), nullable=True)

    exchange_order_id = Column(String(100), nullable=True, unique=True)

    # Relaciones
    user = relationship("User", back_populates="orders")

    def __repr__(self):
        return f"<Order {self.id}: {self.side} {self.quantity} {self.symbol} @ {self.price}>"

Read the full file on GitHub · 311 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. 9d ago First seen · 311 lines · 0 tokens per session scan A 3575d850d75b

Subscribe to this mod's changes

080-python-backend 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 costs nothing until one of its globs matches a file; then it loads 2,089 tokens. 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.