050-testing

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

Testing rules for a trading terminal, with Python and pytest examples for checking individual functions and complete workflows. TDD means test-driven development: writing tests as part of developing the code, often before or alongside the implementation.

In plain words
What is it for?
Use it to organize unit and integration tests, share test data, and verify trading services such as risk management, order handling, and account checks.
Why use it?
A software error in trading logic can place an invalid order or lose money. These rules provide a consistent way to catch mistakes in risk checks, orders, calculations, authentication, and related flows before live use.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/. Also seen: positional $N argument.

Needs its repository: it reads a path above its own folder, which exists only inside the repository. The line is import OrderForm from '../OrderForm';.

Good fit Use it to organize unit and integration tests, share test data, and verify trading services such as risk management, order handling, and account checks.

Compare 6 cursor rules from other repositories ↓
Install

Getting it into your agent

It runs from inside its repository, so the clone comes first — what it calls does not travel with the file alone.

Clone the repo
git clone --depth 1 https://github.com/juandoroteoflesiauni-lang/Market-options-stocks-Scanner
agentmods
npx agentmods add rules/juandoroteoflesiauni-lang/market-options-stocks-scanner/050-testing

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 050-testing

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

Your own site · 80×15
<a href="https://agentmods.dev/rules/juandoroteoflesiauni-lang/market-options-stocks-scanner/050-testing"><img src="https://agentmods.dev/badge/rules/juandoroteoflesiauni-lang/market-options-stocks-scanner/050-testing.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,398 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.02398
Opus 5 $0.00000 $0.01199
Sonnet 5 $0.00000 $0.00480
Haiku 4.5 $0.00000 $0.00240

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

Security

Grade A, and why

050-testing 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 11d 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/050-testing.mdc · 324 lines

How it starts

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

🧪 TESTING — TRADING TERMINAL

FILOSOFÍA: CÓDIGO SIN TEST = CÓDIGO ROTO

En una terminal de trading, un bug puede significar pérdida de dinero. Cada función de lógica de negocio DEBE tener al menos un test.


🐍 TESTS BACKEND (Python/Pytest)

Estructura de tests:

tests/
├── unit/                    ← Tests de funciones individuales (rápidos)
│   ├── test_risk_service.py
│   ├── test_order_service.py
│   └── test_calculators.py
├── integration/             ← Tests de flujos completos (más lentos)
│   ├── test_order_flow.py
│   └── test_auth_flow.py
├── fixtures/                ← Datos de prueba compartidos
│   └── trading_fixtures.py
└── conftest.py              ← Configuración global de pytest

Template de test unitario:

# tests/unit/test_risk_service.py
import pytest
from decimal import Decimal
from unittest.mock import AsyncMock, patch

from app.services.risk_service import RiskService
from app.schemas.order_schema import OrderCreate
from app.core.exceptions import RiskViolationError, InsufficientFundsError

class TestRiskService:
    """Tests del servicio de gestión de riesgo."""

    @pytest.fixture
    def risk_service(self):
        return RiskService()

    @pytest.fixture
    def mock_portfolio(self):
        return {
            "available_usd": Decimal("5000"),
            "total_value": Decimal("10000")
        }

    # ========== HAPPY PATH ==========

    async def test_valid_order_passes_validation(self, risk_service, mock_portfolio):
        """Orden válida dentro de límites debe pasar."""
        order = OrderCreate(
            symbol="BTCUSDT",
            side="BUY",
            order_type="MARKET",
            quantity=Decimal("0.01")
        )
        current_price = Decimal("40000")

        # No debe lanzar excepción
        await risk_service.validate_order(order, mock_portfolio, current_price)

    # ========== CASOS BORDE ==========

    async def test_order_exceeding_max_size_raises_error(self, risk_service, mock_portfolio):
        """Orden > $10,000 debe ser rechazada."""
        order = OrderCreate(
            symbol="BTCUSDT",
            side="BUY",
            order_type="MARKET",
            quantity=Decimal("1.0")  # 1 BTC a $40k = $40,000
        )

        with pytest.raises(RiskViolationError) as exc_info:
            await risk_service.validate_order(order, mock_portfolio, Decimal("40000"))

        assert "excede límite" in str(exc_info.value)

    async def test_insufficient_funds_raises_error(self, risk_service):
        """Orden sin fondos suficientes debe ser rechazada."""
        poor_portfolio = {
            "available_usd": Decimal("100"),
            "total_value": Decimal("100")
        }
        order = OrderCreate(
            symbol="BTCUSDT",
            side="BUY",
            order_type="MARKET",
            quantity=Decimal("0.1")  # $4,000
        )

        with pytest.raises(InsufficientFundsError):
            await risk_service.validate_order(order, poor_portfolio, Decimal("40000"))

    async def test_negative_quantity_raises_error(self, risk_service, mock_portfolio):
        """Cantidad negativa debe ser rechazada por Pydantic."""
        with pytest.raises(ValueError):
            OrderCreate(
                symbol="BTCUSDT",
                side="BUY",
                order_type="MARKET",
                quantity=Decimal("-1.0")
            )

Read the full file on GitHub · 324 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. 11d ago First seen · 324 lines · 0 tokens per session scan A 1ccf8557d268

Subscribe to this mod's changes

050-testing 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,398 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.