docs: remove C# Implementation Considerations sections, clean up temp scripts, reorganize test files

- Remove 'C# Implementation Considerations' sections from 34 indicator .md files
- Delete 29 temp PowerShell scripts (_fix_mojibake.ps1, _hex_scan.ps1, etc.)
- Move test files into tests/ subdirectories for consistent project structure
- Add trader-focused bullet points to indicator documentation
This commit is contained in:
Miha Kralj
2026-03-12 12:34:16 -07:00
parent 8937b0c0fa
commit 060649192f
1149 changed files with 1780 additions and 3316 deletions
-55
View File
@@ -108,61 +108,6 @@ Validation is performed by reproducing standard moving averages (SMA, WMA, TRIMA
| **Tulip** | ✅ | Validated against WMA (using WMA kernel). |
| **Ooples** | ✅ | Validated against WMA (using WMA kernel). |
### C# Implementation Considerations
The QuanTAlib CONV implementation optimizes convolution through pre-allocation and SIMD-accelerated dot products:
**Defensive Kernel Copy**
```csharp
_kernel = new double[_period];
Array.Copy(kernel, _kernel, _period);
```
The kernel is copied to prevent external mutation. This one-time allocation at construction ensures the indicator owns its weight array.
**State Record Struct**
```csharp
[StructLayout(LayoutKind.Auto)]
private record struct State(double LastValidValue);
private State _state;
private State _p_state;
```
Minimal state (just last valid value) enables efficient bar correction via `_p_state` snapshot/restore.
**Circular Buffer Dot Product**
```csharp
int head = _buffer.StartIndex;
int part1Len = _period - head;
result = internalBuf.Slice(head, part1Len).DotProduct(kernelSpan[..part1Len])
+ internalBuf[..head].DotProduct(kernelSpan[part1Len..]);
```
Full buffer requires two `DotProduct` calls to handle the circular wrap. The `DotProduct` extension leverages AVX2/FMA intrinsics when available.
**Stackalloc for Batch Processing**
```csharp
Span<double> window = period <= 256 ? stackalloc double[period] : new double[period];
```
Small kernels (≤256 elements) use stack allocation to avoid heap pressure during batch operations.
**Pre-sized Output Collections**
```csharp
CollectionsMarshal.SetCount(t, len);
CollectionsMarshal.SetCount(v, len);
```
Batch processing pre-sizes lists to avoid reallocation during population.
**Memory Layout**
| Field | Type | Size | Notes |
|:------|:-----|-----:|:------|
| `_period` | int | 4B | Kernel length |
| `_kernel` | double[] | 8B + N×8B | Weight array reference + data |
| `_buffer` | RingBuffer | ~40B + N×8B | Circular data buffer |
| `_state` | State | 8B | Current last valid value |
| `_p_state` | State | 8B | Previous state for rollback |
| **Total** | | ~68B + 2N×8B | Plus object overhead |
For a typical 14-period kernel: ~68 + 224 ≈ **292 bytes** per instance.
### Common Pitfalls
1. **Kernel Direction**: Our implementation applies the kernel such that the last element of the kernel multiplies the most recent data point. If you import kernels from other DSP libraries, you might need to reverse them.