indicator-stream
Implements StreamHub indicator patterns for provider selection and rollback state management with O(1) efficiency.
Install
mkdir -p .claude/skills/indicator-stream && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/5457" && unzip -o skill.zip -d .claude/skills/indicator-stream && rm skill.zipInstalls to .claude/skills/indicator-stream
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Implement StreamHub real-time indicators with O(1) performance. Use for ChainHub or BarProvider implementations. Covers provider selection, RollbackState patterns, performance anti-patterns, and comprehensive testing with StreamHubTestBase.Key capabilities
- →Implement O(1) real-time indicators
- →Manage RollbackState patterns
- →Configure ChainHub or BarProvider logic
- →Perform StreamHub testing
How it works
The skill enforces O(1) incremental updates and StreamHub semantics to ensure efficient real-time data processing without recalculating history.
Inputs & outputs
When to use indicator-stream
- →Implement real-time indicators
- →Optimize data stream performance
- →Configure QuoteProvider logic
About this skill
StreamHub indicator development
A hub computes one result per provider item, incrementally, and must match the Series result exactly — including after late arrivals, removals, and pruning. The indicator-series skill owns the full per-indicator file set and completion checklist; this skill covers only the hub.
Load the reference that matches the moment:
- Choosing a base class, or the hub is not one-result-per-input (aggregator, Renko-style) → provider selection
- Adding any stateful field, or a hub test fails after late arrival or removal → rollback patterns
- Writing
ToIndicator, or a Stream benchmark is slow → performance patterns - The hub needs another hub's output as input (StochRSI on RSI, Gator on Alligator) → compound hubs
Choose a base class
| Input | Output | Base class | Example |
|---|---|---|---|
| Single value | Chainable (IReusable) | ChainHub<IReusable, TResult> | EmaHub, RsiHub |
| OHLCV bar | Chainable (IReusable) | ChainHub<IBar, TResult> | AdxHub, AtrHub |
| OHLCV bar | Multi-value, not chainable | StreamHub<IBar, TResult> | DonchianHub, KeltnerHub |
| Single value | Multi-value, not chainable | StreamHub<IReusable, TResult> | AlligatorHub |
| OHLCV bar | Bar (IBar) | BarProvider<IBar, TResult> | HeikinAshiHub, RenkoHub |
ChainHub requires TResult : IReusable; BarProvider requires TResult : IBar. Only those two can feed general downstream hubs; a compound hub typed to a specific result, such as GatorHub : StreamHub<AlligatorResult, GatorResult>, can also consume a StreamHub output.
Hub shape
Follow EmaHub (src/Indicators/e-j/Ema/EmaHub.cs):
public class EmaHub
: ChainHub<IReusable, EmaResult>, IEma
{
internal EmaHub(
IChainProvider<IReusable> provider,
int lookbackPeriods) : base(provider)
{
Ema.Validate(lookbackPeriods);
LookbackPeriods = lookbackPeriods;
K = 2d / (lookbackPeriods + 1);
Name = $"EMA({lookbackPeriods})";
ValidateCacheSize(lookbackPeriods, Name);
Reinitialize();
}
protected override (EmaResult result, int index)
ToIndicator(IReusable item, int? indexHint)
{
ArgumentNullException.ThrowIfNull(item);
int i = indexHint ?? ProviderCache.IndexOf(item, true);
// compute from ProviderCache[i], Cache[i - 1], and incremental state
// ...
return (result, i);
}
}
- The constructor is
internal; the public entry point is aTo{Name}Hub(this IChainProvider<IReusable> …)or(this IBarProvider<IBar> …)extension in the indicator's static partial class. IndyMath hubs are the exception: they reuse the Series operator name, such asMinus(this IChainProvider<IReusable> …). - Initialize every field
ToIndicatorreads before callingReinitialize(), and call it last: it replays the provider's existing history throughToIndicator. - Set
Namein the constructor; the baseToString()returns it and the hub test asserts it. - Call
ValidateCacheSize(warmupPeriods, Name)with the indicator's warmup length so a too-smallMaxCacheSizefails at construction.
Per-tick cost
ToIndicator runs once per provider item. Its cost must not grow with history length: read Cache[i - 1] or keep incremental state, never re-run a Series method or loop back to index 0. A scan bounded by the lookback window is acceptable. The performance-testing skill owns the overhead targets and benchmark authoring.
Rollback state
Any field that carries state between ToIndicator calls (buffers, running sums, smoothed averages, previous values) needs a RollbackState(int restoreIndex) override. restoreIndex is the last ProviderCache index to keep, or -1 to reset everything; rebuild state as if items [0..restoreIndex] had just been processed. The base class owns the call order and locking (documented in src/Common/AGENTS.md).
protected override void RollbackState(int restoreIndex)
{
_window.Clear();
if (restoreIndex < 0) { return; }
int startIdx = Math.Max(0, restoreIndex + 1 - LookbackPeriods);
for (int p = startIdx; p <= restoreIndex; p++)
{
_window.Add(ProviderCache[p].Value);
}
}
A hub whose ToIndicator reads only ProviderCache and Cache (like EmaHub) needs no override.
Tests
{Name}HubTests inherits StreamHubTestBase. Pick the observer interface by input type — ITestChainObserver for IReusable input, ITestBarObserver for IBar input — and add ITestChainProvider when the hub derives from ChainHub or BarProvider. The testing-standards skill owns the required methods and assertion patterns.
Hub-specific completion items
src/Indicators/{range}/{Name}/{Name}Hub.csholds the hub class and itsTo{Name}Hubextension.- Every stateful field is restored by
RollbackStateand, if it tracks absolute positions, adjusted byPruneState. tests/Library/Indicators/{range}/{Name}/{Name}HubTests.cspasses, including late-arrival, removal, and pruning parity.tools/performance/Perf.Stream.cshas a benchmark for the hub.
Do not do these
- Do not recompute history inside
ToIndicator(calling.To{Name}()on a subset, or looping from index 0). It turns streaming into O(n²). - Do not detect rebuilds inside
ToIndicator(for example by comparingito a last-processed index). The base class callsRollbackStatefor every rollback. - Do not re-emit results or touch
CachefromRollbackState. The base class removes and replays results after it returns. - Do not create a hub inside
ToIndicator. Construct any internal hub once, in the constructor. - Do not store a
CircularDoubleBufferin areadonlyfield. It is a mutable struct, soAddon a readonly field mutates a copy and the window never fills. - Do not call
Add,RemoveAt,RemoveRange, or a secondReinitializeon a subscribed hub. They throw on non-root hubs; drive changes through the rootBarHuborTradeTickHub.
When not to use it
- →When performing O(n²) recalculations
Limitations
- →O(n²) recalculation is forbidden
- →Must implement specific test interfaces for validation
How it compares
It enforces strict O(1) performance and thread-safety contracts, whereas manual implementations often risk O(n²) overhead.
Compared to similar skills
indicator-stream side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| indicator-stream (this skill) | 1 | 4mo | No flags | Advanced |
| java-pro | 34 | 7mo | No flags | Advanced |
| bullmq-specialist | 25 | 10mo | No flags | Intermediate |
| golang-pro | 14 | 7mo | No flags | Advanced |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by DaveSkender
View all by DaveSkender →You might also like
java-pro
sickn33
Master Java 21+ with modern features like virtual threads, pattern matching, and Spring Boot 3.x. Expert in the latest Java ecosystem including GraalVM, Project Loom, and cloud-native patterns. Use PROACTIVELY for Java development, microservices architecture, or performance optimization.
bullmq-specialist
davila7
BullMQ expert for Redis-backed job queues, background processing, and reliable async execution in Node.js/TypeScript applications. Use when: bullmq, bull queue, redis queue, background job, job queue.
golang-pro
sickn33
Master Go 1.21+ with modern patterns, advanced concurrency, performance optimization, and production-ready microservices. Expert in the latest Go ecosystem including generics, workspaces, and cutting-edge frameworks. Use PROACTIVELY for Go development, architecture design, or performance optimization.
go-concurrency-patterns
wshobson
Master Go concurrency with goroutines, channels, sync primitives, and context. Use when building concurrent Go applications, implementing worker pools, or debugging race conditions.
rust-async-patterns
wshobson
Master Rust async programming with Tokio, async traits, error handling, and concurrent patterns. Use when building async Rust applications, implementing concurrent systems, or debugging async code.
graphql
davila7
GraphQL gives clients exactly the data they need - no more, no less. One endpoint, typed schema, introspection. But the flexibility that makes it powerful also makes it dangerous. Without proper controls, clients can craft queries that bring down your server. This skill covers schema design, resolvers, DataLoader for N+1 prevention, federation for microservices, and client integration with Apollo/urql. Key insight: GraphQL is a contract. The schema is the API documentation. Design it carefully.