Add eventing support to WMA indicator and implement unit tests for various indicators

- Enhanced WMA indicator with event-driven capabilities using ITValuePublisher interface.
- Created a new TODO file listing various indicators and their corresponding libraries.
- Added unit tests for DEMA, HMA, TEMA, and WMA indicators to ensure proper functionality.
- Implemented tests for handling new bars, ticks, and historical data updates across indicators.
- Verified that indicators correctly compute values and handle different source types.
This commit is contained in:
Miha Kralj
2025-12-07 16:46:38 -08:00
parent 3734a1c5f6
commit 875998b288
31 changed files with 2445 additions and 1457 deletions
+28
View File
@@ -125,6 +125,34 @@ sma.Update(new TValue(time + 1, 101.2), isNew: true);
**Implementation detail:** Bar correction is O(1) using scalar state save/restore, not buffer copying.
### Eventing and Reactive Support
This indicator implements the `ITValuePublisher` interface, enabling event-driven and reactive workflows.
* **Subscription:** Can be constructed with an `ITValuePublisher` (e.g., `TSeries`) to automatically update when the source emits a new value.
* **Publication:** Emits a `Pub` event with the new `TValue` whenever it is updated.
```csharp
using QuanTAlib;
// 1. Setup a source (publisher)
var source = new TSeries();
// 2. Create indicator subscribed to source
// It waits for events from 'source'
var sma = new Sma(source, period: 10);
// 3. Optional: Subscribe to indicator's output
sma.Pub += (item) => Console.WriteLine($"SMA Updated: {item.Value}");
// 4. Ingest data into source
// This triggers the chain: source -> sma -> Console.WriteLine
source.Add(new TValue(DateTime.Now, 100));
source.Add(new TValue(DateTime.Now, 105));
```
This pattern allows building complex, reactive processing pipelines without manual update loops.
### Handling Invalid Values (NaN/Infinity)
`Sma` uses **last-value substitution** for handling invalid inputs: