$ show lululu811/zettaranc-skill
This repository implements a complete quantitative trading framework for A-shares, known as 'zettaranc-skill'. It is a dual-track project: (1) a Python/Rust software application providing CLI tools, a FastAPI REST API, and a React frontend for stock analysis, backtesting, simulation, screening, and strategy optimization; (2) an AI character-play skill pack that encodes a specific trading methodology (Zettaranc/Shaofu strategies) into a SKILL.md for LLM role-play. The application side dominates: it has 15+ CLI subcommands, a modular architecture with 30+ technical indicators, 20+ strategy detectors, a multi-source data layer (Tushare, Indevs, A-Stock-Data, Hithink, SQLite), a Rust-accelerated backtesting engine (via PyO3), a walk-forward simulation framework, and a self-optimization pipeline. The codebase is well-structured with clean abstractions (DataSource protocol, unified error codes, parameter registration), extensive test coverage, and CI/CD. However, it suffers from some technical drift: dual Python/Rust implementations must stay synchronized, Chinese vernacular naming reduces readability, hardcoded constants persist, and the self-optimizer's LLM judge is a stub. Overall, it is a production-grade personal quant framework with high craftsmanship in its core components.
The LLM identified 4 files worth highlighting for reuse:
Implements a CompositeDataSource that chains multiple data sources (HithinkFinance, Tushare, A-Stock-Data, Indevs, local SQLite) in priority order, automatically degrading on failure. All sources adhere to a runtime-checkable DataSource protocol with common methods (get_daily, get_realtime_quote, etc.). This pattern is reusable for any project needing robust multi-source data access with graceful fallback.
Defines a ZettarancError (inherits ValueError) with a numeric ErrorCode enum covering all known failure modes (API errors, data validation, timeouts, etc.). Enforces narrow exception handling across the codebase (no bare 'except Exception'), improving debuggability and reliability. The pattern can be extracted to any application requiring a consistent error taxonomy.
Provides a compute_func() loader that attempts to import a Rust-compiled Python module (_core_compute) and exposes its functions via a uniform interface (try_call pattern). Controlled by ZETTARANC_BACKTEST_IMPL env var (rust/python/auto), with silent fallback to pure Python on import failure. This pattern is portable to any project needing optional native acceleration with zero-dependency degradation.
Implements a ParamRegistry that registers parameter specifications (name, type, default, min/max, step, description) for trading strategy tuning. Provides a using_params(context) context manager to temporarily override parameters for a given optimization context. Supports persistence via JSON. This pattern generalizes to any ML or simulation project needing structured hyperparameter tracking and scoped overrides.