PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: cinar/indicatorts (ts)

Issue:
Ichimoku indicators are not completely correct
**Describe the bug**
The Tenkan-Sen should be based on the last 9 periods but the first 8 values are incorrect.
For example, the first value is calculated as follows: `(highs[0] + lows[0]) / 2`
The same goes for the Kijun-Sen, SSA, and SSB.

Also, SSA and SSB are incorrect for another reason too. They should be moved 26 periods in the future. By definition, SSA and SSB arrays should have 26 more indexes than Tenkan-Sen, Kijun-Sen, and Chikou-Span.

I think there is also another issue with the Chikou-Span (lagginsSpan) so I may update this issue a bit later.

**Expected behavior**
Until we have enough periods, the value should be null or any other default value.

Pull request:
Fix shift left function was incorrect (#452)
# Describe Request

The shift left function was incorrect

Fixed #452 

# Change Type

Fix function


Patch:
diff --git a/src/helper/numArray.ts b/src/helper/numArray.ts
index f1209ef..5461953 100644
--- a/src/helper/numArray.ts
+++ b/src/helper/numArray.ts
@@ -209,14 +209,12 @@ export function shiftLeftAndFillBy(
     fill: number,
     values: number[]
 ): number[] {
-  const result = new Array<number>(values.length);
+  const length = values.length
+  const result: number[] = Array(length).fill(fill);
 
-  for (let i = 0; i < result.length; i++) {
-    if (i < n) {
-      result[i] = values[i+n];
-    } else {
-      result[i] = fill;
-    }
+  for (let i = n; i < length; i++) {
+    const newIndex = (i - n + length) % length;
+    result[newIndex] = values[i];
   }
 
   return result;


Test patch:
diff --git a/src/indicator/momentum/ichimokuCloud.test.ts b/src/indicator/momentum/ichimokuCloud.test.ts
index d35e228..4a62131 100644
--- a/src/indicator/momentum/ichimokuCloud.test.ts
+++ b/src/indicator/momentum/ichimokuCloud.test.ts
@@ -59,12 +59,12 @@ describe('Ichimoku Cloud', () => {
     })
 
     it('laggingSpan (Chikou-Span) is closings projected in the past by the close periods', () => {
-        const highs = [2, 4, 8, 10]
-        const lows = [1, 3, 6, 3]
-        const closings = [1.5, 3.5, 7.5, 3.5]
+        const highs = [2, 4, 8, 10, 11]
+        const lows = [1, 3, 6, 3, 4]
+        const closings = [1.5, 3.5, 7.5, 3.5, 8]
 
         const {laggingSpan} = ichimokuCloud(highs, lows, closings, {close: 2})
 
-        deepStrictEqual(roundDigitsAll(2, laggingSpan), [7.5, 3.5, 0, 0]);
+        deepStrictEqual(roundDigitsAll(2, laggingSpan), [7.5, 3.5, 8, 0, 0]);
     })
 });