Metadata-Version: 2.5
Name: nlalpha-strategy
Version: 0.2.0
Summary: Strategy authoring and validation MCP service for NLAlpha
Project-URL: Homepage, https://github.com/ruimarj/nlalpha-strategy
Project-URL: Repository, https://github.com/ruimarj/nlalpha-strategy
Project-URL: Issues, https://github.com/ruimarj/nlalpha-strategy/issues
Project-URL: Changelog, https://github.com/ruimarj/nlalpha-strategy/releases
License-Expression: AGPL-3.0-or-later
License-File: LICENSE
Requires-Python: <3.13,>=3.12
Requires-Dist: mcp<2.0,>=1.0
Requires-Dist: nlalpha-core[json-log,telemetry]>=0.7.0
Requires-Dist: starlette>=0.37
Requires-Dist: uvicorn>=0.30
Description-Content-Type: text/markdown

# nlalpha-strategy

Strategy authoring package for the NLAlpha family. It discovers installed strategy families, publishes their current capabilities, and validates strategy specifications against the selected family contract.

## Agent guidance

The package skill owns the general authoring workflow and business semantics. It does not replace the current family contract or execute a backtest. Before writing a strategy, discover the installed family and read its current `about` and full `confess` guidance; those descriptions own concrete implementation requirements. The App skill does not establish that a family or execution path is available in a particular deployment.

Preserve the user's entry, holding, exit, timing, sizing, cost, and risk rules. A state such as `MA20 > MA60` is distinct from an upward cross such as `prev_fast <= prev_slow and curr_fast > curr_slow`. Rule checking and mock validation have limited scope and do not establish profitability or real-data suitability.

After basic request and non-empty-code checks, `validate_spec` applies the shared `AstValidator` policy before checking family helper bindings and AST-level strategy rules. The same forbidden-import and forbidden-call policy is used at execution, so a static pass cannot mask code the sandbox will reject. Family helper calls must use the binding shown by the current contract; for Vector, helpers are `self` methods, not standalone imports or bare names. A static pass still does not execute the strategy or prove its behavior on a real dataset.

App responsibilities are split across three skills: strategy authoring preserves and implements trading intent, data readiness checks the requested market data and time semantics, and backtest execution selects a supported path, runs authorized work, and evaluates its actual result. The shared App rules set stable identity, evidence, privacy, and reporting boundaries; they do not duplicate each skill's procedure.

## Self-description and skills

`about()` describes the service or a selected family from the cached `FamilyContract`; `confess()` returns supplementary family notes separately. `list_families()` returns `available_families`, installed `families`, and `diagnostics`. `list_skills(language="en")` returns the packaged skill catalog with the requested language, all available languages, and each skill's name, title, description, revision, and content SHA-256; call `load_skill(name="strategy-authoring", language="en")` to read one skill in one language. Shared principles are obtained from the `principles` section of an available service `about` description and may be reused while its revision remains unchanged. The core package holds the canonical skill files; this service exposes them at runtime.


## Description revision and canonical skills

Service and family descriptions use schema `nlalpha.description.v1`, include installed package version and available sections, and identify their complete canonical content with `description_revision`. A section request and a full request share the same revision. Shared principles are supplied from the core resource; `confess()` returns family-specific notes and does not duplicate them. `list_skills(language="en")` lists packaged skills without reading their full text, and `load_skill(name, language="en")` reads one language variant at a time; English is canonical and Chinese is its maintained translation. Runtime versions come from distribution metadata, not source constants.

## License

`nlalpha-strategy` is a community distribution under AGPL-3.0-or-later. Platform-owned `ai_rules`, private enhancements, and third-party dependencies are outside this package license scope.

## Container image

The public service image installs a non-editable wheel closure on Python 3.12 slim. Platform integration images are assembled separately from the platform root and its enhanced lock; Rust is not part of this service's runtime. The image exposes the strategy MCP service, and runtime configuration is supplied by the host deployment.
