首页/ AI 技能 / @skilllib/skill-2014279385795211267
Skill站外收录 @skilllib/skill-2014279385795211267

indicator-catalog

生成并注册用于自动化的指标目录条目,支持基于统一模型定义不同调用风格的指标方法,规范参数与结果的命名及类型约束,确保目录项在系统中的正确注册与发现。

0.0 (0) 706 次安装 原作者 编程导航
收录于 2026-01-22
效率工具 AI 技能

Skills.MD

# Indicator catalog development ## File structure - Catalog: `src/{category}/{Indicator}/{Indicator}.Catalog.cs` - Location: Same directory as `{Indicator}.Models.cs` ## Builder pattern ```csharp public static partial class Ema { /// <summary> /// EMA Common Base Listing /// </summary> internal static readonly IndicatorListing CommonListing = new CatalogListingBuilder() .WithName("Exponential Moving Average") .WithId("EMA") .WithCategory(Category.MovingAverage) .AddParameter<int>("lookbackPeriods", "Lookback Period", description: "Number of periods for the EMA calculation", isRequired: true, defaultValue: 20, minimum: 2, maximum: 250) .AddResult("Ema", "EMA", ResultType.Default, isReusable: true) .Build(); /// <summary> /// EMA Series Listing /// </summary> internal static readonly IndicatorListing SeriesListing = new CatalogListingBuilder(CommonListing) .WithStyle(Style.Series) .WithMethodName("ToEma") .Build(); /// <summary> /// EMA Stream Listing /// </summary> internal static readonly IndicatorListing StreamListing = new CatalogListingBuilder(CommonListing) .WithStyle(Style.Stream) .WithMethodName("ToEmaHub") .Build(); /// <summary> /// EMA Buffer Listing /// </summary> internal static readonly IndicatorListing BufferListing = new CatalogListingBuilder(CommonListing) .WithStyle(Style.Buffer) .WithMethodName("ToEmaList") .Build(); } ``` ## Method naming conventions | Style | Pattern | Example | | ----- | ------- | ------- | | Series | `To{IndicatorName}` | `ToEma` | | Stream | `To{IndicatorName}Hub` | `ToEmaHub` | | Buffer | `To{IndicatorName}List` | `ToEmaList` | **Critical**: `.WithMethodName()` must be in style-specific listings, NOT in CommonListing. ## Required parameter patterns - Use `AddParameter<T>()` for basic types (int, double, bool) - Use `AddEnumParameter<T>()` for enum types - Use `AddDateParameter()` for DateTime parameters - Use `AddSeriesParameter()` for `IReadOnlyList<T> where T : IReusable` - MUST set `minimum` and `maximum` for all numeric parameters ## Required result patterns - `dataName` MUST match property name in Models file exactly - Set `isReusable: true` ONLY for property mapping to `IReusable.Value` - `ISeries` models: ALL results MUST have `isReusable: false` - Exactly ONE result with `isReusable: true` per `IReusable` indicator ## Categories | Category | Examples | | -------- | -------- | | MovingAverage | EMA, SMA, HMA, TEMA | | Oscillator | RSI, Stochastic, MACD | | PriceChannel | Bollinger Bands, Keltner | | Trend | ADX, Aroon, Parabolic SAR | | Volume | OBV, Chaikin Money Flow | | Volatility | ATR, Standard Deviation | ## Registration Add to `src/_common/Catalog/Catalog.Listings.cs` in `PopulateCatalog()`: ```csharp _catalog.Add(Ema.SeriesListing); _catalog.Add(Ema.StreamListing); _catalog.Add(Ema.BufferListing); ``` Register in alphabetical order by indicator name. ## Testing Create `tests/indicators/{folder}/{Indicator}/{Indicator}.Catalog.Tests.cs`: ```csharp [TestClass] public class EmaCatalogTests : TestBase { [TestMethod] public void EmaSeriesListing() { var listing = Ema.SeriesListing; listing.Name.Should().Be("Exponential Moving Average"); listing.Style.Should().Be(Style.Series); listing.MethodName.Should().Be("ToEma"); } } ``` ## Prohibited patterns - ❌ `.WithMethodName()` in CommonListing (MUST be in style-specific listings) - ❌ Wrong indicator method name (breaks extension method discovery) - ❌ `isReusable: true` for `ISeries` models (violates interface contract) - ❌ Multiple `isReusable: true` results (ambiguous Value mapping) --- Last updated: December 31, 2025

评论 0

还没有评论,来抢沙发。