uv sync --devinstalls runtime and development dependencies.uv run uvicorn mt5api.main:app --host 0.0.0.0 --port 8000starts the API locally.uv run python -m mt5apistarts the app usingMT5API_HOST,MT5API_PORT, andMT5API_LOG_LEVEL.uv run mkdocs servepreviews the documentation site.
Important: Run these before committing or creating a PR.
- Format, lint, and test: Use
local-qaskill. - Documentation build: Run
uv run mkdocs buildwhen documentation, configuration, or OpenAPI-visible behavior changes.
- The API server must run on Windows with a logged-in MetaTrader 5 terminal.
- Linux and macOS are for HTTP clients, documentation work, and local non-runtime development only.
pdmt5: Underlying MetaTrader 5 client integration used by the API layer.fastapi: HTTP application framework and OpenAPI generation.
mt5api/: Main FastAPI package.main.py: App wiring, lifespan handling, middleware, and router registration.__main__.py: CLI entry point for launching the API from environment-backed configuration.config.py: Environment-backed configuration normalization and validation.auth.py: Optional API key authentication helpers.dependencies.py: Shared endpoint dependencies and MT5 accessors.formatters.py: JSON and Parquet response formatting helpers.models.py: Pydantic API models.middleware.py: Request logging and error handling.constants.py: Shared constants and environment variable names.routers/: Endpoint groups for operations:health.py,symbols.py,market.py,account.py,history.py,calc.py, andtrading.py.
tests/: Pytest suite covering API behavior, configuration, middleware, and CLI entry points.docs/: MkDocs documentation, including REST API and deployment guidance.
- Type hints required (pyright strict mode)
- Comprehensive linting with 35+ rule categories (ruff)
- Test coverage tracking with 100% (pytest-cov)
- Parametrized tests for input/result matrices using
pytest.mark.parametrize(pytest) - Test doubles (mocks, stubs) using
pytest_mockfor external dependencies (pytest-mock) - Pydantic models for data validation and configuration
- Update docstrings and docs when behavior, configuration, or OpenAPI-visible output changes.
- Local preview:
uv run mkdocs serve - Build validation:
uv run mkdocs build
- Run QA using
local-qaskill before committing or creating a PR. - Branch names use appropriate prefixes on creation (e.g.,
feature/...,bugfix/...,refactor/...,docs/...,chore/...). - When instructed to create a PR, create it as a draft with appropriate labels by default.
- Do not commit real MT5 credentials or API keys.
- Configure
MT5API_SECRET_KEY,MT5API_ROUTER_PREFIX, andMT5API_LOG_LEVELthrough environment variables. - Keep runtime configuration in the environment instead of hardcoding deployment values.
- Authentication mode is fixed at process startup; cover both authenticated and unauthenticated behavior when changing auth-related code.
Always prefer the simplest design that works.
- KISS: Choose straightforward solutions and avoid unnecessary abstraction.
- DRY: Remove duplication when it improves clarity and maintainability.
- YAGNI: Do not add features, hooks, or flexibility until they are needed.
- SOLID/Clean Code: Apply these as tools only when they keep the design simpler and easier to change.
Keep delivery incremental, test-backed, and easy to review.
- Make small, safe, reversible changes.
- Prefer
Red -> Green -> Refactor. - Do not mix feature work and refactoring in the same commit.
- Refactor when it improves clarity or removes real duplication (Rule of Three).
- Keep tests fast, focused, and self-validating.