bulltrackers-module 1.0.233 → 1.0.234

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.
@@ -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 {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bulltrackers-module",
3
- "version": "1.0.233",
3
+ "version": "1.0.234",
4
4
  "description": "Helper Functions for Bulltrackers.",
5
5
  "main": "index.js",
6
6
  "files": [