czsc-write-signal-function

Write and register Rust signal functions for the CZSC event-driven trading pipeline.

6.0k|1.7k|Updated Jun 11, 2019
One-click install
npx skills add https://github.com/waditu/czsc --skill czsc-write-signal-function
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: czsc-write-signal-function
Source: https://github.com/waditu/czsc/tree/main/.claude/skills/czsc-write-signal-function
Command: npx skills add https://github.com/waditu/czsc --skill czsc-write-signal-function

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

Developing new trading signal functions in the rs_czsc Rust codebase requires following strict conventions: the 7-segment Signal string format, correct #[signal] attribute registration, proper SignalConfig wiring, and mandatory documentation sections. This Skill guides the entire workflow so signals actually trigger Event and Position matching instead of silently failing.

Core Features & Use Cases

  • Signal Authoring Workflow: Decide between K-line level signals (bar/tas/cxt) and Trader-level signals (pos), implement with the correct function signature, and enforce the 7-segment Signal format.
  • Automatic Registration: Use the #[signal(...)] macro with inventory-based collection so functions are discoverable by SignalConfig without hand-editing registry code.
  • Stub Generation: Run scripts/new_signal_stub.py to scaffold a compliant Rust function skeleton with registration attributes and boundary checks.
  • Use Case: When a new signal fails to trigger a Position open event, use the pipeline reference to check registration name casing, freq Some/None configuration, and Event signal matching rules.

Quick Start

Use the czsc-write-signal-function skill to implement and register a new K-line signal function named tas_example_v240101 in rs_czsc.

Frequently Asked Questions about czsc-write-signal-function

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a new CZSC signal function in Rust?

Choose K-line level (fn(&CZSC, &ParamView, &mut TaCache) -> Vec<Signal>) or Trader level (fn(&dyn TraderState, &ParamView) -> Vec<Signal>), implement the logic, and add a #[signal(category, name, template, opcode, param_kind)] attribute for automatic registration. Run scripts/new_signal_stub.py to generate a compliant skeleton.

How do I register a signal function so SignalConfig can find it?

Add the #[signal(...)] attribute to the function; the inventory crate collects it into the runtime registry automatically. The registration name must exactly match SignalConfig.name, including _V versus _v casing, and K-line signals need freq: Some(...) while Trader signals need freq: None.

Why is my CZSC signal not triggering any Event or Position?

Common causes are a registry name mismatch with SignalConfig.name, output that is not exactly 7 segments so Signal::from_str fails, or a wrong freq setting (Some for K-line, None for Trader). Also verify the Event's k1_k2_k3 key and score requirements match the function output.

What is the required Signal string format in rs_czsc?

A Signal must have exactly 7 underscore-separated segments: k1_k2_k3_v1_v2_v3_score, with score between 0 and 100. CzscSignals splits it into key k1_k2_k3 and value v1_v2_v3_score, and Event matching uses Signal::is_match on those fields.

When should I use a Trader-level signal instead of a K-line signal?

Use a Trader-level signal (pos style) when the logic needs access to Position or strategy state via the TraderState trait. Use a K-line signal when the logic only depends on a single timeframe's bar structure and technical indicators through TaCache.