indicator-series
Series indicator development
File structure
All files live in src/{category}/{Indicator}/:
| File | Purpose |
|---|---|
{Indicator}.StaticSeries.cs |
Static partial class — To{Indicator}() + To{Indicator}List() entry points |
{Indicator}.StreamHub.cs |
Hub class (internal ctor) + To{Indicator}Hub() extension |
{Indicator}.BufferList.cs |
List class + To{Indicator}List() extension |
{Indicator}.Catalog.cs |
CommonListing, SeriesListing, StreamListing, BufferListing |
{Indicator}.Models.cs |
Result record(s) |
{Indicator}.Utilities.cs |
Validate() (internal), Increment() (public), RemoveWarmupPeriods() |
I{Indicator}.cs |
Parameter interface (parameter properties only; NOT result properties) |
Test files mirror in tests/indicators/{category}/{Indicator}/:
{Indicator}.StaticSeries.Tests.cs{Indicator}.BufferList.Tests.cs{Indicator}.StreamHub.Tests.cs{Indicator}.Regression.Tests.cs
Category folders: a-d, e-k, m-r, s-z (alphabetical)
Performance optimization
Array allocation pattern (use for predictable result counts; benchmark first):
TResult[] results = new TResult[length];
// ... assign results[i] = new TResult(...);
return new List<TResult>(results); // NOT results.ToList()
Some indicators (e.g., ADL) are faster with List.Add() — benchmark both.
Required implementation
Beyond the .StaticSeries.cs file, ensure:
- Catalog registration: Create
src/**/{Indicator}.Catalog.csand register inCatalog.Listings.cs - Interface file: Create
src/**/{Indicator}/I{Indicator}.cswith parameter properties (NOT result properties) - Unit tests: Create
tests/indicators/**/{Indicator}.StaticSeries.Tests.cs- Inherit from
StaticSeriesTestBase - Include
[TestCategory("Regression")]for baseline validation - Verify against manually calculated reference values
- Inherit from
- Performance benchmark: Add to
tools/performance/Perf.Series.cs - Public documentation: Update
docs/indicators/{Indicator}.md - Regression tests: Add to
tests/indicators/**/{Indicator}.Regression.Tests.cs - Migration guide: Update
docs/migration.mdfor notable and breaking changes from v2
Precision testing
- Store reference data in
{Indicator}.Data.csat maximum precision - Regression: compare full dataset using Money10-Money12
- Spot checks: use Money4
- Document when precision must be lowered due to accumulated floating-point error
Examples
- Simple:
src/s-z/Sma/Sma.StaticSeries.cs - Exponential smoothing:
src/e-k/Ema/Ema.StaticSeries.cs - Complex multi-stage:
src/a-d/Adx/Adx.StaticSeries.cs - Multi-value results:
src/a-d/Alligator/Alligator.StaticSeries.cs
See references/decision-tree.md for result interface selection.
Constraints
- Series is canonical truth — BufferList and StreamHub MUST match exactly
- Verify algorithms against authoritative reference publications only
- Never reject NaN inputs; guard against division by zero
- Fix formulas, not symptoms — see src/AGENTS.md
More from daveskender/stock.indicators
indicator-buffer
Implement BufferList incremental indicators with efficient state management. Use for IIncrementFromChain or IIncrementFromQuote implementations. Covers interface selection, constructor patterns, and BufferListTestBase testing requirements.
17indicator-catalog
Create and register indicator catalog entries for automation. Use for Catalog.cs files, CatalogListingBuilder patterns, parameter/result definitions, and PopulateCatalog registration.
17testing-standards
Testing conventions for Stock Indicators. Use for test naming (MethodName_StateUnderTest_ExpectedBehavior), FluentAssertions patterns, precision requirements, and test base class selection.
16performance-testing
Benchmark indicator performance with BenchmarkDotNet. Use for Series/Buffer/Stream benchmarks, regression detection, and optimization patterns. Target 1.5x Series for StreamHub, 1.2x for BufferList.
15code-completion
Quality gates checklist for completing code work before finishing implementation cycles
14indicator-stream
Implement StreamHub real-time indicators with O(1) performance. Use for ChainHub or QuoteProvider implementations. Covers provider selection, RollbackState patterns, performance anti-patterns, and comprehensive testing with StreamHubTestBase.
13