bulltrackers-module 1.0.233 → 1.0.235

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,6 +4,8 @@
4
4
  const { generateCodeHash, LEGACY_MAPPING } = require('../topology/HashManager.js');
5
5
  const { normalizeName } = require('../utils/utils');
6
6
 
7
+ const SYSTEM_EPOCH = require('../system_epoch');
8
+
7
9
  // Import Layers
8
10
  const MathematicsLayer = require('../layers/mathematics');
9
11
  const ExtractorsLayer = require('../layers/extractors');
@@ -99,7 +101,7 @@ function buildManifest(productLinesToRun = [], calculations) {
99
101
  const dependencies = Class.getDependencies().map(normalizeName);
100
102
  const codeStr = Class.toString();
101
103
 
102
- let compositeHashString = generateCodeHash(codeStr);
104
+ let compositeHashString = generateCodeHash(codeStr) + `|EPOCH:${SYSTEM_EPOCH}`;
103
105
  const usedDeps = [];
104
106
 
105
107
  for (const [layerName, exportsMap] of Object.entries(LAYER_TRIGGERS)) {
@@ -104,6 +104,36 @@ class DataExtractor {
104
104
  }
105
105
  static getHasTSL(position) { return position ? (position.HasTrailingStopLoss === true) : false; }
106
106
  static getOpenDateTime(position) { return (!position || !position.OpenDateTime) ? null : new Date(position.OpenDateTime); }
107
+
108
+
109
+ /**
110
+ * Returns trades that were active during the given date's 24-hour window.
111
+ * @param {Array} historyTrades - The PublicHistoryPositions array.
112
+ * @param {string} dateStr - YYYY-MM-DD string.
113
+ */
114
+ static getActiveTradesForDate(historyTrades, dateStr) {
115
+ if (!historyTrades || !Array.isArray(historyTrades)) return [];
116
+
117
+ // Define the day's window
118
+ const startTime = new Date(dateStr + "T00:00:00.000Z").getTime();
119
+ const endTime = new Date(dateStr + "T23:59:59.999Z").getTime();
120
+
121
+ return historyTrades.filter(t => {
122
+ if (!t.OpenDateTime) return false;
123
+ const openTime = new Date(t.OpenDateTime).getTime();
124
+
125
+ // 1. Must be opened before the day ended
126
+ if (openTime > endTime) return false;
127
+
128
+ // 2. If closed, must be closed after the day started
129
+ if (t.CloseDateTime) {
130
+ const closeTime = new Date(t.CloseDateTime).getTime();
131
+ if (closeTime < startTime) return false;
132
+ }
133
+
134
+ return true;
135
+ });
136
+ }
107
137
  }
108
138
 
109
139
  class priceExtractor {
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bulltrackers-module",
3
- "version": "1.0.233",
3
+ "version": "1.0.235",
4
4
  "description": "Helper Functions for Bulltrackers.",
5
5
  "main": "index.js",
6
6
  "files": [